Sierra Toolkit  Version of the Day
stk_classic::CSet Class Reference

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 *)
 

Detailed Description

Set of entities of arbitrary types.

Todo:
REFACTOR Use smart pointers to avoid destruction issue.

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 ;
 }

Definition at line 51 of file CSet.hpp.

Member Function Documentation

◆ get()

template<class T >
const T* stk_classic::CSet::get ( ) const

Get member conforming to the given type.

◆ insert_with_delete()

template<class T >
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.

◆ insert_no_delete()

template<class T >
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.

◆ remove()

template<class T >
bool stk_classic::CSet::remove ( const T *  )

Erase a member without deleting. Return if the remove operation was successful.


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