stk::CSet Class Reference
[Util_module]

Set of entities of arbitrary types. More...

#include <CSet.hpp>

List of all members.

Public Member Functions

template<class T >
const T * get () const
 Get member conforming to the given type.
template<class T >
const T * insert_with_delete (const T *)
 Insert a new member.
template<class T >
const T * insert_no_delete (const T *)
 Insert a new member.
template<class T >
bool remove (const T *)
 Erase a member without deleting.

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

template<class T >
const T* stk::CSet::get (  )  const [inline]

Get member conforming to the given type.

template<class T >
const T* stk::CSet::insert_with_delete ( const T *   )  [inline]

Insert a new member.

Invoke 'delete' upon destruction. If already exists then return existing member, insert fails.

template<class T >
const T* stk::CSet::insert_no_delete ( const T *   )  [inline]

Insert a new member.

Do nothing to it upon destruction. If already exists then return existing member, insert fails.

template<class T >
bool stk::CSet::remove ( const T *   )  [inline]

Erase a member without deleting.

Return if the remove operation was successful.


The documentation for this class was generated from the following files:
Generated on Wed Apr 13 10:05:49 2011 for Sierra Toolkit by  doxygen 1.6.3