Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 5 and Version 6 of code/doc/Factory


Ignore:
Timestamp:
Sep 29, 2008, 3:23:04 AM (16 years ago)
Author:
landauf
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/doc/Factory

    v5 v6  
    44== Description ==
    55
    6 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.
     6The Factory is a [wiki:singleton] that maps [wiki:Identifier Identifiers] with their name and their network ID. The Factory is used by the !CreateFactory(classname) macro to add new entries. The ClassByName("classname") and ClassByID(network ID) macros use the Factory to retrieve an [wiki:Identifier] with a given classname or a given network ID respectively. See [wiki:CoreIncludes] for more information.
    77
    8 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.
     8The ClassByName and ClassByID macros are an abbreviation of the static function Factory::getIdentifier("name" or ID). The Factory also handles the change of a network ID to avoid conflicts with ambiguous map-entries.
    99
    1010== Functions ==
    1111
    12  * '''Identifiers''':
    13    * 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).
    14    * getIdentifier(name) and getIdentifier(network ID) return the [wiki:Identifier] with the given name or the given network ID respectively.
    15  * '''Iterators''':
    16    * getFactoryBegin() returns an iterator to the first [wiki:Identifier] in the map.
    17    * getFactoryEnd() returns an iterator to the last [wiki:Identifier] in the map.
     12=== Identifiers ===
     13 * '''getIdentifier('''''name''''')''' and '''getIdentifier('''''network ID''''')''' return the [wiki:Identifier] with the given name or the given network ID respectively.
    1814
    19 == Examples ==
     15=== Iterators ===
     16Because the Factory knows all Identifiers with a [wiki:ClassFactory], it provides functions to get the map-iterators to iterate through all stored Identifiers:
     17 * '''getFactoryMap()''': returns an iterator to the map.
     18 * '''getFactoryMapBegin()''': returns an iterator to the first [wiki:Identifier] in the map.
     19 * '''getFactoryMapEnd()''': returns an iterator to the last [wiki:Identifier] in the map.
    2020
    21 {{{
    22 #!cpp
    23 Identifier* myidentifier = ID("BaseObject");                     // Assigns the BaseObject-Identifier
    24 Identifier* myidentifier = Factory::getIdentifier("BaseObject"); // This does exactly the same
    25 }}}
    26 
    27 {{{
    28 #!cpp
    29 // Returns a list of the names of all Factories in the map
    30 
    31 std::map<std::string, Identifier*>::const_iterator it;
    32 for (it = Factory::getFactoryBegin(); it != Factory::getFactoryEnd(); ++it)
    33   std::cout << (*it)->getName() << std::endl;
    34 }}}
     21=== Class Hierarchy ===
     22 * '''createClassHierarchy()''': Creates the class hierarchy by creating an instance of all classes in the Identifier map (and destroying them afterwards).