CYCLUS
Loading...
Searching...
No Matches
cyclus::IntrusiveBase< Derived > Class Template Reference

Detailed Description

template<class Derived>
class cyclus::IntrusiveBase< Derived >

IntrusiveBase provides a base class that fulfulls basic requirements for a (sub) class to be used in a boost::intrusive_ptr.

Allows subclasses to track their reference count via the onboard "counter_" member variable. To use a class as a boost::intrusive_ptr, it should inherit from IntrusiveBase with default access (NOT public). All destructors of subclasses (and subsub, etc.) should be virtual to ensure memory deallocation occurs properly for objects that have been up-casted:

class Resource: IntrusiveBase<Resource> {
...
virtual ~Resource();
...
}
int main(...) {
boost::intrusive_ptr<Resource> Resource(new Resource());
boost::intrusive_ptr<Resource> resource2(new Resource());
// use resource as if it were a regular pointer, e.g.
double quantity = resource->quantity();
// equals operator compares raw pointer values:
// always true
if (resource == resource) {}
// always false
if (resource == resource2) {}
// don't worry about deallocation - it will be automatic.
}
IntrusiveBase provides a base class that fulfulls basic requirements for a (sub) class to be used in ...
Resource defines an abstract interface implemented by types that are offered, requested,...
Definition resource.h:22
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters

Definition at line 45 of file intrusive_base.h.

#include <intrusive_base.h>

Protected Member Functions

 IntrusiveBase ()
 
 IntrusiveBase (const IntrusiveBase &)
 
IntrusiveBaseoperator= (const IntrusiveBase &)
 
 ~IntrusiveBase ()
 

Constructor & Destructor Documentation

◆ IntrusiveBase() [1/2]

template<class Derived >
cyclus::IntrusiveBase< Derived >::IntrusiveBase ( )
inlineprotected

protected because we don't want direct instantiations of

Definition at line 63 of file intrusive_base.h.

◆ ~IntrusiveBase()

template<class Derived >
cyclus::IntrusiveBase< Derived >::~IntrusiveBase ( )
inlineprotected

Definition at line 65 of file intrusive_base.h.

◆ IntrusiveBase() [2/2]

template<class Derived >
cyclus::IntrusiveBase< Derived >::IntrusiveBase ( const IntrusiveBase< Derived > & )
inlineprotected

the copy constructor must zero out the ref count

Definition at line 68 of file intrusive_base.h.

Member Function Documentation

◆ operator=()

template<class Derived >
IntrusiveBase & cyclus::IntrusiveBase< Derived >::operator= ( const IntrusiveBase< Derived > & )
inlineprotected

Definition at line 70 of file intrusive_base.h.


The documentation for this class was generated from the following file: