[Ns-bugs] [Bug 517] New: RandomVariable serialization is ugly

code@nsnam.ece.gatech.edu code at nsnam.ece.gatech.edu
Tue Mar 3 12:33:00 PST 2009


http://www.nsnam.org/bugzilla/show_bug.cgi?id=517

           Summary: RandomVariable serialization is ugly
           Product: ns-3
           Version: ns-3-dev
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P5
         Component: simulation core
        AssignedTo: ns-bugs at isi.edu
        ReportedBy: raj.b at gatech.edu
   Estimated Hours: 0.0


Created an attachment (id=396)
 --> (http://www.nsnam.org/bugzilla/attachment.cgi?id=396)
make random variable serialize cleaner

The code for serializing RandomVariables to an ostream (ostream&
operator<<(ostream&, const RandomVariable&)) is a series of downcasts testing
for which subclass is being serialized, with some per-type code to actually
perform the serialization.  Each writer of a new variable type will at some
point have to go in to this code and write another downcast, and another chunk
of type specific code.

The attached patch inverts the responsibility of serialization to a method in
each subclass, adds a pure virtual method in the base class to enforce the
existence of this method, and has the serialization code call the virtual
method.  This eliminates the downcasts and the need to change the serialization
code for each RandomVariable type added to ns-3.


-- 
Configure bugmail: http://www.nsnam.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the Ns-bugs mailing list