[Orxonox-commit 4963] r9632 - in code/branches/core6: src/libraries/core/class src/libraries/core/object test/core/object
landauf at orxonox.net
landauf at orxonox.net
Sun Aug 11 11:00:43 CEST 2013
Author: landauf
Date: 2013-08-11 11:00:43 +0200 (Sun, 11 Aug 2013)
New Revision: 9632
Modified:
code/branches/core6/src/libraries/core/class/Identifier.cc
code/branches/core6/src/libraries/core/class/Identifier.h
code/branches/core6/src/libraries/core/class/IdentifierManager.cc
code/branches/core6/src/libraries/core/class/SubclassIdentifier.h
code/branches/core6/src/libraries/core/object/ClassFactory.h
code/branches/core6/test/core/object/ClassFactoryTest.cc
Log:
Factory::fabricate() returns an Identifiable
Modified: code/branches/core6/src/libraries/core/class/Identifier.cc
===================================================================
--- code/branches/core6/src/libraries/core/class/Identifier.cc 2013-08-10 10:15:13 UTC (rev 9631)
+++ code/branches/core6/src/libraries/core/class/Identifier.cc 2013-08-11 09:00:43 UTC (rev 9632)
@@ -173,7 +173,7 @@
@brief Creates an object of the type the Identifier belongs to.
@return The new object
*/
- OrxonoxClass* Identifier::fabricate(Context* context)
+ Identifiable* Identifier::fabricate(Context* context)
{
if (this->factory_)
{
Modified: code/branches/core6/src/libraries/core/class/Identifier.h
===================================================================
--- code/branches/core6/src/libraries/core/class/Identifier.h 2013-08-10 10:15:13 UTC (rev 9631)
+++ code/branches/core6/src/libraries/core/class/Identifier.h 2013-08-11 09:00:43 UTC (rev 9632)
@@ -55,7 +55,7 @@
object->getIdentifier()->getName(); // returns "MyClass"
- OrxonoxClass* other = object->getIdentifier()->fabricate(0); // fabricates a new instance of MyClass
+ Identifiable* other = object->getIdentifier()->fabricate(0); // fabricates a new instance of MyClass
// test the class hierarchy
@@ -124,7 +124,7 @@
/// Returns true if the Identifier has a Factory.
inline bool hasFactory() const { return (this->factory_ != 0); }
- OrxonoxClass* fabricate(Context* context);
+ Identifiable* fabricate(Context* context);
/// Returns true if the class can be loaded through XML.
inline bool isLoadable() const { return this->bLoadable_; }
Modified: code/branches/core6/src/libraries/core/class/IdentifierManager.cc
===================================================================
--- code/branches/core6/src/libraries/core/class/IdentifierManager.cc 2013-08-10 10:15:13 UTC (rev 9631)
+++ code/branches/core6/src/libraries/core/class/IdentifierManager.cc 2013-08-11 09:00:43 UTC (rev 9632)
@@ -90,8 +90,8 @@
// To create the new branch of the class-hierarchy, we create a new object and delete it afterwards.
if (it->second->hasFactory())
{
- OrxonoxClass* temp = it->second->fabricate(0);
- temp->destroy();
+ Identifiable* temp = it->second->fabricate(0);
+ delete temp;
}
}
IdentifierManager::stopCreatingHierarchy();
Modified: code/branches/core6/src/libraries/core/class/SubclassIdentifier.h
===================================================================
--- code/branches/core6/src/libraries/core/class/SubclassIdentifier.h 2013-08-10 10:15:13 UTC (rev 9631)
+++ code/branches/core6/src/libraries/core/class/SubclassIdentifier.h 2013-08-11 09:00:43 UTC (rev 9632)
@@ -164,7 +164,7 @@
/// Creates a new object of the type of the assigned Identifier and dynamic_casts it to the minimal type given by T.
T* fabricate(Context* context) const
{
- OrxonoxClass* newObject = this->identifier_->fabricate(context);
+ Identifiable* newObject = this->identifier_->fabricate(context);
// Check if the creation was successful
if (newObject)
Modified: code/branches/core6/src/libraries/core/object/ClassFactory.h
===================================================================
--- code/branches/core6/src/libraries/core/object/ClassFactory.h 2013-08-10 10:15:13 UTC (rev 9631)
+++ code/branches/core6/src/libraries/core/object/ClassFactory.h 2013-08-11 09:00:43 UTC (rev 9632)
@@ -54,7 +54,7 @@
{
public:
virtual ~Factory() {};
- virtual OrxonoxClass* fabricate(Context* context) = 0;
+ virtual Identifiable* fabricate(Context* context) = 0;
};
// ###############################
@@ -81,7 +81,7 @@
@brief Creates and returns a new object of class T.
@return The new object
*/
- inline OrxonoxClass* fabricate(Context* context)
+ inline Identifiable* fabricate(Context* context)
{
return static_cast<OrxonoxClass*>(new T(context));
}
Modified: code/branches/core6/test/core/object/ClassFactoryTest.cc
===================================================================
--- code/branches/core6/test/core/object/ClassFactoryTest.cc 2013-08-10 10:15:13 UTC (rev 9631)
+++ code/branches/core6/test/core/object/ClassFactoryTest.cc 2013-08-11 09:00:43 UTC (rev 9632)
@@ -7,7 +7,7 @@
TEST(ClassFactoryTest, CanFabricateObject)
{
Factory* factory = new ClassFactory<BaseObject>("BaseObject");
- OrxonoxClass* object = factory->fabricate(NULL);
+ Identifiable* object = factory->fabricate(NULL);
ASSERT_TRUE(object != NULL);
BaseObject* baseObject = dynamic_cast<BaseObject*>(object);
EXPECT_TRUE(baseObject != NULL);
More information about the Orxonox-commit
mailing list