[Orxonox-commit 5821] r10481 - in code/branches/core7: src/libraries/core src/libraries/core/class src/libraries/core/singleton test/core/object
landauf at orxonox.net
landauf at orxonox.net
Mon May 25 21:40:11 CEST 2015
Author: landauf
Date: 2015-05-25 21:40:11 +0200 (Mon, 25 May 2015)
New Revision: 10481
Modified:
code/branches/core7/src/libraries/core/CoreIncludes.h
code/branches/core7/src/libraries/core/class/IdentifierManager.cc
code/branches/core7/src/libraries/core/class/IdentifierManager.h
code/branches/core7/src/libraries/core/singleton/ScopedSingletonIncludes.h
code/branches/core7/test/core/object/ClassFactoryTest.cc
code/branches/core7/test/core/object/ContextTest.cc
code/branches/core7/test/core/object/IteratorTest.cc
code/branches/core7/test/core/object/ListableTest.cc
code/branches/core7/test/core/object/ObjectListIteratorTest.cc
Log:
StaticallyInitializedIdentifier is now responsible to register and unregister the assigned identifier.
Modified: code/branches/core7/src/libraries/core/CoreIncludes.h
===================================================================
--- code/branches/core7/src/libraries/core/CoreIncludes.h 2015-05-25 19:01:33 UTC (rev 10480)
+++ code/branches/core7/src/libraries/core/CoreIncludes.h 2015-05-25 19:40:11 UTC (rev 10481)
@@ -166,9 +166,7 @@
template <class T>
inline Identifier* registerClass(const std::string& name, Factory* factory, bool bLoadable = true)
{
- Identifier* identifier = new ClassIdentifier<T>(name, factory, bLoadable);
- IdentifierManager::getInstance().addIdentifier(identifier);
- return identifier;
+ return new ClassIdentifier<T>(name, factory, bLoadable);
}
/**
@@ -241,12 +239,14 @@
virtual void load()
{
+ IdentifierManager::getInstance().addIdentifier(this->identifier_);
for (size_t i = 0; i < this->parents_.size(); ++i)
this->identifier_->inheritsFrom(this->parents_[i]->getParent());
}
virtual void unload()
{
+ IdentifierManager::getInstance().removeIdentifier(this->identifier_);
}
inline Identifier& getIdentifier()
Modified: code/branches/core7/src/libraries/core/class/IdentifierManager.cc
===================================================================
--- code/branches/core7/src/libraries/core/class/IdentifierManager.cc 2015-05-25 19:01:33 UTC (rev 10480)
+++ code/branches/core7/src/libraries/core/class/IdentifierManager.cc 2015-05-25 19:40:11 UTC (rev 10481)
@@ -70,6 +70,17 @@
}
/**
+ * Unregisters the identifier from all maps of the IdentifierManager.
+ */
+ void IdentifierManager::removeIdentifier(Identifier* identifier)
+ {
+ this->identifiers_.erase(identifier);
+ this->identifierByString_.erase(identifier->getName());
+ this->identifierByLowercaseString_.erase(getLowercase(identifier->getName()));
+ this->identifierByNetworkId_.erase(identifier->getNetworkID());
+ }
+
+ /**
@brief Creates the class-hierarchy by creating and destroying one object of each type.
*/
void IdentifierManager::createClassHierarchy()
Modified: code/branches/core7/src/libraries/core/class/IdentifierManager.h
===================================================================
--- code/branches/core7/src/libraries/core/class/IdentifierManager.h 2015-05-25 19:01:33 UTC (rev 10480)
+++ code/branches/core7/src/libraries/core/class/IdentifierManager.h 2015-05-25 19:40:11 UTC (rev 10481)
@@ -49,6 +49,7 @@
static IdentifierManager& getInstance();
void addIdentifier(Identifier* identifier);
+ void removeIdentifier(Identifier* identifier);
unsigned int getUniqueClassId()
{ return this->classIDCounter_s++; }
Modified: code/branches/core7/src/libraries/core/singleton/ScopedSingletonIncludes.h
===================================================================
--- code/branches/core7/src/libraries/core/singleton/ScopedSingletonIncludes.h 2015-05-25 19:01:33 UTC (rev 10480)
+++ code/branches/core7/src/libraries/core/singleton/ScopedSingletonIncludes.h 2015-05-25 19:40:11 UTC (rev 10481)
@@ -76,7 +76,6 @@
namespace orxonox
{
-
class _CoreExport StaticallyInitializedScopedSingletonWrapper : public StaticallyInitializedInstance
{
public:
Modified: code/branches/core7/test/core/object/ClassFactoryTest.cc
===================================================================
--- code/branches/core7/test/core/object/ClassFactoryTest.cc 2015-05-25 19:01:33 UTC (rev 10480)
+++ code/branches/core7/test/core/object/ClassFactoryTest.cc 2015-05-25 19:40:11 UTC (rev 10481)
@@ -2,6 +2,7 @@
#include "core/object/ClassFactory.h"
#include "core/BaseObject.h"
#include "core/object/Context.h"
+#include "core/module/ModuleInstance.h"
namespace orxonox
{
@@ -14,10 +15,12 @@
virtual void SetUp()
{
Context::setRootContext(new Context(NULL));
+ ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
}
virtual void TearDown()
{
+ ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
Context::setRootContext(NULL);
}
};
Modified: code/branches/core7/test/core/object/ContextTest.cc
===================================================================
--- code/branches/core7/test/core/object/ContextTest.cc 2015-05-25 19:01:33 UTC (rev 10480)
+++ code/branches/core7/test/core/object/ContextTest.cc 2015-05-25 19:40:11 UTC (rev 10481)
@@ -2,6 +2,7 @@
#include "core/object/Context.h"
#include "core/class/OrxonoxClass.h"
#include "core/CoreIncludes.h"
+#include "core/module/ModuleInstance.h"
namespace orxonox
{
@@ -22,10 +23,12 @@
virtual void SetUp()
{
Context::setRootContext(new Context(NULL));
+ ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
}
virtual void TearDown()
{
+ ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
Context::setRootContext(NULL);
}
};
Modified: code/branches/core7/test/core/object/IteratorTest.cc
===================================================================
--- code/branches/core7/test/core/object/IteratorTest.cc 2015-05-25 19:01:33 UTC (rev 10480)
+++ code/branches/core7/test/core/object/IteratorTest.cc 2015-05-25 19:40:11 UTC (rev 10481)
@@ -5,6 +5,7 @@
#include "core/class/OrxonoxClass.h"
#include "core/class/OrxonoxInterface.h"
#include "core/CoreIncludes.h"
+#include "core/module/ModuleInstance.h"
namespace orxonox
{
@@ -33,10 +34,12 @@
virtual void SetUp()
{
Context::setRootContext(new Context(NULL));
+ ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
}
virtual void TearDown()
{
+ ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
Context::setRootContext(NULL);
}
};
Modified: code/branches/core7/test/core/object/ListableTest.cc
===================================================================
--- code/branches/core7/test/core/object/ListableTest.cc 2015-05-25 19:01:33 UTC (rev 10480)
+++ code/branches/core7/test/core/object/ListableTest.cc 2015-05-25 19:40:11 UTC (rev 10481)
@@ -1,6 +1,7 @@
#include <gtest/gtest.h>
#include "core/object/Listable.h"
#include "core/CoreIncludes.h"
+#include "core/module/ModuleInstance.h"
namespace orxonox
{
@@ -38,10 +39,12 @@
virtual void SetUp()
{
Context::setRootContext(new Context(NULL));
+ ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
}
virtual void TearDown()
{
+ ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
Context::setRootContext(NULL);
}
};
Modified: code/branches/core7/test/core/object/ObjectListIteratorTest.cc
===================================================================
--- code/branches/core7/test/core/object/ObjectListIteratorTest.cc 2015-05-25 19:01:33 UTC (rev 10480)
+++ code/branches/core7/test/core/object/ObjectListIteratorTest.cc 2015-05-25 19:40:11 UTC (rev 10481)
@@ -4,6 +4,7 @@
#include "core/object/ObjectListIterator.h"
#include "core/object/Listable.h"
#include "core/CoreIncludes.h"
+#include "core/module/ModuleInstance.h"
namespace orxonox
{
@@ -25,10 +26,12 @@
virtual void SetUp()
{
Context::setRootContext(new Context(NULL));
+ ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
}
virtual void TearDown()
{
+ ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
Context::setRootContext(NULL);
}
};
More information about the Orxonox-commit
mailing list