[Orxonox-commit 5682] r10342 - in code/branches/core7/src/libraries/core: . module
landauf at orxonox.net
landauf at orxonox.net
Sat Apr 4 13:24:49 CEST 2015
Author: landauf
Date: 2015-04-04 13:24:49 +0200 (Sat, 04 Apr 2015)
New Revision: 10342
Added:
code/branches/core7/src/libraries/core/module/
code/branches/core7/src/libraries/core/module/CMakeLists.txt
code/branches/core7/src/libraries/core/module/ModuleInstance.cc
code/branches/core7/src/libraries/core/module/ModuleInstance.h
code/branches/core7/src/libraries/core/module/StaticallyInitializedInstance.cc
code/branches/core7/src/libraries/core/module/StaticallyInitializedInstance.h
Modified:
code/branches/core7/src/libraries/core/CMakeLists.txt
code/branches/core7/src/libraries/core/Core.cc
code/branches/core7/src/libraries/core/CorePrereqs.h
Log:
added helper class for module initialization
Modified: code/branches/core7/src/libraries/core/CMakeLists.txt
===================================================================
--- code/branches/core7/src/libraries/core/CMakeLists.txt 2015-04-02 14:08:52 UTC (rev 10341)
+++ code/branches/core7/src/libraries/core/CMakeLists.txt 2015-04-04 11:24:49 UTC (rev 10342)
@@ -65,6 +65,7 @@
ADD_SUBDIRECTORY(command)
ADD_SUBDIRECTORY(config)
ADD_SUBDIRECTORY(input)
+ADD_SUBDIRECTORY(module)
ADD_SUBDIRECTORY(object)
#Add the icon (for the renderwindow)
Modified: code/branches/core7/src/libraries/core/Core.cc
===================================================================
--- code/branches/core7/src/libraries/core/Core.cc 2015-04-02 14:08:52 UTC (rev 10341)
+++ code/branches/core7/src/libraries/core/Core.cc 2015-04-04 11:24:49 UTC (rev 10342)
@@ -76,6 +76,7 @@
#include "command/TclThreadManager.h"
#include "input/InputManager.h"
#include "object/ObjectList.h"
+#include "module/ModuleInstance.h"
namespace orxonox
{
@@ -138,6 +139,8 @@
}
}
+ ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
+
// Parse command line arguments AFTER the modules have been loaded (static code!)
CommandLineParser::parse(cmdLine);
Modified: code/branches/core7/src/libraries/core/CorePrereqs.h
===================================================================
--- code/branches/core7/src/libraries/core/CorePrereqs.h 2015-04-02 14:08:52 UTC (rev 10341)
+++ code/branches/core7/src/libraries/core/CorePrereqs.h 2015-04-04 11:24:49 UTC (rev 10342)
@@ -168,6 +168,7 @@
class LuaState;
class MemoryArchive;
class MemoryArchiveFactory;
+ class ModuleInstance;
class Namespace;
class NamespaceNode;
template <class T>
@@ -186,6 +187,7 @@
class SettingsConfigFile;
template <class T>
class SmartPtr;
+ class StaticallyInitializedInstance;
template <class T>
class SubclassIdentifier;
class Template;
Added: code/branches/core7/src/libraries/core/module/CMakeLists.txt
===================================================================
--- code/branches/core7/src/libraries/core/module/CMakeLists.txt (rev 0)
+++ code/branches/core7/src/libraries/core/module/CMakeLists.txt 2015-04-04 11:24:49 UTC (rev 10342)
@@ -0,0 +1,4 @@
+ADD_SOURCE_FILES(CORE_SRC_FILES
+ ModuleInstance.cc
+ StaticallyInitializedInstance.cc
+)
Property changes on: code/branches/core7/src/libraries/core/module/CMakeLists.txt
___________________________________________________________________
Added: svn:eol-style
+ native
Added: code/branches/core7/src/libraries/core/module/ModuleInstance.cc
===================================================================
--- code/branches/core7/src/libraries/core/module/ModuleInstance.cc (rev 0)
+++ code/branches/core7/src/libraries/core/module/ModuleInstance.cc 2015-04-04 11:24:49 UTC (rev 10342)
@@ -0,0 +1,59 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "ModuleInstance.h"
+
+#include "StaticallyInitializedInstance.h"
+
+namespace orxonox
+{
+ ModuleInstance* ModuleInstance::currentModuleInstance_s = NULL;
+
+ void ModuleInstance::addStaticallyInitializedInstance(StaticallyInitializedInstance* instance)
+ {
+ this->staticallyInitializedInstances_.push_back(instance);
+ }
+
+ void ModuleInstance::loadAllStaticallyInitializedInstances()
+ {
+ for (size_t i = 0; i < this->staticallyInitializedInstances_.size(); ++i)
+ this->staticallyInitializedInstances_[i]->load();
+ }
+
+ /*static*/ void ModuleInstance::setCurrentModuleInstance(ModuleInstance* instance)
+ {
+ ModuleInstance::currentModuleInstance_s = instance;
+ }
+
+ /*static*/ ModuleInstance* ModuleInstance::getCurrentModuleInstance()
+ {
+ if (!ModuleInstance::currentModuleInstance_s)
+ ModuleInstance::currentModuleInstance_s = new ModuleInstance();
+ return ModuleInstance::currentModuleInstance_s;
+ }
+}
Property changes on: code/branches/core7/src/libraries/core/module/ModuleInstance.cc
___________________________________________________________________
Added: svn:eol-style
+ native
Added: code/branches/core7/src/libraries/core/module/ModuleInstance.h
===================================================================
--- code/branches/core7/src/libraries/core/module/ModuleInstance.h (rev 0)
+++ code/branches/core7/src/libraries/core/module/ModuleInstance.h 2015-04-04 11:24:49 UTC (rev 10342)
@@ -0,0 +1,54 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _ModuleInstance_H__
+#define _ModuleInstance_H__
+
+#include "core/CorePrereqs.h"
+
+#include <vector>
+
+namespace orxonox
+{
+ class _CoreExport ModuleInstance
+ {
+ public:
+ void addStaticallyInitializedInstance(StaticallyInitializedInstance* instance);
+ void loadAllStaticallyInitializedInstances();
+
+ static void setCurrentModuleInstance(ModuleInstance* instance);
+ static ModuleInstance* getCurrentModuleInstance();
+
+ private:
+ std::vector<StaticallyInitializedInstance*> staticallyInitializedInstances_;
+
+ static ModuleInstance* currentModuleInstance_s;
+ };
+}
+
+#endif /* _ModuleInstance_H__ */
Property changes on: code/branches/core7/src/libraries/core/module/ModuleInstance.h
___________________________________________________________________
Added: svn:eol-style
+ native
Added: code/branches/core7/src/libraries/core/module/StaticallyInitializedInstance.cc
===================================================================
--- code/branches/core7/src/libraries/core/module/StaticallyInitializedInstance.cc (rev 0)
+++ code/branches/core7/src/libraries/core/module/StaticallyInitializedInstance.cc 2015-04-04 11:24:49 UTC (rev 10342)
@@ -0,0 +1,39 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "StaticallyInitializedInstance.h"
+
+#include "ModuleInstance.h"
+
+namespace orxonox
+{
+ StaticallyInitializedInstance::StaticallyInitializedInstance()
+ {
+ ModuleInstance::getCurrentModuleInstance()->addStaticallyInitializedInstance(this);
+ }
+}
Property changes on: code/branches/core7/src/libraries/core/module/StaticallyInitializedInstance.cc
___________________________________________________________________
Added: svn:eol-style
+ native
Added: code/branches/core7/src/libraries/core/module/StaticallyInitializedInstance.h
===================================================================
--- code/branches/core7/src/libraries/core/module/StaticallyInitializedInstance.h (rev 0)
+++ code/branches/core7/src/libraries/core/module/StaticallyInitializedInstance.h 2015-04-04 11:24:49 UTC (rev 10342)
@@ -0,0 +1,46 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _StaticallyInitializedInstance_H__
+#define _StaticallyInitializedInstance_H__
+
+#include "core/CorePrereqs.h"
+
+namespace orxonox
+{
+ class _CoreExport StaticallyInitializedInstance
+ {
+ public:
+ StaticallyInitializedInstance();
+ virtual ~StaticallyInitializedInstance() {}
+
+ virtual void load() = 0;
+ };
+}
+
+#endif /* _StaticallyInitializedInstance_H__ */
Property changes on: code/branches/core7/src/libraries/core/module/StaticallyInitializedInstance.h
___________________________________________________________________
Added: svn:eol-style
+ native
More information about the Orxonox-commit
mailing list