how to set ObjectVector attributes?

39 views
Skip to first unread message

Daniel Halperin

unread,
Jan 18, 2011, 3:14:18 AM1/18/11
to ns-3-...@googlegroups.com
I want one of the parameters in an Object's construction to be a
std::vector of Objects. This is straightforward enough to set up as
an attribute:

.AddAttribute ("MeasuredPoints",
"The set of measured points in the vector.",
ObjectVectorValue (),
MakeObjectVectorAccessor (&MeasurementSet::m_measurements),
MakeObjectVectorChecker<Measurement> ())

but how do I actually set that parameter when I'm setting the object's
attributes up in the helper?

std::vector<Ptr<Measurement> > meas;

helper.Set("MeasuredPoints", ObjectVectorValue(meas));

doesn't work, nor does

helper.Set("MeasuredPoints", ObjectVectorValue<Measurement>(meas));

or

helper.Set("MeasuredPoints", ObjectVectorValue<Ptr<Measurement> >(meas));

It looks like ObjectVectorValue doesn't really have that kind of constructor.

I'm using the DoubleValue object as a reference here...

Dan

Mathieu Lacage

unread,
Jan 18, 2011, 6:05:03 AM1/18/11
to ns-3-...@googlegroups.com
On Tue, Jan 18, 2011 at 09:14, Daniel Halperin
<dhal...@cs.washington.edu> wrote:
> I want one of the parameters in an Object's construction to be a
> std::vector of Objects.  This is straightforward enough to set up as
> an attribute:

The short answer is that this is not possible. See ObjectVectorAccessor::Set.

[lengthy rationale elided]

Mathieu
--
Mathieu Lacage <mathieu...@gmail.com>

Reply all
Reply to author
Forward
0 new messages