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

Set of entities of arbitrary types. More...

#include <CSet.hpp>

List of all members.

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

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

Get member conforming to the given type.

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

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

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

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


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends