[Ns-bugs] [Bug 133] automate memory management of RandomVariable

bugzilla-daemon@nsnam-www.ece.gatech.edu bugzilla-daemon at nsnam-www.ece.gatech.edu
Thu Feb 7 09:37:11 PST 2008


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





------- Comment #4 from mathieu.lacage at sophia.inria.fr  2008-02-07 12:37 -------
(In reply to comment #3)

> Mathieu, could you provide a summary of this patch?  From what I see, it
> appears that RandomVariables now are passed only by value.  It also appears

yes.

> that there is some renaming and some extra indirection introduced into the
> object and ownership heirarchy (RandomVariable owns a RandomVariableBase, which
> is subclassed by Impl classes?)

Yes. Details below.

The previously-existing RandomVariable base class has been renamed to
RandomVariableBase. The previously-existing XXXVariable classes have been
renamed to XXXVariableImpl and they now subclass RandomVariableBase. Finally, a
new RandomVariable base class has been introduced which holds a pointer to a
RandomVariableBase subclass and does the memory management of the underlying
RandomVariableBase subclass. Basically, the RandomVariable class is not a smart
pointer which knows how to copy and delete RandomVariableBase subclasses. The
other XXXRandomVariable subclasses of the RandomVariable base class are just
conveniant constructors and were added to avoid changing the user-visible API.
i.e., to make it still possible to pass a temporary UniformVariable through a
function call.

This patchset is basically replacing the existing C++ variables of type
"RandomVariable *" into variables of type "RandomVariable". i.e., it is
removing the pointer and relieves the user from doing memory management
himself. As I said earlier, it would be trivially possible to achieve the same
result by using Ptr<RandomVariable> but this would break the user-visible API
since the user would not be able anymore to pass around temporary
UniformVariable objects.


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


More information about the Ns-bugs mailing list