Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 11, 2011, 10:45:56 PM (14 years ago)
Author:
dafrick
Message:

Extending NotificationQueueCEGUI.

Location:
code/branches/tutoriallevel2/src/orxonox/interfaces
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/tutoriallevel2/src/orxonox/interfaces/NotificationListener.cc

    r8445 r8448  
    4747    // Commands
    4848    /*static*/ const std::string NotificationListener::COMMAND_CLEAR("clear");
     49    /*static*/ const std::string NotificationListener::COMMAND_NONE("none");
    4950   
    5051    registerStaticNetworkFunction(NotificationListener::sendHelper);
     
    108109        {
    109110            // If the notification is a message.
    110             if(!isCommand && it->registerNotification(message, sender, notificationMessageType::Value(messageType)))
    111                 COUT(3) << "Notification \"" << message << "\" sent." << std::endl;
     111            if(!isCommand)
     112                it->registerNotification(message, sender, notificationMessageType::Value(messageType));
    112113
    113114            // If the notification is a command.
     
    115116            {
    116117                notificationCommand::Value command = str2Command(message);
    117                 if(command != notificationCommand::none && it->executeCommand(command, sender))
    118                     COUT(3) << "Command \"" << message << "\" executed." << std::endl;
     118                if(command != notificationCommand::none)
     119                    it->executeCommand(command, sender);
    119120            }
    120121        }
     
    138139        return command;
    139140    }
     141
     142    /**
     143    @brief
     144        Helper method. Converts a command enum into its corresponding string.
     145    @param command
     146        The command to be converted.
     147    @return
     148        Returns the corresponding string.
     149    */
     150    /*static*/ const std::string& NotificationListener::command2Str(notificationCommand::Value command)
     151    {
     152        switch(command)
     153        {
     154            case notificationCommand::clear:
     155                return NotificationListener::COMMAND_CLEAR;
     156            default:
     157                return NotificationListener::COMMAND_NONE;
     158        }
     159    }
    140160   
    141161}
  • code/branches/tutoriallevel2/src/orxonox/interfaces/NotificationListener.h

    r8445 r8448  
    108108            /**
    109109            @brief Sends a specified command to the specified client from the specified sender.
    110             @param message The command that should be sent (and later executed).
     110            @param command The command that should be sent (and later executed).
    111111            @param sender The sender that sent the notification. Default is 'none'.
    112112            @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.
     
    138138            */
    139139            virtual bool executeCommand(notificationCommand::Value command, const std::string& sender) { return false; }
     140
     141        public:
    140142           
    141143            static const std::string ALL; //!< Static string to indicate a sender that sends to all NotificationQueues.
     
    144146            //! Commands
    145147            static const std::string COMMAND_CLEAR;
     148            static const std::string COMMAND_NONE;
    146149           
    147150        protected:
    148151            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.
    149            
     152
    150153            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.
    151155    };
    152156}
Note: See TracChangeset for help on using the changeset viewer.