|
Bugzilla – Full Text Bug Listing |
| Summary: | base class for reference counted objects | ||
|---|---|---|---|
| Product: | ns-3 | Reporter: | Tom Henderson <tomh> |
| Component: | core | Assignee: | ns-bugs <ns-bugs> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | P3 | ||
| Version: | pre-release | ||
| Hardware: | All | ||
| OS: | All | ||
| Attachments: | class RefCountBase | ||
|
Description
Tom Henderson
2008-03-17 09:07:00 UTC
Created attachment 116 [details]
class RefCountBase
(In reply to comment #0) > As discussed in November, a base class for providing implementations of > Ref/Unref for classes that do not derive from ns3::Object. > > Written by George, with proposed rename by Tom from "SmartPointer" to > "RefCountBase". > > We need to decide which classes use this base class. Should any of the below > be specifically excluded from this class?: > AttributeAccessor > AttributeChecker > Packet > Object > TraceSourceAccessor Object should not because the implementation is very different/incompatible. All the others could but they already derive from the ObjectBase class so doing what you suggest now would require some multiple inheritance which I would rather avoid. Since I plan to remove eventually the ObjectBase class from their inheritance tree, could we defer using RefCountBase in the classes which derive from ObjectBase until I have done that removal ? Other than that, looks good to me. (In reply to comment #2) > Object should not because the implementation is very different/incompatible. > All the others could but they already derive from the ObjectBase class so doing > what you suggest now would require some multiple inheritance which I would > rather avoid. > > Since I plan to remove eventually the ObjectBase class from their inheritance > tree, could we defer using RefCountBase in the classes which derive from > ObjectBase until I have done that removal ? > > Other than that, looks good to me. > Instead, we could add Ref and Unref into ObjectBase, and then eventually renaming ObjectBase to RefCountedBase? There is no problem with Object inheriting from this class too (as it does now), because it would just reimplement Ref and Unref with its own implementation, provided we make the ObjectBase::Ref and Unref methods virtual. (In reply to comment #3) > (In reply to comment #2) > > Object should not because the implementation is very different/incompatible. > > All the others could but they already derive from the ObjectBase class so doing > > what you suggest now would require some multiple inheritance which I would > > rather avoid. > > > > Since I plan to remove eventually the ObjectBase class from their inheritance > > tree, could we defer using RefCountBase in the classes which derive from > > ObjectBase until I have done that removal ? > > > > Other than that, looks good to me. > > > > Instead, we could add Ref and Unref into ObjectBase, and then eventually > renaming ObjectBase to RefCountedBase? There is no problem with Object The plan is to move the attribute system to ObjectBase, not the reference counting to allow classes which do not want to be refcounted to get the attributes anyway. The only reason why they inherit from ObjectBase now is that I needed to do this as a temporary hack to get the attributes working a few weeks ago and never removed it since then because no one reminded me of the merge of RefCountedBase. > inheriting from this class too (as it does now), because it would just > reimplement Ref and Unref with its own implementation, provided we make the > ObjectBase::Ref and Unref methods virtual. We cannot make these virtual for performance reasons. Since there were no comments on this bug for a while, and since tom's patch seems ok and since the ObjectBase code was merged earlier last week, I pushed out tom's patch (modulo a few things to make it build). Final patch: changeset 03a23eb5f1e8 |