33#ifndef G4CREATORFACTORYT_HH
34#define G4CREATORFACTORYT_HH
39template <
typename T,
typename Identifier,
typename Creator>
54 T*
Create(
const Identifier&
id)
const;
58 typedef std::map<Identifier, Creator> Map;
65template <
typename T,
typename Identifier,
typename Creator>
68template <
typename T,
typename Identifier,
typename Creator>
71template <
typename T,
typename Identifier,
typename Creator>
76 if (fMap.find(
id) != fMap.end()) {
78 ed <<
"Creator with identifier "<<
id<<
" already exists."<<
G4endl;
80 (
"G4CreatorFactoryT::Register(const Identifier& id, Creator creator)",
87 std::pair<Identifier, Creator> myPair(
id, creator);
88 return fMap.insert(myPair).second;
91template <
typename T,
typename Identifier,
typename Creator>
95 typename Map::const_iterator iter = fMap.find(
id);
97 if (iter == fMap.end()) {
99 ed <<
"Identifier "<<
id<<
" does not exist."<<
G4endl;
100 G4Exception(
"G4CreatorFactoryT::Create(const Identifier& id)",
102 "Non-existent identifier");
106 return iter->second();
G4bool Register(const Identifier &id, Creator creator)
T * Create(const Identifier &id) const
virtual ~G4CreatorFactoryT()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
std::ostringstream G4ExceptionDescription