[Ns-developers] How to serialize a array

Mihai Oprea misulica.o at gmail.com
Tue Dec 23 10:38:31 PST 2008


>From what I learned so far, AddHeader will try to call
example[i].Serialize(), and since example[i] is not a class already inside
NS-3, we have to implement the serialization function ourselves.

Mihai

On Tue, Dec 23, 2008 at 20:29, Mathieu Lacage <
mathieu.lacage at sophia.inria.fr> wrote:

> On Mon, 2008-12-22 at 10:58 +0000, Nuno Farias wrote:
> > Hi!
> >
> > I having a problem that probably has a very easy solution but I don't
> > know how to solve it.
> >
> > Basically I have a class (here is resumed):
> >
> > class PREQElement
> > {
> > public:
> >  PREQElement ();
> >
> >  uint8_t m_pdflags;
> >  Mac48Address m_destinationaddress;
> >  uint64_t m_destinationseqnum;
> >
> >  uint32_t GetSerializedSize (void) const
> >  { return 1+6+8;}
> >
> >  void Serialize (Buffer::Iterator start) const
> >  {
> >    i.WriteU8(m_pdflags);
> >    WriteTo (i, m_destinationaddress);
> >    i.WriteU64 (m_destinationseqnum);
> >  }
> >
> >  Buffer::Iterator Deserialize (Buffer::Iterator start)
> >  {
> >    m_pdflags = i.ReadU8 ();
> >    ReadFrom (i, m_destinationaddress);
> >    m_destinationaddress = i.ReadU64 ();
> >  }
> > };
> >
> > and in other class called "class PREQElement :: public Header" I have to
> > do a
> >
> > PREQElement example[50];
> >
> > How do I serialize this? I can't just call serialize... How can I do it?
>
> Sorry if I missed something obvious, but, what is wrong about this ?
>
> for (int i = 0; i < 50; i++)
>  {
>    p->AddHeader (example[i]);
>  }
>
>
> >
> > Sorry if this is very easy.
> >
> > Thanks,
> > Nuno.
>
>


-- 
Mihai Oprea

School of Engineering and Applied Science
University of Pennsylvania '09
US: +1 (970) 412 1909
RO: +40 (72) 000 2704


More information about the Ns-developers mailing list