= Factory = [[TracNav(TracNav/TOC_Development)]] == Description == The [wiki:Factory] is a [wiki:singleton] that maps [wiki:Identifier Identifiers] with their name and their network ID. The [wiki:Factory] is used by the !CreateFactory(classname) macro (include [wiki:CoreIncludes CoreIncludes.h] to use it) to add new entries and by the ID("classname") and ID(network ID) macros (include [wiki:CoreIncludes CoreIncludes.h] to use them) to retrieve an [wiki:Identifier] with a given classname or a given network ID respectively. The ID macro is an abbreviation of the static function Factory::getIdentifier(...). The [wiki:Factory] also handles the change of a network ID to avoid conflicts with ambiguous map-entries. Because the [wiki:Factory] knows all Identifiers with a [wiki:ClassFactory], it provides functions to get the map-iterators to iterate through all stored Identifiers. == Functions == * '''Identifiers''': * add(name, identifier) adds an [wiki:Identifier] with a given name (this is usually done by the !CreateFactory(classname) macro (read the Wiki-page of [wiki:CoreIncludes] for more information). * getIdentifier(name) and getIdentifier(network ID) return the [wiki:Identifier] with the given name or the given network ID respectively. * '''Iterators''': * getFactoryBegin() returns an iterator to the first [wiki:Identifier] in the map. * getFactoryEnd() returns an iterator to the last [wiki:Identifier] in the map. == Examples == {{{ #!cpp Identifier* myidentifier = ID("BaseObject"); // Assigns the BaseObject-Identifier Identifier* myidentifier = Factory::getIdentifier("BaseObject"); // This does exactly the same }}} {{{ #!cpp // Returns a list of the names of all Factories in the map std::map::const_iterator it; for (it = Factory::getFactoryBegin(); it != Factory::getFactoryEnd(); ++it) std::cout << (*it)->getName() << std::endl; }}}