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 >
125 remove (
const std::string & name )
127 typename std::map < std::string, Type * > ::iterator
it
128 = m_types.find ( name );
129 if ( it != m_types.end () ) {
130 m_types.erase ( it );
134 template <
class Type >
136 exists (
const std::string & name )
const
140 typename std::map< std::string, Type * >::const_iterator
it
141 = m_types.find ( name );
143 return it != m_types.end ();
147 template<
class Type >
152 typename std::map< std::string, Type * >::const_iterator
it
153 = m_types.find ( name );
159 template<
class Type >
162 Type * obj = prototype ( name );
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_
std::vector< std::string > m_names
The list of available types by names.
The base class for singleton factory classes.
Type * create(const std::string &name)
Creates a new object from a prototype named name.
Type * prototype(const std::string &name) const
Returns a pointer to a prototype with name name.
const std::vector< std::string > & names() const
Returns the list of available prototype names.
std::map< std::string, Type * > m_types
A list of available types.
void add(Type *)
Adds a prototype object to the list of prototypes.
virtual ~Factory()
The destructor.
bool exists(const std::string &name) const
Returns true if prototype with name name exists in the factory, otherwise returns false...
FactoryException class interface.
Factory()
The default constructor.
An exception class that is thrown when the factory fails to find the request class by its name...
list< QAction * >::iterator it