Sierra Toolkit
Version of the Day
|
Set of entities of arbitrary types. More...
#include <CSet.hpp>
Public Member Functions | |
template<class T > | |
const T * | get () const |
template<class T > | |
const T * | insert_with_delete (const T *) |
template<class T > | |
const T * | insert_no_delete (const T *) |
template<class T > | |
bool | remove (const T *) |
Set of entities of arbitrary types.
Example usage of the three methods:
class A { ... }; class B { ... };
CSet cset ;
// Insert pointers to objects:
cset.insert<A>( new A ); // Do not delete on destruction cset.insert<B>( new B , true ); // Delete on destruction
// Query the collection of objects of a given type:
const A * sa = cset.get<A>(); const B * sb = cset.get<B>();
// Remove a member:
{ B * b = ... ; cset.remove<B>( b ); // Remove never deletes delete b ; }
const T* stk_classic::CSet::get | ( | ) | const |
Get member conforming to the given type.
const T* stk_classic::CSet::insert_with_delete | ( | const T * | ) |
Insert a new member. Invoke 'delete' upon destruction. If already exists then return existing member, insert fails.
const T* stk_classic::CSet::insert_no_delete | ( | const T * | ) |
Insert a new member. Do nothing to it upon destruction. If already exists then return existing member, insert fails.
bool stk_classic::CSet::remove | ( | const T * | ) |
Erase a member without deleting. Return if the remove operation was successful.