#include <OwnedCntrShared.hh>
Inheritance diagram for MangoPtr::Owned< CntrType &, OShared >:
The container instance must live somewhere else, therefore this class must be used with care:
The only "good" places to use Owned<Container &> seem to be:
See the general documentation for Owned<T> to get more usage information.
Definition at line 70 of file OwnedCntrShared.hh.
Public Types | |
typedef CntrType | ObjectType |
Class of object held, a la auto_ptr. | |
Public Methods | |
Constructors | |
Owned (CntrType &) | |
Take ownership of a container of pointers. | |
Owned (const Owned &) | |
Take ownership of a container of pointers, but by copy. | |
~Owned () | |
Use the method pointer to do the clean up. | |
Utility methods | |
void | cloneObjNew (CntrType &) const |
Convenience method to create a deep-copied copy of the owned container, using new() (if you have defined a specialization of CntrCloner for your container element type and it is visible at the time of copy, that one will be used by the compiler instead of new()), into dest. | |
void | reset () |
Reset the container owned to empty pointers. | |
CntrType & | cntr () |
Use this method to get ref to container. | |
const CntrType & | cntr () const |
Use this method to get ref to const container. | |
CntrType * | operator() () |
Use this method to get a pointer to container, never NULL. | |
const CntrType * | operator() () const |
Use this method to get a const pointer to container, never NULL. |
|
Use the method pointer to do the clean up. This supports default destructors of classes that want to use only a forward declaration of the container's element type. Definition at line 146 of file OwnedCntrShared.hh. References MangoPtr::Owned< CntrType, oshiptype >::reset(). |
|
Take ownership of a container of pointers. The cntr is transfered to Owned, meaning that after creation, the original container is empty. This requires a exception-safe, performant std::swap to be defined CntrType. Definition at line 123 of file OwnedCntrShared.hh. |
|
Take ownership of a container of pointers, but by copy. The cntr is shallow-copied to Owned. This uses more memory than the transfering constructor, but allows the user to keep working with the original, confident that the memory will be freed when the Owned goes out of scope. Ie., user must make sure that original list elements are not used *after* the Owned has gone out of scope Definition at line 136 of file OwnedCntrShared.hh. |
|
Convenience method to create a deep-copied copy of the owned container, using new() (if you have defined a specialization of CntrCloner for your container element type and it is visible at the time of copy, that one will be used by the compiler instead of new()), into dest. To clone into another owned container, use cloneObjNew(owned.cntr()).
Definition at line 179 of file OwnedCntrShared.hh. |
|
Reset the container owned to empty pointers. Remember that this affects the original container, as well as all the other owners sharing this container. The result is that the original container is empty and every element has had delete called on it. Definition at line 159 of file OwnedCntrShared.hh. |