CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
LogicFactory< Ilogic, Identifier, LogicCreator > Class Template Reference

#include <LogicFactory.h>

Public Member Functions

Ilogic * CreateObject (const Identifier &id)
 
bool Register (const Identifier &id, LogicCreator creator)
 
bool Unregister (const Identifier &id)
 

Private Attributes

std::map< Identifier,
LogicCreator > 
m_associations
 

Detailed Description

template<class Ilogic, typename Identifier, typename LogicCreator = Ilogic * (*)()>
class LogicFactory< Ilogic, Identifier, LogicCreator >

Author
Andres Osorio

email: aosor.nosp@m.io@u.nosp@m.niand.nosp@m.es.e.nosp@m.du.co

Date
2008-10-11

Definition at line 21 of file LogicFactory.h.

Member Function Documentation

template<class Ilogic, typename Identifier, typename LogicCreator = Ilogic * (*)()>
Ilogic* LogicFactory< Ilogic, Identifier, LogicCreator >::CreateObject ( const Identifier &  id)
inline

Definition at line 39 of file LogicFactory.h.

Referenced by LogicTool< RBCLogic >::retrieve().

40  {
41  typename std::map<Identifier, LogicCreator>::const_iterator itr;
42  itr = m_associations.find( id );
43 
44  if ( itr != m_associations.end() ) {
45  return ( itr->second )();
46  } else return NULL; // handle error
47  }
std::map< Identifier, LogicCreator > m_associations
Definition: LogicFactory.h:53
#define NULL
Definition: scimark2.h:8
template<class Ilogic, typename Identifier, typename LogicCreator = Ilogic * (*)()>
bool LogicFactory< Ilogic, Identifier, LogicCreator >::Register ( const Identifier &  id,
LogicCreator  creator 
)
inline

Definition at line 24 of file LogicFactory.h.

Referenced by LogicTool< RBCLogic >::initialise().

25  {
26  return m_associations.insert(typename std::map<Identifier, LogicCreator>::value_type(id,creator)).second;
27  }
std::map< Identifier, LogicCreator > m_associations
Definition: LogicFactory.h:53
Container::value_type value_type
template<class Ilogic, typename Identifier, typename LogicCreator = Ilogic * (*)()>
bool LogicFactory< Ilogic, Identifier, LogicCreator >::Unregister ( const Identifier &  id)
inline

Definition at line 29 of file LogicFactory.h.

Referenced by LogicTool< RBCLogic >::endjob().

30  {
31  typename std::map<Identifier, LogicCreator>::const_iterator itr;
32  itr = m_associations.find(id);
33  if( itr != m_associations.end() ) {
34  delete ( itr->second )() ;
35  }
36  return m_associations.erase(id) == 1;
37  }
std::map< Identifier, LogicCreator > m_associations
Definition: LogicFactory.h:53

Member Data Documentation

template<class Ilogic, typename Identifier, typename LogicCreator = Ilogic * (*)()>
std::map<Identifier, LogicCreator> LogicFactory< Ilogic, Identifier, LogicCreator >::m_associations
private