Changeset 9675 in orxonox.OLD for trunk/src/lib/util/loading
- Timestamp:
- Aug 21, 2006, 10:57:35 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/util/loading/factory.cc
r9406 r9675 29 29 */ 30 30 Factory::Factory (const std::string& factoryName, ClassID classID) 31 : classID(classID), className(factoryName)31 : classID(classID), className(factoryName) 32 32 { 33 33 this->setClassID(CL_FACTORY, "Factory"); … … 86 86 bool Factory::operator==(const char* className) const 87 87 { 88 return (className != NULL && this->className == className);88 return (className != NULL && this->className == className); 89 89 } 90 90 … … 96 96 bool Factory::operator==(const std::string& className) const 97 97 { 98 return (this->className == className);98 return (this->className == className); 99 99 } 100 100 … … 105 105 * @returns a new Object of Type root->Value() on match, NULL otherwise 106 106 */ 107 107 BaseObject* Factory::fabricate(const TiXmlElement* root) 108 108 { 109 if (root == NULL || Factory::factoryList == NULL) 110 return NULL; 109 assert (root != NULL && Factory::factoryList != NULL); 111 110 112 111 std::list<Factory*>::const_iterator factory; 113 112 for (factory = Factory::factoryList->begin(); factory != Factory::factoryList->end(); factory++) 114 113 if (*(*factory) == root->Value()) 115 break; 114 { 115 PRINTF(2)("Create a new Object of type %s\n", (*factory)->getCName()); 116 return (*factory)->fabricateObject(root); 117 } 116 118 117 if (factory != Factory::factoryList->end()) 118 { 119 PRINTF(2)("Create a new Object of type %s\n", (*factory)->getCName()); 120 return (*factory)->fabricateObject(root); 121 } 122 else 123 { 124 PRINTF(2)("Could not Fabricate an Object of Class '%s'\n", root->Value()); 125 return NULL; 126 } 119 PRINTF(2)("Could not Fabricate an Object of Class '%s'\n", root->Value()); 120 return NULL; 127 121 } 128 122 129 123 130 124 /** 131 * Creates a new Object of type className125 * @brief Creates a new Object of type className 132 126 * @param className the ClassName to match for the newly created Object 133 127 * @returns a new Object of Type className on match, NULL otherwise 134 128 */ 135 129 BaseObject* Factory::fabricate(const std::string& className) 136 130 { 137 131 if (Factory::factoryList == NULL) … … 141 135 for (factory = Factory::factoryList->begin(); factory != Factory::factoryList->end(); factory++) 142 136 if (*(*factory) == className) 143 break; 144 145 if (factory != Factory::factoryList->end()) 146 { 147 PRINTF(4)("Create a new Object of type %s\n", (*factory)->getCName()); 148 return (*factory)->fabricateObject(NULL); 149 } 150 else 151 { 152 PRINTF(2)("Could not Fabricate an Object of Class '%s'\n", className.c_str()); 153 return NULL; 154 } 137 { 138 PRINTF(4)("Create a new Object of type %s\n", (*factory)->getCName()); 139 return (*factory)->fabricateObject(NULL); 140 } 141 PRINTF(2)("Could not Fabricate an Object of Class '%s'\n", className.c_str()); 142 return NULL; 155 143 } 156 144 157 145 158 146 /** 159 * Creates a new Object of type classID147 * @brief Creates a new Object of type classID 160 148 * @param classID the ClassID to match for the newly created Object 161 149 * @returns a new Object of Type classID on match, NULL otherwise … … 169 157 for (factory = Factory::factoryList->begin(); factory != Factory::factoryList->end(); factory++) 170 158 if (*(*factory) == classID) 171 break; 159 { 160 PRINTF(4)("Create a new Object of type %s\n", (*factory)->getCName()); 161 return (*factory)->fabricateObject(NULL); 172 162 173 if (factory != Factory::factoryList->end()) 174 { 175 PRINTF(4)("Create a new Object of type %s\n", (*factory)->getCName()); 176 return (*factory)->fabricateObject(NULL); 177 } 178 else 179 { 180 PRINTF(2)("Could not Fabricate an Object of ClassID '0x%h'\n", classID); 181 return NULL; 182 } 163 } 164 PRINTF(2)("Could not Fabricate an Object of ClassID '0x%h'\n", classID); 165 return NULL; 183 166 }
Note: See TracChangeset
for help on using the changeset viewer.