[Orxonox-commit 5801] r10461 - code/branches/core7/src/libraries/core/singleton

landauf at orxonox.net landauf at orxonox.net
Sun May 24 23:29:21 CEST 2015


Author: landauf
Date: 2015-05-24 23:29:21 +0200 (Sun, 24 May 2015)
New Revision: 10461

Added:
   code/branches/core7/src/libraries/core/singleton/ScopeManager.cc
   code/branches/core7/src/libraries/core/singleton/ScopeManager.h
Removed:
   code/branches/core7/src/libraries/core/singleton/Scope.cc
Modified:
   code/branches/core7/src/libraries/core/singleton/CMakeLists.txt
   code/branches/core7/src/libraries/core/singleton/Scope.h
Log:
moved ScopeManager into separate class

Modified: code/branches/core7/src/libraries/core/singleton/CMakeLists.txt
===================================================================
--- code/branches/core7/src/libraries/core/singleton/CMakeLists.txt	2015-05-24 21:19:15 UTC (rev 10460)
+++ code/branches/core7/src/libraries/core/singleton/CMakeLists.txt	2015-05-24 21:29:21 UTC (rev 10461)
@@ -1,4 +1,4 @@
 ADD_SOURCE_FILES(CORE_SRC_FILES
-  Scope.cc
+  ScopeManager.cc
   ScopedSingletonIncludes.cc
 )

Deleted: code/branches/core7/src/libraries/core/singleton/Scope.cc
===================================================================
--- code/branches/core7/src/libraries/core/singleton/Scope.cc	2015-05-24 21:19:15 UTC (rev 10460)
+++ code/branches/core7/src/libraries/core/singleton/Scope.cc	2015-05-24 21:29:21 UTC (rev 10461)
@@ -1,48 +0,0 @@
-/*
- *   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:
- *      ...
- *
- */
-
-/**
-    @file
-    @brief Static linkage of the two maps in orxonox::ScopeManager.
-*/
-
-#include "Scope.h"
-
-namespace orxonox
-{
-    /*static*/ std::map<ScopeID::Value, int>& ScopeManager::getInstanceCounts()
-    {
-        static std::map<ScopeID::Value, int> instanceCounts;
-        return instanceCounts;
-    }
-    /*static*/ std::map<ScopeID::Value, std::set<ScopeListener*> >& ScopeManager::getListeners()
-    {
-        static std::map<ScopeID::Value, std::set<ScopeListener*> > listeners;
-        return listeners;
-    }
-}

Modified: code/branches/core7/src/libraries/core/singleton/Scope.h
===================================================================
--- code/branches/core7/src/libraries/core/singleton/Scope.h	2015-05-24 21:19:15 UTC (rev 10460)
+++ code/branches/core7/src/libraries/core/singleton/Scope.h	2015-05-24 21:29:21 UTC (rev 10461)
@@ -29,16 +29,15 @@
 /**
 @file
 @ingroup SingletonScope
- at brief Declaration of the classes that are needed to use Scopes:
-orxonox::Scope, orxonox::ScopeListener, and orxonox::ScopeManager.
+ at brief Declaration of the classes that are needed to use Scopes: orxonox::Scope and orxonox::ScopeListener.
 
 @anchor Scope
 
 A virtual scope can be represented by an instance of class orxonox::Scope. orxonox::Scope<@a scope> is a template
 an its template argument defines the name of the virtual scope. See orxonox::ScopeID for an enumeration of the
 available values for @a scope. The orxonox::Scope object for a given @a scope can be activated or deactivated.
-Instances of orxonox::ScopeListener can register for a given @a scope and will get a notification if the
-corresponding orxonox::Scope object changes its state.
+Instances of orxonox::ScopeListener can register in orxonox::ScopeMAnager for a given @a scope and will get a
+notification if the corresponding orxonox::Scope object changes its state.
 
 To avoid multiple instances of orxonox::Scope<@a scope> in different libraries, each instance of orxonox::Scope
 registers in orxonox::ScopeManager, where they are linked statically in the core library.
@@ -59,30 +58,11 @@
 #include <loki/ScopeGuard.h>
 
 #include "util/Output.h"
+#include "ScopeManager.h"
 
 namespace orxonox
 {
     /**
-        @brief The ScopeManager stores the variables of the Scope templates in a statically linked context.
-
-        If all Scope objects are managed by this class, they are statically linked in the core library.
-        Without this, a new instance of Scope<T> for each T would be created in every library of Orxonox,
-        which is of course not the desired behavior.
-
-        @see See @ref Scope "this description" for details about the interrelationship of Scope, ScopeListener, and ScopeManager.
-    */
-    class _CoreExport ScopeManager
-    {
-        template <ScopeID::Value scope>
-        friend class Scope;
-        friend class StaticallyInitializedScopedSingletonWrapper;
-
-        private:
-            static std::map<ScopeID::Value, int>& getInstanceCounts();                  //!< Counts the number of active instances (>0 means active) for a scope
-            static std::map<ScopeID::Value, std::set<ScopeListener*> >& getListeners(); //!< Stores all listeners for a scope
-    };
-
-    /**
         @brief ScopeListeners register themselves in the corresponding Scope and wait for notifications.
         Notifications are sent if a Scope is activated or deactivated.
 

Copied: code/branches/core7/src/libraries/core/singleton/ScopeManager.cc (from rev 10457, code/branches/core7/src/libraries/core/singleton/Scope.cc)
===================================================================
--- code/branches/core7/src/libraries/core/singleton/ScopeManager.cc	                        (rev 0)
+++ code/branches/core7/src/libraries/core/singleton/ScopeManager.cc	2015-05-24 21:29:21 UTC (rev 10461)
@@ -0,0 +1,48 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Static linkage of the two maps in orxonox::ScopeManager.
+*/
+
+#include "Scope.h"
+
+namespace orxonox
+{
+    /*static*/ std::map<ScopeID::Value, int>& ScopeManager::getInstanceCounts()
+    {
+        static std::map<ScopeID::Value, int> instanceCounts;
+        return instanceCounts;
+    }
+    /*static*/ std::map<ScopeID::Value, std::set<ScopeListener*> >& ScopeManager::getListeners()
+    {
+        static std::map<ScopeID::Value, std::set<ScopeListener*> > listeners;
+        return listeners;
+    }
+}

Copied: code/branches/core7/src/libraries/core/singleton/ScopeManager.h (from rev 10460, code/branches/core7/src/libraries/core/singleton/Scope.h)
===================================================================
--- code/branches/core7/src/libraries/core/singleton/ScopeManager.h	                        (rev 0)
+++ code/branches/core7/src/libraries/core/singleton/ScopeManager.h	2015-05-24 21:29:21 UTC (rev 10461)
@@ -0,0 +1,66 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+/**
+ at file
+ at ingroup SingletonScope
+ at brief Declaration of orxonox::ScopeManager.
+*/
+
+#ifndef __ScopeManager_H__
+#define __ScopeManager_H__
+
+#include "core/CorePrereqs.h"
+
+#include <map>
+#include <set>
+
+namespace orxonox
+{
+    /**
+        @brief The ScopeManager stores the variables of the Scope templates in a statically linked context.
+
+        If all Scope objects are managed by this class, they are statically linked in the core library.
+        Without this, a new instance of Scope<T> for each T would be created in every library of Orxonox,
+        which is of course not the desired behavior.
+
+        @see See @ref Scope "this description" for details about the interrelationship of Scope, ScopeListener, and ScopeManager.
+    */
+    class _CoreExport ScopeManager
+    {
+        template <ScopeID::Value scope>
+        friend class Scope;
+        friend class StaticallyInitializedScopedSingletonWrapper;
+
+        private:
+            static std::map<ScopeID::Value, int>& getInstanceCounts();                  //!< Counts the number of active instances (>0 means active) for a scope
+            static std::map<ScopeID::Value, std::set<ScopeListener*> >& getListeners(); //!< Stores all listeners for a scope
+    };
+}
+
+#endif /* __ScopeManager_H__ */




More information about the Orxonox-commit mailing list