20 #include "msdevstudio/MSconfig.h" 58 mutable std::vector< std::string >
m_names;
75 void remove (
const std::string & name );
80 bool exists (
const std::string & name )
const;
94 const std::vector< std::string > &
names ()
const;
98 template <
class Type >
103 template<
class Type >
106 typename std::map < std::string, Type * > ::iterator first
108 for ( ; first !=
m_types.end(); ++first ) {
109 delete first->second;
115 template<
class Type >
118 const std::string & name = obj->name ();
122 template <
class Type >
127 typename std::map < std::string, Type * > ::iterator it
134 template <
class Type >
136 exists (
const std::string & name )
const 140 typename std::map< std::string, Type * >::const_iterator it
147 template<
class Type >
152 typename std::map< std::string, Type * >::const_iterator it
159 template<
class Type >
166 return obj->clone ();
169 template<
class Type >
173 typename std::map <std::string, Type *>::const_iterator it
175 for ( ; it !=
m_types.end (); ++it ) {
176 m_names.push_back ( it->first );
184 #endif // _Factory_H_ void remove(const std::string &name)
Removes the named prototype object from the list of prototypes.
FactoryException class interface.
const std::vector< std::string > & names() const
Returns the list of available prototype names.
Factory()
The default constructor.
virtual ~Factory()
The destructor.
void add(Type *)
Adds a prototype object to the list of prototypes.
Type * create(const std::string &name)
Creates a new object from a prototype named name.
std::vector< std::string > m_names
The list of available types by names.
std::map< std::string, Type *> m_types
A list of available types.
An exception class that is thrown when the factory fails to find the request class by its name...
bool exists(const std::string &name) const
Returns true if prototype with name name exists in the factory, otherwise returns false...
The base class for singleton factory classes.
Type * prototype(const std::string &name) const
Returns a pointer to a prototype with name name.