[Orxonox-commit 6337] r10994 - in code/branches/cpp11_v2/src: libraries/core libraries/core/command libraries/core/input libraries/network libraries/network/packet libraries/util/output orxonox/controllers

landauf at orxonox.net landauf at orxonox.net
Tue Dec 29 17:36:14 CET 2015


Author: landauf
Date: 2015-12-29 17:36:14 +0100 (Tue, 29 Dec 2015)
New Revision: 10994

Modified:
   code/branches/cpp11_v2/src/libraries/core/CorePrereqs.h
   code/branches/cpp11_v2/src/libraries/core/command/CommandExecutor.h
   code/branches/cpp11_v2/src/libraries/core/command/IRC.cc
   code/branches/cpp11_v2/src/libraries/core/input/InputPrereqs.h
   code/branches/cpp11_v2/src/libraries/network/NetworkFunction.h
   code/branches/cpp11_v2/src/libraries/network/NetworkPrereqs.h
   code/branches/cpp11_v2/src/libraries/network/TrafficControl.cc
   code/branches/cpp11_v2/src/libraries/network/packet/Gamestate.h
   code/branches/cpp11_v2/src/libraries/util/output/LogWriter.cc
   code/branches/cpp11_v2/src/libraries/util/output/OutputDefinitions.h
   code/branches/cpp11_v2/src/orxonox/controllers/FormationController.cc
Log:
using some constexpr

Modified: code/branches/cpp11_v2/src/libraries/core/CorePrereqs.h
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/CorePrereqs.h	2015-12-29 16:18:23 UTC (rev 10993)
+++ code/branches/cpp11_v2/src/libraries/core/CorePrereqs.h	2015-12-29 16:36:14 UTC (rev 10994)
@@ -67,7 +67,7 @@
 
 namespace orxonox
 {
-    static const uint32_t OBJECTID_UNKNOWN = static_cast<uint32_t>(-1);
+    static constexpr uint32_t OBJECTID_UNKNOWN = static_cast<uint32_t>(-1);
 }
 
 //-----------------------------------------------------------------------
@@ -81,19 +81,19 @@
         typedef int Value;
 
         //!A list of available scopes for the Scope template.
-        static const Value ROOT = 1;
-        static const Value GRAPHICS = 2;
+        static constexpr Value ROOT = 1;
+        static constexpr Value GRAPHICS = 2;
     }
 
     namespace StaticInitialization
     {
         typedef int Type;
 
-        static const Type STATIC_INITIALIZATION_HANDLER = 1;
-        static const Type IDENTIFIER = 2;
-        static const Type SCOPED_SINGLETON_WRAPPER = 3;
-        static const Type COMMAND_LINE_ARGUMENT = 4;
-        static const Type CONSOLE_COMMAND = 5;
+        static constexpr Type STATIC_INITIALIZATION_HANDLER = 1;
+        static constexpr Type IDENTIFIER = 2;
+        static constexpr Type SCOPED_SINGLETON_WRAPPER = 3;
+        static constexpr Type COMMAND_LINE_ARGUMENT = 4;
+        static constexpr Type CONSOLE_COMMAND = 5;
     }
 
     namespace XMLPort

Modified: code/branches/cpp11_v2/src/libraries/core/command/CommandExecutor.h
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/command/CommandExecutor.h	2015-12-29 16:18:23 UTC (rev 10993)
+++ code/branches/cpp11_v2/src/libraries/core/command/CommandExecutor.h	2015-12-29 16:36:14 UTC (rev 10994)
@@ -117,12 +117,12 @@
 
             static CommandEvaluation evaluate(const std::string& command);
 
-            static const int Success = 0;       ///< Error code for "success" (or no error)
-            static const int Inexistent = 1;    ///< Error code if the command doesn't exist
-            static const int Incomplete = 2;    ///< Error code if the command needs more arguments
-            static const int Deactivated = 3;   ///< Error code if the command is not active
-            static const int Denied = 4;        ///< Error code if the command needs a different access level
-            static const int Error = 5;         ///< Error code if the command returned an error
+            static constexpr int Success = 0;       ///< Error code for "success" (or no error)
+            static constexpr int Inexistent = 1;    ///< Error code if the command doesn't exist
+            static constexpr int Incomplete = 2;    ///< Error code if the command needs more arguments
+            static constexpr int Deactivated = 3;   ///< Error code if the command is not active
+            static constexpr int Denied = 4;        ///< Error code if the command needs a different access level
+            static constexpr int Error = 5;         ///< Error code if the command returned an error
 
             static std::string getErrorDescription(int error);
 

Modified: code/branches/cpp11_v2/src/libraries/core/command/IRC.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/command/IRC.cc	2015-12-29 16:18:23 UTC (rev 10993)
+++ code/branches/cpp11_v2/src/libraries/core/command/IRC.cc	2015-12-29 16:36:14 UTC (rev 10994)
@@ -43,7 +43,7 @@
 
 namespace orxonox
 {
-    static const unsigned int IRC_TCL_THREADID  = 1421421421;   ///< The ID of the thread in TclThreadManager that is used for the IRC connection
+    static constexpr unsigned int IRC_TCL_THREADID  = 1421421421;   ///< The ID of the thread in TclThreadManager that is used for the IRC connection
 
     SetConsoleCommand("IRC", "say",  &IRC::say);
     SetConsoleCommand("IRC", "msg",  &IRC::msg);

Modified: code/branches/cpp11_v2/src/libraries/core/input/InputPrereqs.h
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/input/InputPrereqs.h	2015-12-29 16:18:23 UTC (rev 10993)
+++ code/branches/cpp11_v2/src/libraries/core/input/InputPrereqs.h	2015-12-29 16:36:14 UTC (rev 10994)
@@ -453,13 +453,13 @@
     {
         OrxEnumConstructors(InputStatePriority);
 
-        static const int Empty        = -1;
-        static const int Dynamic      = 0;
+        static constexpr int Empty        = -1;
+        static constexpr int Dynamic      = 0;
 
-        static const int HighPriority = 1000;
-        static const int Console      = HighPriority + 0;
-        static const int Calibrator   = HighPriority + 1;
-        static const int Detector     = HighPriority + 2;
+        static constexpr int HighPriority = 1000;
+        static constexpr int Console      = HighPriority + 0;
+        static constexpr int Calibrator   = HighPriority + 1;
+        static constexpr int Detector     = HighPriority + 2;
     };
 }
 

Modified: code/branches/cpp11_v2/src/libraries/network/NetworkFunction.h
===================================================================
--- code/branches/cpp11_v2/src/libraries/network/NetworkFunction.h	2015-12-29 16:18:23 UTC (rev 10993)
+++ code/branches/cpp11_v2/src/libraries/network/NetworkFunction.h	2015-12-29 16:36:14 UTC (rev 10994)
@@ -44,11 +44,11 @@
 {
 
 #if defined(ORXONOX_COMPILER_GCC) && defined(ORXONOX_ARCH_32)
-static const unsigned int MAX_FUNCTION_POINTER_SIZE = 8;
+static constexpr unsigned int MAX_FUNCTION_POINTER_SIZE = 8;
 #else
-static const unsigned int MAX_FUNCTION_POINTER_SIZE = 16;
+static constexpr unsigned int MAX_FUNCTION_POINTER_SIZE = 16;
 #endif //ORXONOX_COMPILER_GCC
-static const unsigned int MAX_FUNCTION_POINTER_INTS = (MAX_FUNCTION_POINTER_SIZE-1)/4+1;
+static constexpr unsigned int MAX_FUNCTION_POINTER_INTS = (MAX_FUNCTION_POINTER_SIZE-1)/4+1;
 
 struct _NetworkExport NetworkFunctionPointer {
   uint32_t pointer[MAX_FUNCTION_POINTER_INTS];

Modified: code/branches/cpp11_v2/src/libraries/network/NetworkPrereqs.h
===================================================================
--- code/branches/cpp11_v2/src/libraries/network/NetworkPrereqs.h	2015-12-29 16:18:23 UTC (rev 10993)
+++ code/branches/cpp11_v2/src/libraries/network/NetworkPrereqs.h	2015-12-29 16:36:14 UTC (rev 10994)
@@ -66,16 +66,16 @@
 
 namespace orxonox
 {
-  static const unsigned int GAMESTATEID_INITIAL       = static_cast<unsigned int>(-1);
+  static constexpr unsigned int GAMESTATEID_INITIAL       = static_cast<unsigned int>(-1);
   extern const char* LAN_DISCOVERY_MESSAGE;
   extern const char* LAN_DISCOVERY_ACK;
-  static const unsigned int LAN_DISCOVERY_PORT          = 55558;
-  static const unsigned int NETWORK_PEER_ID_SERVER      = 0;
-  static const unsigned int NETWORK_PEER_ID_BROADCAST   = static_cast<unsigned int>(-1);
-  static const unsigned int NETWORK_PEER_ID_UNKNOWN     = static_cast<unsigned int>(-2);
-  static const unsigned int NETWORK_CHANNEL_DEFAULT     = 0;
-  static const unsigned int NETWORK_CHANNEL_UNRELIABLE  = 1;
-  static const unsigned int NETWORK_CHANNEL_COUNT       = 2;
+  static constexpr unsigned int LAN_DISCOVERY_PORT          = 55558;
+  static constexpr unsigned int NETWORK_PEER_ID_SERVER      = 0;
+  static constexpr unsigned int NETWORK_PEER_ID_BROADCAST   = static_cast<unsigned int>(-1);
+  static constexpr unsigned int NETWORK_PEER_ID_UNKNOWN     = static_cast<unsigned int>(-2);
+  static constexpr unsigned int NETWORK_CHANNEL_DEFAULT     = 0;
+  static constexpr unsigned int NETWORK_CHANNEL_UNRELIABLE  = 1;
+  static constexpr unsigned int NETWORK_CHANNEL_COUNT       = 2;
 }
 
 //-----------------------------------------------------------------------

Modified: code/branches/cpp11_v2/src/libraries/network/TrafficControl.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/network/TrafficControl.cc	2015-12-29 16:18:23 UTC (rev 10993)
+++ code/branches/cpp11_v2/src/libraries/network/TrafficControl.cc	2015-12-29 16:36:14 UTC (rev 10994)
@@ -37,7 +37,7 @@
 
 namespace orxonox {
 
-  static const unsigned int SCHED_PRIORITY_OFFSET = static_cast<unsigned int>(-1);
+  static constexpr unsigned int SCHED_PRIORITY_OFFSET = static_cast<unsigned int>(-1);
   namespace arg = std::placeholders;
 
   objInfo::objInfo(uint32_t ID, uint32_t creatorID, int32_t curGsID, int32_t diffGsID, uint32_t size, unsigned int prioperm, unsigned int priosched)

Modified: code/branches/cpp11_v2/src/libraries/network/packet/Gamestate.h
===================================================================
--- code/branches/cpp11_v2/src/libraries/network/packet/Gamestate.h	2015-12-29 16:18:23 UTC (rev 10993)
+++ code/branches/cpp11_v2/src/libraries/network/packet/Gamestate.h	2015-12-29 16:36:14 UTC (rev 10994)
@@ -47,8 +47,8 @@
 namespace packet
 {
     
-static const uint8_t GAMESTATE_MODE_SERVER = 0x1;
-static const uint8_t GAMESTATE_MODE_CLIENT = 0x2;
+static constexpr uint8_t GAMESTATE_MODE_SERVER = 0x1;
+static constexpr uint8_t GAMESTATE_MODE_CLIENT = 0x2;
 
 class _NetworkExport GamestateHeader
 {

Modified: code/branches/cpp11_v2/src/libraries/util/output/LogWriter.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/util/output/LogWriter.cc	2015-12-29 16:18:23 UTC (rev 10993)
+++ code/branches/cpp11_v2/src/libraries/util/output/LogWriter.cc	2015-12-29 16:36:14 UTC (rev 10994)
@@ -43,7 +43,7 @@
 
 namespace orxonox
 {
-    static const int MAX_ARCHIVED_FILES = 9;
+    static constexpr int MAX_ARCHIVED_FILES = 9;
 
     /**
         @brief Constructor, initializes the desired output levels and the name and path of the log-file, and opens the log-file.

Modified: code/branches/cpp11_v2/src/libraries/util/output/OutputDefinitions.h
===================================================================
--- code/branches/cpp11_v2/src/libraries/util/output/OutputDefinitions.h	2015-12-29 16:18:23 UTC (rev 10993)
+++ code/branches/cpp11_v2/src/libraries/util/output/OutputDefinitions.h	2015-12-29 16:36:14 UTC (rev 10994)
@@ -131,10 +131,10 @@
 
     namespace context
     {
-        static const OutputContextMask all       = 0xFFFFFFFFFFFFFFFFull; ///< Context mask, all bits set to 1
-        static const OutputContextMask none      = 0x0000000000000000ull; ///< Context mask, all bits set to 0
+        static constexpr OutputContextMask all       = 0xFFFFFFFFFFFFFFFFull; ///< Context mask, all bits set to 1
+        static constexpr OutputContextMask none      = 0x0000000000000000ull; ///< Context mask, all bits set to 0
 
-        static const OutputContextSubID no_subcontext = 0; ///< Used as ID for contexts which are not sub-contexts
+        static constexpr OutputContextSubID no_subcontext = 0; ///< Used as ID for contexts which are not sub-contexts
 
         namespace
         {

Modified: code/branches/cpp11_v2/src/orxonox/controllers/FormationController.cc
===================================================================
--- code/branches/cpp11_v2/src/orxonox/controllers/FormationController.cc	2015-12-29 16:18:23 UTC (rev 10993)
+++ code/branches/cpp11_v2/src/orxonox/controllers/FormationController.cc	2015-12-29 16:36:14 UTC (rev 10994)
@@ -57,15 +57,15 @@
 
     RegisterClass(FormationController);
 
-    static const unsigned int STANDARD_MAX_FORMATION_SIZE = 9;
-    static const int RADIUS_TO_SEARCH_FOR_MASTERS = 5000;
-    static const float FORMATION_LENGTH =  110;
-    static const float FORMATION_WIDTH =  110;
-    static const int FREEDOM_COUNT = 4; //seconds the slaves in a formation will be set free when master attacks an enemy
-    static const float SPEED_MASTER = 0.6f;
-    static const float ROTATEFACTOR_MASTER = 0.2f;
-    static const float SPEED_FREE = 0.8f;
-    static const float ROTATEFACTOR_FREE = 0.8f;
+    static constexpr unsigned int STANDARD_MAX_FORMATION_SIZE = 9;
+    static constexpr int RADIUS_TO_SEARCH_FOR_MASTERS = 5000;
+    static constexpr float FORMATION_LENGTH =  110;
+    static constexpr float FORMATION_WIDTH =  110;
+    static constexpr int FREEDOM_COUNT = 4; //seconds the slaves in a formation will be set free when master attacks an enemy
+    static constexpr float SPEED_MASTER = 0.6f;
+    static constexpr float ROTATEFACTOR_MASTER = 0.2f;
+    static constexpr float SPEED_FREE = 0.8f;
+    static constexpr float ROTATEFACTOR_FREE = 0.8f;
 
     FormationController::FormationController(Context* context) : Controller(context)
     {




More information about the Orxonox-commit mailing list