Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 17, 2016, 10:29:21 PM (9 years ago)
Author:
landauf
Message:

merged branch cpp11_v3 back to trunk

Location:
code/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/interfaces/NotificationListener.cc

    r10624 r11071  
    7474        The type of the notification, can be either 'info' or 'important'.
    7575    */
    76     /*static*/ void NotificationListener::sendNetworkHelper(const std::string& message, const std::string& sender, notificationSendMode::Value sendMode, unsigned int clientId, bool isCommand, notificationMessageType::Value messageType)
     76    /*static*/ void NotificationListener::sendNetworkHelper(const std::string& message, const std::string& sender, NotificationSendMode sendMode, unsigned int clientId, bool isCommand, NotificationMessageType messageType)
    7777    {
    7878        // If we're in standalone mode or we're already no the right client we create and send the notification/command.
    79         if(GameMode::isStandalone() || sendMode == notificationSendMode::local || (sendMode ==  notificationSendMode::network && Host::getPlayerID() == clientId))
     79        if(GameMode::isStandalone() || sendMode == NotificationSendMode::local || (sendMode ==  NotificationSendMode::network && Host::getPlayerID() == clientId))
    8080        {
    8181            sendHelper(message, sender, isCommand, messageType);
    8282        }
    8383        // If we're on the server (and the server is not the intended recipient of the notification/command) we send it over the network.
    84         else if(GameMode::isServer() && sendMode == notificationSendMode::network && Host::getPlayerID() != clientId)
     84        else if(GameMode::isServer() && sendMode == NotificationSendMode::network && Host::getPlayerID() != clientId)
    8585        {
    86             callStaticNetworkFunction(&NotificationListener::sendHelper, clientId, message, sender, isCommand, (unsigned int)messageType);
     86            callStaticNetworkFunction(&NotificationListener::sendHelper, clientId, message, sender, isCommand, messageType);
    8787        }
    88         else if(GameMode::isServer() && sendMode == notificationSendMode::broadcast)
     88        else if(GameMode::isServer() && sendMode == NotificationSendMode::broadcast)
    8989        {
    9090            // TODO: Works as intended?
    91             callStaticNetworkFunction(&NotificationListener::sendHelper, NETWORK_PEER_ID_BROADCAST, message, sender, isCommand, (unsigned int)messageType);
     91            callStaticNetworkFunction(&NotificationListener::sendHelper, NETWORK_PEER_ID_BROADCAST, message, sender, isCommand, messageType);
    9292        }
    9393    }
     
    105105        The type of the notification.
    106106    */
    107     /*static*/ void NotificationListener::sendHelper(const std::string& message, const std::string& sender, bool isCommand, unsigned int messageType)
     107    /*static*/ void NotificationListener::sendHelper(const std::string& message, const std::string& sender, bool isCommand, NotificationMessageType type)
    108108    {
    109109        // Iterate through all NotificationListeners and notify them by calling the method they overloaded.
    110         for(ObjectList<NotificationListener>::iterator it = ObjectList<NotificationListener>::begin(); it != ObjectList<NotificationListener>::end(); ++it)
     110        for(NotificationListener* listener : ObjectList<NotificationListener>())
    111111        {
    112112            // If the notification is a message.
    113113            if(!isCommand)
    114                 it->registerNotification(message, sender, notificationMessageType::Value(messageType));
     114                listener->registerNotification(message, sender, type);
    115115
    116116            // If the notification is a command.
    117117            if(isCommand)
    118118            {
    119                 notificationCommand::Value command = str2Command(message);
    120                 if(command != notificationCommand::none)
    121                     it->executeCommand(command, sender);
     119                NotificationCommand command = str2Command(message);
     120                if(command != NotificationCommand::none)
     121                    listener->executeCommand(command, sender);
    122122            }
    123123        }
     
    130130        The string to be converted.
    131131    @return
    132         Returns the corresponding enum, notificationCommand::none if the command doesn't exist.
     132        Returns the corresponding enum, NotificationCommand::none if the command doesn't exist.
    133133    */
    134     /*static*/ notificationCommand::Value NotificationListener::str2Command(const std::string& string)
     134    /*static*/ NotificationCommand NotificationListener::str2Command(const std::string& string)
    135135    {
    136         notificationCommand::Value command = notificationCommand::none;
     136        NotificationCommand command = NotificationCommand::none;
    137137
    138138        if(string == NotificationListener::COMMAND_CLEAR)
    139             command = notificationCommand::clear;
     139            command = NotificationCommand::clear;
    140140
    141141        return command;
     
    150150        Returns the corresponding string.
    151151    */
    152     /*static*/ const std::string& NotificationListener::command2Str(notificationCommand::Value command)
     152    /*static*/ const std::string& NotificationListener::command2Str(NotificationCommand command)
    153153    {
    154154        switch(command)
    155155        {
    156             case notificationCommand::clear:
     156            case NotificationCommand::clear:
    157157                return NotificationListener::COMMAND_CLEAR;
    158158            default:
  • code/trunk/src/orxonox/interfaces/NotificationListener.h

    r9667 r11071  
    4949{
    5050    // TODO: Document.
    51     namespace notificationMessageType
    52     {
    53         enum Value {
    54             info,
    55             important
    56         };
    57     }
     51    enum class NotificationMessageType {
     52        info,
     53        important
     54    };
    5855   
    59     namespace notificationSendMode
    60     {
    61         enum Value {
    62             local,
    63             network,
    64             broadcast
    65         };
    66     }
     56    enum class NotificationSendMode {
     57        local,
     58        network,
     59        broadcast
     60    };
    6761   
    68     namespace notificationCommand
    69     {
    70         enum Value {
    71             none,
    72             clear
    73         };
    74     }
     62    enum class NotificationCommand {
     63        none,
     64        clear
     65    };
    7566
    7667    // TODO: Update doc.
     
    10192            @param sender The sender that sent the notification. Default is 'none'.
    10293            @param messageType The type of the message, can be either 'info' or 'important'. Default is 'info'.
    103             @param sendMode The mode in which the notification is sent, can be 'local' to send the notification to the client where this function is executed, 'network' if the notification is to be sent to the client with the specified clientID, or 'broadcast' if the notification should be sent to all hosts. Default is notificationSendMode::local.
     94            @param sendMode The mode in which the notification is sent, can be 'local' to send the notification to the client where this function is executed, 'network' if the notification is to be sent to the client with the specified clientID, or 'broadcast' if the notification should be sent to all hosts. Default is NotificationSendMode::local.
    10495            @param clientId The id of the client the notification should be sent to. Default is 0.
    10596            */
    106             static void sendNotification(const std::string& message, const std::string& sender = NotificationListener::NONE, notificationMessageType::Value messageType = notificationMessageType::info, notificationSendMode::Value sendMode = notificationSendMode::local, unsigned int clientId = 0)
     97            static void sendNotification(const std::string& message, const std::string& sender = NotificationListener::NONE, NotificationMessageType messageType = NotificationMessageType::info, NotificationSendMode sendMode = NotificationSendMode::local, unsigned int clientId = 0)
    10798                { NotificationListener::sendNetworkHelper(message, sender, sendMode, clientId, false, messageType); }
    10899            /**
     
    110101            @param command The command that should be sent (and later executed).
    111102            @param sender The sender that sent the notification. Default is 'none'.
    112             @param sendMode The mode in which the command is sent, can be 'local' to send the command to the client where this function is executed, 'network' if the command is to be sent to the client with the specified clientID, or 'broadcast' if the command should be sent to all hosts. Default is notificationSendMode::local.
     103            @param sendMode The mode in which the command is sent, can be 'local' to send the command to the client where this function is executed, 'network' if the command is to be sent to the client with the specified clientID, or 'broadcast' if the command should be sent to all hosts. Default is NotificationSendMode::local.
    113104            @param clientId The id of the client the command should be sent to. Default is 0.
    114105            */
    115             static void sendCommand(const std::string& command, const std::string& sender = NotificationListener::NONE, notificationSendMode::Value sendMode = notificationSendMode::local, unsigned int clientId = 0)
     106            static void sendCommand(const std::string& command, const std::string& sender = NotificationListener::NONE, NotificationSendMode sendMode = NotificationSendMode::local, unsigned int clientId = 0)
    116107                { NotificationListener::sendNetworkHelper(command, sender, sendMode, clientId, true); }
    117108
    118             static void sendHelper(const std::string& message, const std::string& sender, bool isCommand = false, unsigned int messageMode = 0); // Helper method to register a notification/execute a command with all NotificationListeners after it has been sent over the network.
     109            static void sendHelper(const std::string& message, const std::string& sender, bool isCommand, NotificationMessageType type); // Helper method to register a notification/execute a command with all NotificationListeners after it has been sent over the network.
    119110
    120111            //TODO: Make protected?
     
    128119            @return Returns true if the notification was successfully registered, false if not.
    129120            */
    130             virtual bool registerNotification(const std::string& message, const std::string& sender, notificationMessageType::Value type)
     121            virtual bool registerNotification(const std::string& message, const std::string& sender, NotificationMessageType type)
    131122                { return false; }
    132123            /**
     
    137128            @return Returns true if the command was successfully executed, false if not.
    138129            */
    139             virtual bool executeCommand(notificationCommand::Value command, const std::string& sender) { return false; }
     130            virtual bool executeCommand(NotificationCommand command, const std::string& sender) { return false; }
    140131
    141132        public:
     
    149140           
    150141        protected:
    151             static void sendNetworkHelper(const std::string& message, const std::string& sender, notificationSendMode::Value sendMode, unsigned int clientId, bool isCommand = false, notificationMessageType::Value messageType = notificationMessageType::info); // Helper method to send both notifications and commands over the network.
     142            static void sendNetworkHelper(const std::string& message, const std::string& sender, NotificationSendMode sendMode, unsigned int clientId, bool isCommand = false, NotificationMessageType messageType = NotificationMessageType::info); // Helper method to send both notifications and commands over the network.
    152143
    153             static notificationCommand::Value str2Command(const std::string& string); // Helper method. Converts a string into the enum for a command.
    154             static const std::string& command2Str(notificationCommand::Value command); // Helper method. Converts a command enum into its corresponding string.
     144            static NotificationCommand str2Command(const std::string& string); // Helper method. Converts a string into the enum for a command.
     145            static const std::string& command2Str(NotificationCommand command); // Helper method. Converts a command enum into its corresponding string.
    155146    };
    156147}
  • code/trunk/src/orxonox/interfaces/PickupCarrier.cc

    r10624 r11071  
    101101        // Go recursively through all children to check whether they are a target.
    102102        std::vector<PickupCarrier*>* children = this->getCarrierChildren();
    103         for(std::vector<PickupCarrier*>::const_iterator it = children->begin(); it != children->end(); it++)
     103        for(PickupCarrier* carrier : *children)
    104104        {
    105             if((*it)->isTarget(pickup))
     105            if(carrier->isTarget(pickup))
    106106            {
    107107                isTarget = true;
     
    127127    {
    128128        if(!this->isTarget(pickup))
    129             return NULL;
     129            return nullptr;
    130130
    131131        if(pickup->isTarget(this)) // If the PickupCarrier itself is a target.
    132132            return this;
    133133
    134         PickupCarrier* target = NULL;
     134        PickupCarrier* target = nullptr;
    135135        // Go recursively through all children to check whether they are the target.
    136136        std::vector<PickupCarrier*>* children = this->getCarrierChildren();
    137         for(std::vector<PickupCarrier*>::iterator it = children->begin(); it != children->end(); it++)
     137        for(PickupCarrier* child : *children)
    138138        {
    139             if(pickup->isTarget(*it))
     139            if(pickup->isTarget(child))
    140140            {
    141                 target = *it;
     141                target = child;
    142142                break;
    143143            }
  • code/trunk/src/orxonox/interfaces/PickupCarrier.h

    r9667 r11071  
    5959        But this structure has to be established first.
    6060        - <b>getCarrierChildren()</b> To this end a PickupCarrier needs to implement getCarrierChildren() which returns a list of its direct PickupCarrier children. If you need an example, have a look at @ref orxonox::Pawn "Pawn" and @ref orxonox::Engine "Engine".
    61         - <b>getCarrierParent()</b> This is the method in the other direction. It returns the parent of this PickupCarrier, or NULL if the PickupCarrier is a root node in this hierarchy.
     61        - <b>getCarrierParent()</b> This is the method in the other direction. It returns the parent of this PickupCarrier, or nullptr if the PickupCarrier is a root node in this hierarchy.
    6262
    6363    @author
     
    7777            PickupCarrier(); //!< Constructor.
    7878            virtual ~PickupCarrier(); //!< Destructor.
    79             void preDestroy(void); //!< Is called before the PickupCarrier is effectively destroyed.
     79            virtual void preDestroy(void) override; //!< Is called before the PickupCarrier is effectively destroyed.
    8080
    8181            bool isTarget(const Pickupable* pickup) const; //!< Can be used to check whether the PickupCarrier or a child of his is a target ot the input Pickupable.
  • code/trunk/src/orxonox/interfaces/PickupListener.cc

    r10624 r11071  
    7474
    7575        // Iterate through all PickupListeners and notify them by calling the method they overloaded.
    76         for(ObjectList<PickupListener>::iterator it = ObjectList<PickupListener>::begin(); it != ObjectList<PickupListener>::end(); ++it)
    77             it->pickupChangedUsed(pickup, used);
     76        for(PickupListener* listener : ObjectList<PickupListener>())
     77            listener->pickupChangedUsed(pickup, used);
    7878    }
    7979
     
    9292
    9393        // Iterate through all PickupListeners and notify them by calling the method they overloaded.
    94         for(ObjectList<PickupListener>::iterator it = ObjectList<PickupListener>::begin(); it != ObjectList<PickupListener>::end(); ++it)
    95             it->pickupChangedPickedUp(pickup, pickedUp);
     94        for(PickupListener* listener : ObjectList<PickupListener>())
     95            listener->pickupChangedPickedUp(pickup, pickedUp);
    9696    }
    9797
  • code/trunk/src/orxonox/interfaces/Pickupable.cc

    r10624 r11071  
    5656        RegisterObject(Pickupable);
    5757
    58         this->carrier_ = NULL;
     58        this->carrier_ = nullptr;
    5959
    6060        this->beingDestroyed_ = false;
     
    143143    bool Pickupable::isTarget(const PickupCarrier* carrier) const
    144144    {
    145         if(carrier == NULL)
     145        if(carrier == nullptr)
    146146            return false;
    147147
     
    160160    {
    161161        // Iterate through all targets of this Pickupable.
    162         for(std::list<Identifier*>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); it++)
     162        for(Identifier* target : this->targets_)
    163163        {
    164             if(identifier->isA(*it))
     164            if(identifier->isA(target))
    165165                return true;
    166166        }
     
    210210    bool Pickupable::pickup(PickupCarrier* carrier)
    211211    {
    212         if(carrier == NULL || this->isPickedUp()) // If carrier is NULL or the Pickupable is already picked up.
     212        if(carrier == nullptr || this->isPickedUp()) // If carrier is nullptr or the Pickupable is already picked up.
    213213            return false;
    214214
     
    237237            return false;
    238238
    239         assert(this->getCarrier()); // The Carrier cannot be NULL at this point.
     239        assert(this->getCarrier()); // The Carrier cannot be nullptr at this point.
    240240        if(!this->getCarrier()->removePickup(this)) //TODO Shouldn't this be a little later?
    241241            orxout(internal_warning, context::pickups) << "Pickupable (&" << this << ", " << this->getIdentifier()->getName() << ") is being dropped, but it was not present in the PickupCarriers list of pickups." << endl;
     
    249249            created = this->createSpawner();
    250250
    251         this->setCarrier(NULL);
     251        this->setCarrier(nullptr);
    252252
    253253        if(!created && createSpawner) // If a PickupSpawner should have been created but wasn't.
     
    301301        orxout(verbose, context::pickups) << "Pickupable (&" << this << ") changed Carrier (& " << carrier << ")." << endl;
    302302
    303         if(carrier != NULL && tell)
     303        if(carrier != nullptr && tell)
    304304        {
    305305            if(!carrier->addPickup(this))
  • code/trunk/src/orxonox/interfaces/Pickupable.h

    r10624 r11071  
    144144
    145145        protected:
    146             virtual void preDestroy(void); //!< A method that is called by Destroyable::destroy() before the object is actually destroyed.
     146            virtual void preDestroy(void) override; //!< A method that is called by Destroyable::destroy() before the object is actually destroyed.
    147147            virtual void destroyPickup(void); //!< Destroys a Pickupable.
    148148            virtual void carrierDestroyed(void); //!< Is called by the PickupCarrier when it is being destroyed.
     
    182182        // For implementing the Rewardable interface:
    183183        public:
    184             virtual bool reward(PlayerInfo* player); //!< Method to transcribe a Pickupable as a Rewardable to the player.
     184            virtual bool reward(PlayerInfo* player) override; //!< Method to transcribe a Pickupable as a Rewardable to the player.
    185185
    186186    };
  • code/trunk/src/orxonox/interfaces/RadarViewable.cc

    r10624 r11071  
    4949        , wePtr_(wePtr)
    5050        , radarObjectCamouflage_(0.0f)
    51         , radarObjectShape_(Dot)
     51        , radarObjectShape_(Shape::Dot)
    5252        , radarObjectDescription_("staticObject")
    5353        , scale_(1.0f)
  • code/trunk/src/orxonox/interfaces/RadarViewable.h

    r10624 r11071  
    4949    {
    5050    public:
    51         enum Shape
     51        enum class Shape
    5252        {
    5353            Square,
     
    6666                if (name == "HIDDEN")
    6767                {
    68                     this->bVisibility_ = 0;
     68                    this->bVisibility_ = false;
    6969                    this->settingsChanged();
    7070                }
Note: See TracChangeset for help on using the changeset viewer.