[Orxonox-commit 1059] r5779 - code/branches/core5/src/libraries/core

landauf at orxonox.net landauf at orxonox.net
Thu Sep 24 02:55:34 CEST 2009


Author: landauf
Date: 2009-09-24 02:55:34 +0200 (Thu, 24 Sep 2009)
New Revision: 5779

Modified:
   code/branches/core5/src/libraries/core/ClassFactory.h
   code/branches/core5/src/libraries/core/CoreIncludes.h
   code/branches/core5/src/libraries/core/CorePrereqs.h
   code/branches/core5/src/libraries/core/Identifier.cc
   code/branches/core5/src/libraries/core/Identifier.h
Log:
Renamed BaseFactory as Factory
Added function ClassByLowercaseString

Modified: code/branches/core5/src/libraries/core/ClassFactory.h
===================================================================
--- code/branches/core5/src/libraries/core/ClassFactory.h	2009-09-24 00:47:53 UTC (rev 5778)
+++ code/branches/core5/src/libraries/core/ClassFactory.h	2009-09-24 00:55:34 UTC (rev 5779)
@@ -45,14 +45,14 @@
 
 namespace orxonox
 {
-    // ###############################
-    // ###       BaseFactory       ###
-    // ###############################
+    // ###########################
+    // ###       Factory       ###
+    // ###########################
     //! Base-class of ClassFactory.
-    class _CoreExport BaseFactory
+    class _CoreExport Factory
     {
         public:
-            virtual ~BaseFactory() {};
+            virtual ~Factory() {};
             virtual BaseObject* fabricate(BaseObject* creator) = 0;
     };
 
@@ -61,7 +61,7 @@
     // ###############################
     //! The ClassFactory is able to create new objects of a specific class.
     template <class T>
-    class ClassFactory : public BaseFactory
+    class ClassFactory : public Factory
     {
         public:
             ClassFactory(const std::string& name, bool bLoadable = true);

Modified: code/branches/core5/src/libraries/core/CoreIncludes.h
===================================================================
--- code/branches/core5/src/libraries/core/CoreIncludes.h	2009-09-24 00:47:53 UTC (rev 5778)
+++ code/branches/core5/src/libraries/core/CoreIncludes.h	2009-09-24 00:55:34 UTC (rev 5779)
@@ -79,14 +79,14 @@
     @param ClassName The name of the class
 */
 #define CreateFactory(ClassName) \
-    BaseFactory* ClassName##Factory = new orxonox::ClassFactory<ClassName>(#ClassName, true)
+    Factory* _##ClassName##Factory = new orxonox::ClassFactory<ClassName>(#ClassName, true)
 
 /**
     @brief Creates the Factory for classes which should not be loaded through XML.
     @param ClassName The name of the class
 */
 #define CreateUnloadableFactory(ClassName) \
-    BaseFactory* ClassName##Factory = new orxonox::ClassFactory<ClassName>(#ClassName, false)
+    Factory* _##ClassName##Factory = new orxonox::ClassFactory<ClassName>(#ClassName, false)
 
 /**
     @brief Returns the Identifier of the given class.
@@ -99,7 +99,7 @@
 namespace orxonox
 {
     /**
-        @brief Returns the Identifier with a given name through the factory.
+        @brief Returns the Identifier with a given name.
         @param String The name of the class
     */
     inline Identifier* ClassByString(const std::string& name)
@@ -108,7 +108,16 @@
     }
 
     /**
-        @brief Returns the Identifier with a given network ID through the factory.
+        @brief Returns the Identifier with a given lowercase name.
+        @param String The lowercase name of the class
+    */
+    inline Identifier* ClassByLowercaseString(const std::string& name)
+    {
+        return Identifier::getIdentifierByLowercaseString(name);
+    }
+
+    /**
+        @brief Returns the Identifier with a given network ID.
         @param networkID The network ID of the class
     */
     inline Identifier* ClassByID(uint32_t id)

Modified: code/branches/core5/src/libraries/core/CorePrereqs.h
===================================================================
--- code/branches/core5/src/libraries/core/CorePrereqs.h	2009-09-24 00:47:53 UTC (rev 5778)
+++ code/branches/core5/src/libraries/core/CorePrereqs.h	2009-09-24 00:55:34 UTC (rev 5779)
@@ -86,7 +86,6 @@
 
     class ArgumentCompleter;
     class ArgumentCompletionListElement;
-    class BaseFactory;
     class BaseMetaObjectListElement;
     class BaseObject;
     template <class T>

Modified: code/branches/core5/src/libraries/core/Identifier.cc
===================================================================
--- code/branches/core5/src/libraries/core/Identifier.cc	2009-09-24 00:47:53 UTC (rev 5778)
+++ code/branches/core5/src/libraries/core/Identifier.cc	2009-09-24 00:55:34 UTC (rev 5779)
@@ -371,6 +371,20 @@
     }
 
     /**
+        @brief Returns the Identifier with a given name in lowercase.
+        @param name The name of the wanted Identifier
+        @return The Identifier
+    */
+    Identifier* Identifier::getIdentifierByLowercaseString(const std::string& name)
+    {
+        std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseStringIdentifierMapIntern().find(name);
+        if (it != Identifier::getLowercaseStringIdentifierMapIntern().end())
+            return it->second;
+        else
+            return 0;
+    }
+
+    /**
         @brief Returns the Identifier with a given network ID.
         @param id The network ID of the wanted Identifier
         @return The Identifier

Modified: code/branches/core5/src/libraries/core/Identifier.h
===================================================================
--- code/branches/core5/src/libraries/core/Identifier.h	2009-09-24 00:47:53 UTC (rev 5778)
+++ code/branches/core5/src/libraries/core/Identifier.h	2009-09-24 00:55:34 UTC (rev 5779)
@@ -102,7 +102,7 @@
             inline ObjectListBase* getObjects() const { return this->objects_; }
 
             /** @brief Sets the Factory. @param factory The factory to assign */
-            inline void addFactory(BaseFactory* factory) { this->factory_ = factory; }
+            inline void addFactory(Factory* factory) { this->factory_ = factory; }
             /** @brief Returns true if the Identifier has a Factory. */
             inline bool hasFactory() const { return (this->factory_ != 0); }
 
@@ -164,6 +164,7 @@
             static void destroyAllIdentifiers();
 
             static Identifier* getIdentifierByString(const std::string& name);
+            static Identifier* getIdentifierByLowercaseString(const std::string& name);
             static Identifier* getIdentifierByID(uint32_t id);
 
             static void clearNetworkIDs();
@@ -333,7 +334,7 @@
             bool bSetName_;                                                //!< True if the name is set
             bool bLoadable_;                                               //!< False = it's not permitted to load the object through XML
             std::string name_;                                             //!< The name of the class the Identifier belongs to
-            BaseFactory* factory_;                                         //!< The Factory, able to create new objects of the given class (if available)
+            Factory* factory_;                                             //!< The Factory, able to create new objects of the given class (if available)
             static int hierarchyCreatingCounter_s;                         //!< Bigger than zero if at least one Identifier stores its parents (its an int instead of a bool to avoid conflicts with multithreading)
             uint32_t networkID_;                                           //!< The network ID to identify a class through the network
             const unsigned int classID_;                                   //!< Uniquely identifies a class (might not be the same as the networkID_)




More information about the Orxonox-commit mailing list