[Orxonox-commit 6341] r10998 - in code/branches/cpp11_v2/src/modules: objects/triggers pickup pickup/items

landauf at orxonox.net landauf at orxonox.net
Wed Dec 30 13:59:38 CET 2015


Author: landauf
Date: 2015-12-30 13:59:38 +0100 (Wed, 30 Dec 2015)
New Revision: 10998

Modified:
   code/branches/cpp11_v2/src/modules/objects/triggers/DistanceMultiTrigger.cc
   code/branches/cpp11_v2/src/modules/objects/triggers/DistanceMultiTrigger.h
   code/branches/cpp11_v2/src/modules/objects/triggers/DistanceTrigger.cc
   code/branches/cpp11_v2/src/modules/objects/triggers/DistanceTrigger.h
   code/branches/cpp11_v2/src/modules/objects/triggers/EventTrigger.cc
   code/branches/cpp11_v2/src/modules/objects/triggers/EventTrigger.h
   code/branches/cpp11_v2/src/modules/objects/triggers/Trigger.cc
   code/branches/cpp11_v2/src/modules/objects/triggers/Trigger.h
   code/branches/cpp11_v2/src/modules/objects/triggers/TriggerBase.h
   code/branches/cpp11_v2/src/modules/pickup/Pickup.cc
   code/branches/cpp11_v2/src/modules/pickup/Pickup.h
   code/branches/cpp11_v2/src/modules/pickup/items/DronePickup.cc
   code/branches/cpp11_v2/src/modules/pickup/items/HealthPickup.cc
   code/branches/cpp11_v2/src/modules/pickup/items/HealthPickup.h
   code/branches/cpp11_v2/src/modules/pickup/items/MetaPickup.cc
   code/branches/cpp11_v2/src/modules/pickup/items/MetaPickup.h
Log:
using strongly typed enum class in pickups and triggers.

Modified: code/branches/cpp11_v2/src/modules/objects/triggers/DistanceMultiTrigger.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/objects/triggers/DistanceMultiTrigger.cc	2015-12-30 11:21:18 UTC (rev 10997)
+++ code/branches/cpp11_v2/src/modules/objects/triggers/DistanceMultiTrigger.cc	2015-12-30 12:59:38 UTC (rev 10998)
@@ -57,7 +57,7 @@
         RegisterObject(DistanceMultiTrigger);
 
         this->distance_ = 100.0f;
-        this->setBeaconModeDirect(distanceMultiTriggerBeaconMode::off);
+        this->setBeaconModeDirect(DistanceMultiTriggerBeaconMode::off);
         this->targetName_ = "";
         this->beaconMask_.exclude(Class(BaseObject));
         this->beaconMask_.include(Class(DistanceTriggerBeacon));
@@ -135,7 +135,7 @@
         // Check for new objects that are in range
         ClassTreeMask targetMask = this->getTargetMask();
         // If we are in identify-mode another target mask has to be applies to find the DistanceTriggerBeacons.
-        if(this->beaconMode_ == distanceMultiTriggerBeaconMode::identify)
+        if(this->beaconMode_ == DistanceMultiTriggerBeaconMode::identify)
             targetMask = this->beaconMask_;
 
         // Iterate through all objects that are targets of the DistanceMultiTrigger.
@@ -144,7 +144,7 @@
             WorldEntity* entity = static_cast<WorldEntity*>(*it);
 
             // If the DistanceMultiTrigger is in identify-mode and the DistanceTriggerBeacon attached to the object has the wrong name we ignore it.
-            if(this->beaconMode_ == distanceMultiTriggerBeaconMode::identify)
+            if(this->beaconMode_ == DistanceMultiTriggerBeaconMode::identify)
             {
                 if(entity->getName() != this->targetName_)
                     continue;
@@ -154,7 +154,7 @@
             }
             
             // If the DistanceMultiTrigger is in exclude mode and the DistanceTriggerBeacon attached to the object has the right name, we ignore it.
-            if(this->beaconMode_ == distanceMultiTriggerBeaconMode::exclude)
+            if(this->beaconMode_ == DistanceMultiTriggerBeaconMode::exclude)
             {
                 
                 const std::set<WorldEntity*> attachedObjects = entity->getAttachedObjects();
@@ -181,7 +181,7 @@
                     continue;
 
                 // Change the entity to the parent of the DistanceTriggerBeacon (if in identify-mode), which is the entity to which the beacon is attached.
-                if(this->beaconMode_ == distanceMultiTriggerBeaconMode::identify)
+                if(this->beaconMode_ == DistanceMultiTriggerBeaconMode::identify)
                     entity = entity->getParent();
 
                 // If no queue has been created, yet.
@@ -205,7 +205,7 @@
     @param mode
         The mode as an enum.
     */
-    void DistanceMultiTrigger::setBeaconModeDirect(distanceMultiTriggerBeaconMode::Value mode)
+    void DistanceMultiTrigger::setBeaconModeDirect(DistanceMultiTriggerBeaconMode mode)
     {
         this->beaconMode_ = mode;
     }
@@ -220,11 +220,11 @@
     {
         switch(this->getBeaconModeDirect())
         {
-            case distanceMultiTriggerBeaconMode::off :
+            case DistanceMultiTriggerBeaconMode::off :
                 return DistanceMultiTrigger::beaconModeOff_s;
-            case distanceMultiTriggerBeaconMode::identify:
+            case DistanceMultiTriggerBeaconMode::identify:
                 return DistanceMultiTrigger::beaconModeIdentify_s;
-            case distanceMultiTriggerBeaconMode::exclude:
+            case DistanceMultiTriggerBeaconMode::exclude:
                 return DistanceMultiTrigger::beaconModeExlcude_s;
             default :
                 assert(0); // This is impossible.
@@ -241,11 +241,11 @@
     void DistanceMultiTrigger::setBeaconMode(const std::string& mode)
     {
         if(mode == DistanceMultiTrigger::beaconModeOff_s)
-            this->setBeaconModeDirect(distanceMultiTriggerBeaconMode::off);
+            this->setBeaconModeDirect(DistanceMultiTriggerBeaconMode::off);
         else if(mode == DistanceMultiTrigger::beaconModeIdentify_s)
-            this->setBeaconModeDirect(distanceMultiTriggerBeaconMode::identify);
+            this->setBeaconModeDirect(DistanceMultiTriggerBeaconMode::identify);
         else if(mode == DistanceMultiTrigger::beaconModeExlcude_s)
-            this->setBeaconModeDirect(distanceMultiTriggerBeaconMode::exclude);
+            this->setBeaconModeDirect(DistanceMultiTriggerBeaconMode::exclude);
         else
             orxout(internal_error, context::triggers) << "Invalid beacon mode in DistanceMultiTrigger." << endl;
     }

Modified: code/branches/cpp11_v2/src/modules/objects/triggers/DistanceMultiTrigger.h
===================================================================
--- code/branches/cpp11_v2/src/modules/objects/triggers/DistanceMultiTrigger.h	2015-12-30 11:21:18 UTC (rev 10997)
+++ code/branches/cpp11_v2/src/modules/objects/triggers/DistanceMultiTrigger.h	2015-12-30 12:59:38 UTC (rev 10998)
@@ -54,14 +54,11 @@
         
     @ingroup MultiTrigger
     */
-    namespace distanceMultiTriggerBeaconMode
-    {
-        enum Value {
-            off, //!< The DistanceMultiTrigger is not in <em>beacon-mode</em>.
-            identify, //!< The DistanceTrigger is in <em>identify-mode</em>.
-            exclude //!< The DistanceTrigger is in <em>exclude-mode</em>.
-        };
-    }
+    enum class DistanceMultiTriggerBeaconMode {
+        off, //!< The DistanceMultiTrigger is not in <em>beacon-mode</em>.
+        identify, //!< The DistanceTrigger is in <em>identify-mode</em>.
+        exclude //!< The DistanceTrigger is in <em>exclude-mode</em>.
+    };
 
     /**
     @brief
@@ -112,12 +109,12 @@
             inline float getDistance() const
                 { return this->distance_; }
             
-            void setBeaconModeDirect(distanceMultiTriggerBeaconMode::Value mode); // Set the beacon mode.
+            void setBeaconModeDirect(DistanceMultiTriggerBeaconMode mode); // Set the beacon mode.
             /**
             @brief Get the beacon mode.
             @return Returns the mode as an enum.
             */
-            inline distanceMultiTriggerBeaconMode::Value getBeaconModeDirect(void) const
+            inline DistanceMultiTriggerBeaconMode getBeaconModeDirect(void) const
                 { return this->beaconMode_; }
             void setBeaconMode(const std::string& mode); // Set the beacon mode.
             const std::string& getBeaconMode(void) const; // Get the beacon mode.
@@ -148,7 +145,7 @@
             
             float distance_; //!< The distance at which the DistanceMultiTrigger triggers.
 
-            distanceMultiTriggerBeaconMode::Value beaconMode_; //!< The beacon mode, the DistanceMultiTrigger is in.
+            DistanceMultiTriggerBeaconMode beaconMode_; //!< The beacon mode, the DistanceMultiTrigger is in.
             std::string targetName_; //!< The target name, used in <em>single-target</em> mode.
             ClassTreeMask beaconMask_; //!< A mask, that only accepts DistanceTriggerBeacons.
 

Modified: code/branches/cpp11_v2/src/modules/objects/triggers/DistanceTrigger.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/objects/triggers/DistanceTrigger.cc	2015-12-30 11:21:18 UTC (rev 10997)
+++ code/branches/cpp11_v2/src/modules/objects/triggers/DistanceTrigger.cc	2015-12-30 12:59:38 UTC (rev 10998)
@@ -157,7 +157,7 @@
         // Check for new objects that are in range
         ClassTreeMask targetMask = this->targetMask_;
         // If we are in identify-mode another target mask has to be applies to find the DistanceTriggerBeacons.
-        if(this->beaconMode_ == distanceTriggerBeaconMode::identify)
+        if(this->beaconMode_ == DistanceTriggerBeaconMode::identify)
             targetMask = this->beaconMask_;
 
         // Iterate through all objects that are targets of the DistanceTrigger.
@@ -166,7 +166,7 @@
             WorldEntity* entity = static_cast<WorldEntity*>(*it);
 
             // If the DistanceTrigger is in identify-mode and the DistanceTriggerBeacon attached to the object has the wrong name we ignore it.
-            if(this->beaconMode_ == distanceTriggerBeaconMode::identify)
+            if(this->beaconMode_ == DistanceTriggerBeaconMode::identify)
             {
                 if(entity->getName() != this->targetName_)
                     continue;
@@ -176,7 +176,7 @@
             }
 
             // If the DistanceTrigger is in exclude mode and the DistanceTriggerBeacon attached to the object has the right name, we ignore it.
-            if(this->beaconMode_ == distanceTriggerBeaconMode::exclude)
+            if(this->beaconMode_ == DistanceTriggerBeaconMode::exclude)
             {
 
                 const std::set<WorldEntity*> attachedObjects = entity->getAttachedObjects();
@@ -201,7 +201,7 @@
                 if(this->isForPlayer())
                 {
                     // Change the entity to the parent of the DistanceTriggerBeacon (if in identify-mode), which is the entity to which the beacon is attached.
-                    if(this->beaconMode_ == distanceTriggerBeaconMode::identify)
+                    if(this->beaconMode_ == DistanceTriggerBeaconMode::identify)
                         entity = entity->getParent();
 
                     Pawn* pawn = orxonox_cast<Pawn*>(entity);
@@ -227,7 +227,7 @@
     @param mode
         The mode as an enum.
     */
-    void DistanceTrigger::setBeaconModeDirect(distanceTriggerBeaconMode::Value mode)
+    void DistanceTrigger::setBeaconModeDirect(DistanceTriggerBeaconMode mode)
     {
         this->beaconMode_ = mode;
     }
@@ -242,11 +242,11 @@
     {
         switch(this->getBeaconModeDirect())
         {
-            case distanceTriggerBeaconMode::off :
+            case DistanceTriggerBeaconMode::off :
                 return DistanceTrigger::beaconModeOff_s;
-            case distanceTriggerBeaconMode::identify:
+            case DistanceTriggerBeaconMode::identify:
                 return DistanceTrigger::beaconModeIdentify_s;
-            case distanceTriggerBeaconMode::exclude:
+            case DistanceTriggerBeaconMode::exclude:
                 return DistanceTrigger::beaconModeExlcude_s;
             default :
                 assert(0); // This is impossible.
@@ -263,11 +263,11 @@
     void DistanceTrigger::setBeaconMode(const std::string& mode)
     {
         if(mode == DistanceTrigger::beaconModeOff_s)
-            this->setBeaconModeDirect(distanceTriggerBeaconMode::off);
+            this->setBeaconModeDirect(DistanceTriggerBeaconMode::off);
         else if(mode == DistanceTrigger::beaconModeIdentify_s)
-            this->setBeaconModeDirect(distanceTriggerBeaconMode::identify);
+            this->setBeaconModeDirect(DistanceTriggerBeaconMode::identify);
         else if(mode == DistanceTrigger::beaconModeExlcude_s)
-            this->setBeaconModeDirect(distanceTriggerBeaconMode::exclude);
+            this->setBeaconModeDirect(DistanceTriggerBeaconMode::exclude);
         else
             orxout(internal_error, context::triggers) << "Invalid beacon mode in DistanceTrigger." << endl;
     }
@@ -281,7 +281,7 @@
     @return
         Returns true if it is triggered ,false if not.
     */
-    bool DistanceTrigger::isTriggered(TriggerMode::Value mode)
+    bool DistanceTrigger::isTriggered(TriggerMode mode)
     {
         if (Trigger::isTriggered(mode))
             return checkDistance();

Modified: code/branches/cpp11_v2/src/modules/objects/triggers/DistanceTrigger.h
===================================================================
--- code/branches/cpp11_v2/src/modules/objects/triggers/DistanceTrigger.h	2015-12-30 11:21:18 UTC (rev 10997)
+++ code/branches/cpp11_v2/src/modules/objects/triggers/DistanceTrigger.h	2015-12-30 12:59:38 UTC (rev 10998)
@@ -54,14 +54,11 @@
       
   @ingroup NormalTrigger
   */
-  namespace distanceTriggerBeaconMode
-  {
-      enum Value {
-          off,
-          identify,
-          exclude
-      };
-  }
+  enum class DistanceTriggerBeaconMode {
+      off,
+      identify,
+      exclude
+  };
 
     /**
     @brief
@@ -117,12 +114,12 @@
             inline float getDistance() const
                 { return this->distance_; }
 
-            void setBeaconModeDirect(distanceTriggerBeaconMode::Value mode); // Set the beacon mode.
+            void setBeaconModeDirect(DistanceTriggerBeaconMode mode); // Set the beacon mode.
             /**
             @brief Get the beacon mode.
             @return Returns the mode as an enum.
             */
-            inline distanceTriggerBeaconMode::Value getBeaconModeDirect(void) const
+            inline DistanceTriggerBeaconMode getBeaconModeDirect(void) const
             { return this->beaconMode_; }
             void setBeaconMode(const std::string& mode); // Set the beacon mode.
             const std::string& getBeaconMode(void) const; // Get the beacon mode.
@@ -143,7 +140,7 @@
             bool checkDistance(); // Check, whether there are entities that are targets of this DistanceTrigger in its range.
 
         protected:
-            virtual bool isTriggered(TriggerMode::Value mode); // Check whether the DistanceTrigger is triggered.
+            virtual bool isTriggered(TriggerMode mode) override; // Check whether the DistanceTrigger is triggered.
             /**
             @brief Notifies interested parties about a change of the DistanceTrigger's target mask.
             */
@@ -159,7 +156,7 @@
 
             float distance_; //!< The range of the DistanceTrigger.
             
-            distanceTriggerBeaconMode::Value beaconMode_; //!< The beacon mode.
+            DistanceTriggerBeaconMode beaconMode_; //!< The beacon mode.
             std::string targetName_; //!< The name a DistanceTriggerBeacon needs to have to make the DistanceTrigger react to it if in beacon-mode.
             ClassTreeMask beaconMask_; //!< A mask, that only accepts DistanceTriggerBeacons.
             

Modified: code/branches/cpp11_v2/src/modules/objects/triggers/EventTrigger.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/objects/triggers/EventTrigger.cc	2015-12-30 11:21:18 UTC (rev 10997)
+++ code/branches/cpp11_v2/src/modules/objects/triggers/EventTrigger.cc	2015-12-30 12:59:38 UTC (rev 10998)
@@ -78,7 +78,7 @@
         Check whether the EventTrigger should be triggered.
         It should be triggered if it is triggered according just to its sub-triggers and if the last event that came in was an event that changed from not triggered to triggered.
     */
-    bool EventTrigger::isTriggered(TriggerMode::Value mode)
+    bool EventTrigger::isTriggered(TriggerMode mode)
     {
         if (Trigger::isTriggered(mode))
             return this->bEventTriggered_;

Modified: code/branches/cpp11_v2/src/modules/objects/triggers/EventTrigger.h
===================================================================
--- code/branches/cpp11_v2/src/modules/objects/triggers/EventTrigger.h	2015-12-30 11:21:18 UTC (rev 10997)
+++ code/branches/cpp11_v2/src/modules/objects/triggers/EventTrigger.h	2015-12-30 12:59:38 UTC (rev 10998)
@@ -83,7 +83,7 @@
                 { this->bEventTriggered_ = bTriggered; this->tick(0); }
 
         protected:
-            virtual bool isTriggered(TriggerMode::Value mode); // Check whether the EventTrigger should be triggered.
+            virtual bool isTriggered(TriggerMode mode) override; // Check whether the EventTrigger should be triggered.
 
         private:
             bool bEventTriggered_; //!< Boolean to keep track of what the state of the last event was.

Modified: code/branches/cpp11_v2/src/modules/objects/triggers/Trigger.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/objects/triggers/Trigger.cc	2015-12-30 11:21:18 UTC (rev 10997)
+++ code/branches/cpp11_v2/src/modules/objects/triggers/Trigger.cc	2015-12-30 12:59:38 UTC (rev 10998)
@@ -202,7 +202,7 @@
     @return
         Returns true if the Trigger should be triggered and false if not.
     */
-    bool Trigger::isTriggered(TriggerMode::Value mode)
+    bool Trigger::isTriggered(TriggerMode mode)
     {
         // If the trigger has sub-triggers.
         if (this->children_.size() > 0)

Modified: code/branches/cpp11_v2/src/modules/objects/triggers/Trigger.h
===================================================================
--- code/branches/cpp11_v2/src/modules/objects/triggers/Trigger.h	2015-12-30 11:21:18 UTC (rev 10997)
+++ code/branches/cpp11_v2/src/modules/objects/triggers/Trigger.h	2015-12-30 12:59:38 UTC (rev 10998)
@@ -104,7 +104,7 @@
             */
             inline bool isTriggered()
                 { return this->isTriggered(this->mode_); }
-            virtual bool isTriggered(TriggerMode::Value mode); // Check whether the Trigger should be triggered, given only its sub-triggers, given a specific mode.
+            virtual bool isTriggered(TriggerMode mode); // Check whether the Trigger should be triggered, given only its sub-triggers, given a specific mode.
             virtual void triggered(bool bIsTriggered); // Fires an event with the input triggered state.
 
         private:

Modified: code/branches/cpp11_v2/src/modules/objects/triggers/TriggerBase.h
===================================================================
--- code/branches/cpp11_v2/src/modules/objects/triggers/TriggerBase.h	2015-12-30 11:21:18 UTC (rev 10997)
+++ code/branches/cpp11_v2/src/modules/objects/triggers/TriggerBase.h	2015-12-30 12:59:38 UTC (rev 10998)
@@ -51,15 +51,12 @@
 
     @ingroup Triggers
     */
-    namespace TriggerMode
+    enum class TriggerMode
     {
-        enum Value
-        {
-            EventTriggerAND, //!< The <em>and</em> mode. The trigger can only trigger if all the children are active. 
-            EventTriggerOR, //!< The <em>or</em> mode. The trigger can only trigger if at least one child is active.
-            EventTriggerXOR, //!< The <em>xor</em> mode. The trigger can only trigger if exactly one child is active. 
-        };
-    }
+        EventTriggerAND, //!< The <em>and</em> mode. The trigger can only trigger if all the children are active.
+        EventTriggerOR, //!< The <em>or</em> mode. The trigger can only trigger if at least one child is active.
+        EventTriggerXOR, //!< The <em>xor</em> mode. The trigger can only trigger if exactly one child is active.
+    };
 
     /**
     @brief
@@ -157,14 +154,14 @@
             @brief Set the mode of the trigger.
             @param mode The mode of the trigger.
             */
-            inline void setMode(TriggerMode::Value mode) //!< Get the mode of the trigger.
+            inline void setMode(TriggerMode mode) //!< Get the mode of the trigger.
                 { this->mode_ = mode; }
             const std::string& getModeString(void) const;
             /**
             @brief Get the mode of the trigger.
             @return Returns and Enum for the mode of the trigger.
             */
-            inline TriggerMode::Value getMode(void) const
+            inline TriggerMode getMode(void) const
                 { return mode_; }
 
             void addTrigger(TriggerBase* trigger);
@@ -210,7 +207,7 @@
             int remainingActivations_; //!< The remaining activations of this trigger.
 
             bool bInvertMode_; //!< Bool for the invert-mode, if true the trigger is inverted.
-            TriggerMode::Value mode_; //!< The mode of the trigger.
+            TriggerMode mode_; //!< The mode of the trigger.
 
             TriggerBase* parent_; //!< The parent of this trigger.
             std::set<TriggerBase*> children_; //!< The children of this trigger.

Modified: code/branches/cpp11_v2/src/modules/pickup/Pickup.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/pickup/Pickup.cc	2015-12-30 11:21:18 UTC (rev 10997)
+++ code/branches/cpp11_v2/src/modules/pickup/Pickup.cc	2015-12-30 12:59:38 UTC (rev 10998)
@@ -77,8 +77,8 @@
     */
     void Pickup::initialize(void)
     {
-        this->activationType_ = pickupActivationType::immediate;
-        this->durationType_ = pickupDurationType::once;
+        this->activationType_ = PickupActivationType::immediate;
+        this->durationType_ = PickupDurationType::once;
     }
 
     /**
@@ -104,9 +104,9 @@
     {
         switch(this->getActivationType())
         {
-            case pickupActivationType::immediate:
+            case PickupActivationType::immediate:
                 return activationTypeImmediate_s;
-            case pickupActivationType::onUse:
+            case PickupActivationType::onUse:
                 return activationTypeOnUse_s;
             default:
                 return BLANKSTRING;
@@ -123,9 +123,9 @@
     {
         switch(this->getDurationType())
         {
-            case pickupDurationType::once:
+            case PickupDurationType::once:
                 return durationTypeOnce_s;
-            case pickupDurationType::continuous:
+            case PickupDurationType::continuous:
                 return durationTypeContinuous_s;
             default:
                 return BLANKSTRING;
@@ -141,9 +141,9 @@
     void Pickup::setActivationTypeAsString(const std::string& type)
     {
         if(type == Pickup::activationTypeImmediate_s)
-            this->setActivationType(pickupActivationType::immediate);
+            this->setActivationType(PickupActivationType::immediate);
         else if(type == Pickup::activationTypeOnUse_s)
-            this->setActivationType(pickupActivationType::onUse);
+            this->setActivationType(PickupActivationType::onUse);
         else
             orxout(internal_error, context::pickups) << "Invalid activationType '" << type << "' in " << this->getIdentifier()->getName() << "." << endl;
     }
@@ -157,9 +157,9 @@
     void Pickup::setDurationTypeAsString(const std::string& type)
     {
         if(type == Pickup::durationTypeOnce_s)
-            this->setDurationType(pickupDurationType::once);
+            this->setDurationType(PickupDurationType::once);
         else if(type == Pickup::durationTypeContinuous_s)
-            this->setDurationType(pickupDurationType::continuous);
+            this->setDurationType(PickupDurationType::continuous);
         else
             orxout(internal_error, context::pickups) << "Invalid durationType '" << type << "' in " << this->getIdentifier()->getName() << "." << endl;
     }

Modified: code/branches/cpp11_v2/src/modules/pickup/Pickup.h
===================================================================
--- code/branches/cpp11_v2/src/modules/pickup/Pickup.h	2015-12-30 11:21:18 UTC (rev 10997)
+++ code/branches/cpp11_v2/src/modules/pickup/Pickup.h	2015-12-30 12:59:38 UTC (rev 10998)
@@ -52,14 +52,11 @@
 
     @ingroup Pickup
     */
-    namespace pickupActivationType
+    enum class PickupActivationType
     {
-        enum Value
-        {
-            immediate, //!< Means that the @ref orxonox::Pickup "Pickup" will be used immediately after pickup.
-            onUse, //!< Means that the @ref orxonox::Pickup "Pickup" will be used at a later point trough some external influence.
-        };
-    }
+        immediate, //!< Means that the @ref orxonox::Pickup "Pickup" will be used immediately after pickup.
+        onUse, //!< Means that the @ref orxonox::Pickup "Pickup" will be used at a later point trough some external influence.
+    };
 
     /**
     @brief
@@ -67,14 +64,11 @@
 
     @ingroup Pickup
     */
-    namespace pickupDurationType
+    enum class PickupDurationType
     {
-        enum Value
-        {
-            once, //!< Means that the @ref orxonox::Pickup "Pickup" will be used only once at a singular time instant.
-            continuous, //!< Means that the @ref orxonox::Pickup "Pickup" will be used over a continuous timespan.
-        };
-    }
+        once, //!< Means that the @ref orxonox::Pickup "Pickup" will be used only once at a singular time instant.
+        continuous, //!< Means that the @ref orxonox::Pickup "Pickup" will be used over a continuous timespan.
+    };
 
     /**
     @brief
@@ -111,13 +105,13 @@
             @brief Get the activation type of the Pickup.
             @return Returns the activation type of the Pickup.
             */
-            inline pickupActivationType::Value getActivationType(void) const
+            inline PickupActivationType getActivationType(void) const
                 { return this->activationType_; }
             /**
             @brief Get the duration type of the Pickup.
             @return Returns the duration type of the Pickup.
             */
-            inline pickupDurationType::Value getDurationType(void) const
+            inline PickupDurationType getDurationType(void) const
                 { return this->durationType_; }
 
             const std::string& getActivationTypeAsString(void) const; //!< Get the activation type of the Pickup.
@@ -128,25 +122,25 @@
             @return Returns true if the activation type is 'immediate'.
             */
             inline bool isImmediate(void) const
-                { return this->getActivationType() == pickupActivationType::immediate; }
+                { return this->getActivationType() == PickupActivationType::immediate; }
             /**
             @brief Get whether the activation type is 'onUse'.
             @return Returns true if the activation type is 'onUse'.
             */
             inline bool isOnUse(void) const
-                { return this->getActivationType() == pickupActivationType::onUse; }
+                { return this->getActivationType() == PickupActivationType::onUse; }
             /**
             @brief Get whether the duration type is 'once'.
             @return Returns true if the duration type is 'once'.
             */
             inline bool isOnce(void) const
-                { return this->getDurationType() == pickupDurationType::once; }
+                { return this->getDurationType() == PickupDurationType::once; }
             /**
             @brief Get whether the duration type is 'continuous'.
             @return Returns true if the duration type is 'continuous'.
             */
             inline bool isContinuous(void) const
-                { return this->getDurationType() == pickupDurationType::continuous; }
+                { return this->getDurationType() == PickupDurationType::continuous; }
 
             virtual void changedPickedUp(void) override; //!< Should be called when the pickup has transited from picked up to dropped or the other way around.
 
@@ -163,13 +157,13 @@
             @brief Set the activation type of the Pickup.
             @param type The activation type of the Pickup.
             */
-            inline void setActivationType(pickupActivationType::Value type)
+            inline void setActivationType(PickupActivationType type)
                 { this->activationType_ = type; }
             /**
             @brief Set the duration type of the Pickup.
             @param type The duration type of the Pickup.
             */
-            inline void setDurationType(pickupDurationType::Value type)
+            inline void setDurationType(PickupDurationType type)
                 { this->durationType_ = type; }
 
             void setActivationTypeAsString(const std::string& type); //!< Set the activation type of the Pickup.
@@ -179,8 +173,8 @@
             void initialize(void); //!< Initializes the member variables.
 
             std::string representationName_; //!< The name of the associated PickupRepresentation.
-            pickupActivationType::Value activationType_; //!< The activation type of the Pickup.
-            pickupDurationType::Value durationType_; //!< The duration type of the Pickup.
+            PickupActivationType activationType_; //!< The activation type of the Pickup.
+            PickupDurationType durationType_; //!< The duration type of the Pickup.
 
             //! Strings for the activation and duration types.
             static const std::string activationTypeImmediate_s;

Modified: code/branches/cpp11_v2/src/modules/pickup/items/DronePickup.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/pickup/items/DronePickup.cc	2015-12-30 11:21:18 UTC (rev 10997)
+++ code/branches/cpp11_v2/src/modules/pickup/items/DronePickup.cc	2015-12-30 12:59:38 UTC (rev 10998)
@@ -73,7 +73,7 @@
     void DronePickup::initialize(void)
     {
         this->addTarget(ClassIdentifier<Pawn>::getIdentifier());
-        this->setDurationType(pickupDurationType::once);
+        this->setDurationType(PickupDurationType::once);
         this->droneTemplate_ = "";
     }
 

Modified: code/branches/cpp11_v2/src/modules/pickup/items/HealthPickup.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/pickup/items/HealthPickup.cc	2015-12-30 11:21:18 UTC (rev 10997)
+++ code/branches/cpp11_v2/src/modules/pickup/items/HealthPickup.cc	2015-12-30 12:59:38 UTC (rev 10998)
@@ -76,7 +76,7 @@
     {
         this->health_ = 0.0f;
         this->healthRate_ = 0.0f;
-        this->healthType_ = pickupHealthType::limited;
+        this->healthType_ = PickupHealthType::limited;
         this->maxHealthSave_ = 0.0f;
         this->maxHealthOverwrite_ = 0.0f;
 
@@ -126,13 +126,13 @@
 
             switch(this->getHealthType())
             {
-                case pickupHealthType::permanent:
+                case PickupHealthType::permanent:
                     if(pawn->getMaxHealth() < fullHealth)
                         pawn->setMaxHealth(fullHealth);
-                case pickupHealthType::limited:
+                case PickupHealthType::limited:
                     pawn->addHealth(health);
                     break;
-                case pickupHealthType::temporary:
+                case PickupHealthType::temporary:
                     if(pawn->getMaxHealth() > fullHealth)
                     {
                         this->maxHealthSave_ = pawn->getMaxHealth();
@@ -173,14 +173,14 @@
                 float health = 0.0f;
                 switch(this->getHealthType())
                 {
-                    case pickupHealthType::permanent:
+                    case PickupHealthType::permanent:
                         health = pawn->getHealth()+this->getHealth();
                         if(pawn->getMaxHealth() < health)
                             pawn->setMaxHealth(health);
-                    case pickupHealthType::limited:
+                    case PickupHealthType::limited:
                         pawn->addHealth(this->getHealth());
                         break;
-                    case pickupHealthType::temporary:
+                    case PickupHealthType::temporary:
                         health = pawn->getHealth()+this->getHealth();
                         if(pawn->getMaxHealth() < health)
                         {
@@ -200,7 +200,7 @@
         }
         else
         {
-            if(this->getHealthType() == pickupHealthType::temporary)
+            if(this->getHealthType() == PickupHealthType::temporary)
             {
                 PickupCarrier* carrier = this->getCarrier();
                 Pawn* pawn = orxonox_cast<Pawn*>(carrier);
@@ -255,11 +255,11 @@
     {
         switch(this->getHealthType())
         {
-            case pickupHealthType::limited:
+            case PickupHealthType::limited:
                 return HealthPickup::healthTypeLimited_s;
-            case pickupHealthType::temporary:
+            case PickupHealthType::temporary:
                 return HealthPickup::healthTypeTemporary_s;
-            case pickupHealthType::permanent:
+            case PickupHealthType::permanent:
                 return HealthPickup::healthTypePermanent_s;
             default:
                 orxout(internal_error, context::pickups) << "Invalid healthType in HealthPickup." << endl;
@@ -307,11 +307,11 @@
     void HealthPickup::setHealthTypeAsString(const std::string& type)
     {
         if(type == HealthPickup::healthTypeLimited_s)
-            this->setHealthType(pickupHealthType::limited);
+            this->setHealthType(PickupHealthType::limited);
         else if(type == HealthPickup::healthTypeTemporary_s)
-            this->setHealthType(pickupHealthType::temporary);
+            this->setHealthType(PickupHealthType::temporary);
         else if(type == HealthPickup::healthTypePermanent_s)
-            this->setHealthType(pickupHealthType::permanent);
+            this->setHealthType(PickupHealthType::permanent);
         else
             orxout(internal_error, context::pickups) << "Invalid healthType '" << type << "' in HealthPickup." << endl;
     }

Modified: code/branches/cpp11_v2/src/modules/pickup/items/HealthPickup.h
===================================================================
--- code/branches/cpp11_v2/src/modules/pickup/items/HealthPickup.h	2015-12-30 11:21:18 UTC (rev 10997)
+++ code/branches/cpp11_v2/src/modules/pickup/items/HealthPickup.h	2015-12-30 12:59:38 UTC (rev 10998)
@@ -50,15 +50,12 @@
 
     @ingroup PickupItems
     */
-    namespace pickupHealthType
+    enum class PickupHealthType
     {
-        enum Value
-        {
-            limited, //!< Means that the @ref orxonox::HealthPickup "HealthPickup" only increases the users health to its maximum health.
-            temporary, //!< Means that the @ref orxonox::HealthPickup "HealthPickup" temporarily increases the users health even above its maximum health, but only as long as it is in use.
-            permanent //!< Means that the @ref orxonox::HealthPickup "HealthPickup" increases the users health even above its maximum health and increases the maximum health permanently such that it matches the new health.
-        };
-    }
+        limited, //!< Means that the @ref orxonox::HealthPickup "HealthPickup" only increases the users health to its maximum health.
+        temporary, //!< Means that the @ref orxonox::HealthPickup "HealthPickup" temporarily increases the users health even above its maximum health, but only as long as it is in use.
+        permanent //!< Means that the @ref orxonox::HealthPickup "HealthPickup" increases the users health even above its maximum health and increases the maximum health permanently such that it matches the new health.
+    };
 
     /**
     @brief
@@ -114,7 +111,7 @@
             @brief Get the type of HealthPickup, this pickup is.
             @return Returns the health type as an enum.
             */
-            inline pickupHealthType::Value getHealthType(void) const
+            inline PickupHealthType getHealthType(void) const
                 { return this->healthType_; }
             const std::string& getHealthTypeAsString(void) const; //!< Get the health type of this pickup.
 
@@ -126,7 +123,7 @@
             @brief Set the health type of this pickup.
             @param type The type of this pickup as an enum.
             */
-            inline void setHealthType(pickupHealthType::Value type)
+            inline void setHealthType(PickupHealthType type)
                 { this->healthType_ = type; }
             void setHealthTypeAsString(const std::string& type); //!< Set the type of the HealthPickup.
 
@@ -138,7 +135,7 @@
             float healthRate_; //!< The rate at which the health is transferred.
             float maxHealthSave_; //!< Helper to remember what the actual maxHealth of the Pawn was before we changed it.
             float maxHealthOverwrite_; //!< Helper to remember with which value we overwrote the maxHealh, to detect if someone else changed it as well.
-            pickupHealthType::Value healthType_; //!< The type of the HealthPickup.
+            PickupHealthType healthType_; //!< The type of the HealthPickup.
 
             //! Strings for the health types.
             static const std::string healthTypeLimited_s;

Modified: code/branches/cpp11_v2/src/modules/pickup/items/MetaPickup.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/pickup/items/MetaPickup.cc	2015-12-30 11:21:18 UTC (rev 10997)
+++ code/branches/cpp11_v2/src/modules/pickup/items/MetaPickup.cc	2015-12-30 12:59:38 UTC (rev 10998)
@@ -78,8 +78,8 @@
     {
         this->addTarget(ClassIdentifier<PickupCarrier>::getIdentifier());
 
-        this->setDurationType(pickupDurationType::once);
-        this->metaType_ = pickupMetaType::none;
+        this->setDurationType(PickupDurationType::once);
+        this->metaType_ = PickupMetaType::none;
     }
 
     /**
@@ -103,13 +103,13 @@
         SUPER(MetaPickup, changedUsed);
 
         // If the MetaPickup transited to used, and the metaType is not none.
-        if(this->isUsed() && this->metaType_ != pickupMetaType::none)
+        if(this->isUsed() && this->metaType_ != PickupMetaType::none)
         {
             PickupCarrier* carrier = this->getCarrier();
-            if(this->getMetaType() != pickupMetaType::none && carrier != nullptr)
+            if(this->getMetaType() != PickupMetaType::none && carrier != nullptr)
             {
                 // If the metaType is destroyCarrier, then the PickupCarrier is destroyed.
-                if(this->getMetaType() == pickupMetaType::destroyCarrier)
+                if(this->getMetaType() == PickupMetaType::destroyCarrier)
                 {
                     Pawn* pawn = orxonox_cast<Pawn*>(carrier);
                     pawn->kill();
@@ -123,17 +123,17 @@
                         continue;
 
                     // If the metaType is use, then the Pickupable is set to used.
-                    if(this->getMetaType() == pickupMetaType::use && !pickup->isUsed())
+                    if(this->getMetaType() == PickupMetaType::use && !pickup->isUsed())
                     {
                         pickup->setUsed(true);
                     }
                     // If the metaType is drop, then the Pickupable is dropped.
-                    else if(this->getMetaType() == pickupMetaType::drop)
+                    else if(this->getMetaType() == PickupMetaType::drop)
                     {
                         pickup->drop();
                     }
                     // If the metaType is destroy, then the Pickupable is destroyed.
-                    else if(this->getMetaType() == pickupMetaType::destroy)
+                    else if(this->getMetaType() == PickupMetaType::destroy)
                     {
                         pickup->Pickupable::destroy();
                     }
@@ -153,15 +153,15 @@
     {
         switch(this->getMetaType())
         {
-            case pickupMetaType::none:
+            case PickupMetaType::none:
                 return MetaPickup::metaTypeNone_s;
-            case pickupMetaType::use:
+            case PickupMetaType::use:
                 return MetaPickup::metaTypeUse_s;
-            case pickupMetaType::drop:
+            case PickupMetaType::drop:
                 return MetaPickup::metaTypeDrop_s;
-            case pickupMetaType::destroy:
+            case PickupMetaType::destroy:
                 return MetaPickup::metaTypeDestroy_s;
-            case pickupMetaType::destroyCarrier:
+            case PickupMetaType::destroyCarrier:
                 return MetaPickup::metaTypeDestroyCarrier_s;
             default:
                 return BLANKSTRING;
@@ -178,23 +178,23 @@
     {
         if(type == MetaPickup::metaTypeNone_s)
         {
-            this->setMetaType(pickupMetaType::none);
+            this->setMetaType(PickupMetaType::none);
         }
         else if(type == MetaPickup::metaTypeUse_s)
         {
-            this->setMetaType(pickupMetaType::use);
+            this->setMetaType(PickupMetaType::use);
         }
         else if(type == MetaPickup::metaTypeDrop_s)
         {
-            this->setMetaType(pickupMetaType::drop);
+            this->setMetaType(PickupMetaType::drop);
         }
         else if(type == MetaPickup::metaTypeDestroy_s)
         {
-            this->setMetaType(pickupMetaType::destroy);
+            this->setMetaType(PickupMetaType::destroy);
         }
         else if(type == MetaPickup::metaTypeDestroyCarrier_s)
         {
-            this->setMetaType(pickupMetaType::destroyCarrier);
+            this->setMetaType(PickupMetaType::destroyCarrier);
         }
         else
             orxout(internal_warning, context::pickups) << "Invalid metaType '" << type << "' in MetaPickup." << endl;

Modified: code/branches/cpp11_v2/src/modules/pickup/items/MetaPickup.h
===================================================================
--- code/branches/cpp11_v2/src/modules/pickup/items/MetaPickup.h	2015-12-30 11:21:18 UTC (rev 10997)
+++ code/branches/cpp11_v2/src/modules/pickup/items/MetaPickup.h	2015-12-30 12:59:38 UTC (rev 10998)
@@ -47,17 +47,14 @@
 
     @ingroup PickupItems
     */
-    namespace pickupMetaType
+    enum class PickupMetaType
     {
-        enum Value
-        {
-            none, //!< The @ref orxonox::MetaPickup "MetaPickup" does nothing.
-            use, //!< The @ref orxonox::MetaPickup "MetaPickup" uses all the @ref orxonox::PickupCarrier "PickupCarriers'" @ref orxonox::Pickupable "Pickupables".
-            drop, //!< The @ref orxonox::MetaPickup "MetaPickup" drops all the @ref orxonox::PickupCarrier "PickupCarriers'" @ref orxonox::Pickupable "Pickupables".
-            destroy, //!< The @ref orxonox::MetaPickup "MetaPickup" destroys all the @ref orxonox::PickupCarrier "PickupCarriers'" @ref orxonox::Pickupable "Pickupables".
-            destroyCarrier //!< The @ref orxonox::MetaPickup "MetaPickup" destroys the @ref orxonox::PickupCarrier "PickupCarrier".
-        };
-    }
+        none, //!< The @ref orxonox::MetaPickup "MetaPickup" does nothing.
+        use, //!< The @ref orxonox::MetaPickup "MetaPickup" uses all the @ref orxonox::PickupCarrier "PickupCarriers'" @ref orxonox::Pickupable "Pickupables".
+        drop, //!< The @ref orxonox::MetaPickup "MetaPickup" drops all the @ref orxonox::PickupCarrier "PickupCarriers'" @ref orxonox::Pickupable "Pickupables".
+        destroy, //!< The @ref orxonox::MetaPickup "MetaPickup" destroys all the @ref orxonox::PickupCarrier "PickupCarriers'" @ref orxonox::Pickupable "Pickupables".
+        destroyCarrier //!< The @ref orxonox::MetaPickup "MetaPickup" destroys the @ref orxonox::PickupCarrier "PickupCarrier".
+    };
 
     /**
     @brief
@@ -99,7 +96,7 @@
             @brief Returns the meta type of the MetaPickup.
             @return Returns an enum with the meta type of the MetaPickup.
             */
-            inline pickupMetaType::Value getMetaType(void) const
+            inline PickupMetaType getMetaType(void) const
                 { return this->metaType_; }
             const std::string& getMetaTypeAsString(void) const; //!< Get the meta type of this MetaPickup.
 
@@ -108,14 +105,14 @@
             @brief Set the meta type of the MetaPickup.
             @param type The meta type as an enum.
             */
-            inline void setMetaType(pickupMetaType::Value type)
+            inline void setMetaType(PickupMetaType type)
                 { this->metaType_ =  type; }
             void setMetaTypeAsString(const std::string& type); //!< Set the meta type of this MetaPickup.
 
         private:
             void initialize(void); //!< Initializes the member variables.
 
-            pickupMetaType::Value metaType_; //!< The meta type of the MetaPickup, determines which actions are taken.
+            PickupMetaType metaType_; //!< The meta type of the MetaPickup, determines which actions are taken.
 
             //! Static strings for the meta types.
             static const std::string metaTypeNone_s;




More information about the Orxonox-commit mailing list