CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
LogicFactory< Ilogic, Identifier, LogicCreator > Class Template Reference

#include <LogicFactory.h>

Public Member Functions

std::unique_ptr< Ilogic > CreateObject (const Identifier &id) const
 
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 20 of file LogicFactory.h.

Member Function Documentation

◆ CreateObject()

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

Definition at line 28 of file LogicFactory.h.

References LogicFactory< Ilogic, Identifier, LogicCreator >::m_associations.

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

28  {
29  auto itr = m_associations.find(id);
30 
31  if (itr != m_associations.end()) {
32  return std::unique_ptr<Ilogic>{(itr->second)()};
33  } else
34  return nullptr; // handle error
35  }
std::map< Identifier, LogicCreator > m_associations
Definition: LogicFactory.h:39

◆ Register()

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

Definition at line 22 of file LogicFactory.h.

References LogicFactory< Ilogic, Identifier, LogicCreator >::m_associations.

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

22  {
23  return m_associations.insert(typename std::map<Identifier, LogicCreator>::value_type(id, creator)).second;
24  }
std::map< Identifier, LogicCreator > m_associations
Definition: LogicFactory.h:39

◆ Unregister()

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

Definition at line 26 of file LogicFactory.h.

References LogicFactory< Ilogic, Identifier, LogicCreator >::m_associations.

26 { return m_associations.erase(id) == 1; }
std::map< Identifier, LogicCreator > m_associations
Definition: LogicFactory.h:39

Member Data Documentation

◆ m_associations

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