#include <Derivhdl.hh>
Collaboration diagram for RazorBack::Derivhdl_:
Public Methods | |
Derivhdl_ () | |
default ctor: init to empty. | |
Derivhdl_ (const BaseT_ &B) | |
init with a BaseT_ object, stores a deep copy: also BaseT_ -> wrapper conversion. | |
Derivhdl_ (const Derivhdl_ &D) | |
copy ctor, implements shallow copy. | |
~Derivhdl_ () | |
destructor. | |
Derivhdl_& | operator= (const Derivhdl_ &Rhs) |
assignment. | |
bool | empty () const |
empty(). | |
const BaseT_& | ref () const |
ref(): access to the underlying BaseT_ object. More... | |
BaseT_& | ref () |
const BaseT_* | ptr () const |
ptr(): returns a pointer to the underlying BaseT_ object. More... | |
BaseT_* | ptr () |
template<class DerivedT_> const DerivedT_* | real_ptr () const |
real_ptr(): returns a pointer to the wrapped object of type DerivedT_. More... | |
template<class DerivedT_> DerivedT_* | real_ptr () |
bool | operator< (const Derivhdl_< BaseT_ > &Rhs) const |
<: comparison for STL algorithms Empty objects are always "smaller" than non-empty ones Uses the < operator of BaseT_. | |
Protected Methods | |
void | unlink_old () |
Private Attributes | |
Refcount_* | Dataptr |
The Derivhdl_<BaseT_> provides the external interface, and holds a pointer to a Refcount_<BaseT_> object. The Refcount_<BaseT_> class may be pointed to by several Derivhdl_ classes. Refcount_<BaseT_> holds one BaseT_ base type pointer and owns the object pointed to by BaseT_. That object itself may be of type BaseT_ or any class derived from BaseT_.
Derivhdl_<BaseT_> Derivhdl_<BaseT_> | | +------+ +------+ |...| V V Refcount_<BaseT_> | V BaseT_
1) The BaseT_ class must have a virtual constructor method that looks like BaseT_* T_::virtual_ctor() const { return new T_(*this); } where T_ is a type possibly derived from BaseT_. This function shall return a BaseT_ pointer to a freshly allocated copy of the calling object. 2) BaseT_ shall provide the less-than comparison operator < to be used by the STL. This is called via the comparison operator of Derivhdl_.
Definition at line 70 of file Derivhdl.hh.
|
default ctor: init to empty.
Definition at line 108 of file Derivhdl.hh. |
|
init with a BaseT_ object, stores a deep copy: also BaseT_ -> wrapper conversion.
Definition at line 111 of file Derivhdl.hh. |
|
copy ctor, implements shallow copy.
Definition at line 117 of file Derivhdl.hh. |
|
destructor.
Definition at line 123 of file Derivhdl.hh. |
|
assignment.
|
|
empty().
Definition at line 129 of file Derivhdl.hh. Referenced by operator<(). |
|
ref(): access to the underlying BaseT_ object. Throws Emptyexc_ if the calling object is empty. Referenced by operator<(). |
|
|
|
ptr(): returns a pointer to the underlying BaseT_ object. Returns NULL if the calling object is empty. Referenced by real_ptr(). |
|
|
|
real_ptr(): returns a pointer to the wrapped object of type DerivedT_. dynamic_cast must be able to convert from BaseT_* to DerivedT_*. In general, you should manipulate the wrapped objects only through their virtual methods. However, under some circumstances it might be useful to know and use the "real" type of the polymorphic object wrapped in Derivhdl_ (for instance when doing I/O). If the conversion was unsuccessful or the wrapper was empty then NULL is returned. Use this at least as carefully as you would dynamic_cast! Always test the returned pointer! Definition at line 157 of file Derivhdl.hh. |
|
Definition at line 162 of file Derivhdl.hh. |
|
<: comparison for STL algorithms Empty objects are always "smaller" than non-empty ones Uses the < operator of BaseT_.
Definition at line 172 of file Derivhdl.hh. |
|
Referenced by ~Derivhdl_(). |
|
Definition at line 102 of file Derivhdl.hh. |