Changeset 8448 for code/branches/tutoriallevel2/src/orxonox
- Timestamp:
- May 11, 2011, 10:45:56 PM (14 years ago)
- Location:
- code/branches/tutoriallevel2/src/orxonox/interfaces
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/tutoriallevel2/src/orxonox/interfaces/NotificationListener.cc
r8445 r8448 47 47 // Commands 48 48 /*static*/ const std::string NotificationListener::COMMAND_CLEAR("clear"); 49 /*static*/ const std::string NotificationListener::COMMAND_NONE("none"); 49 50 50 51 registerStaticNetworkFunction(NotificationListener::sendHelper); … … 108 109 { 109 110 // 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)); 112 113 113 114 // If the notification is a command. … … 115 116 { 116 117 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); 119 120 } 120 121 } … … 138 139 return command; 139 140 } 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 } 140 160 141 161 } -
code/branches/tutoriallevel2/src/orxonox/interfaces/NotificationListener.h
r8445 r8448 108 108 /** 109 109 @brief Sends a specified command to the specified client from the specified sender. 110 @param messageThe command that should be sent (and later executed).110 @param command The command that should be sent (and later executed). 111 111 @param sender The sender that sent the notification. Default is 'none'. 112 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. … … 138 138 */ 139 139 virtual bool executeCommand(notificationCommand::Value command, const std::string& sender) { return false; } 140 141 public: 140 142 141 143 static const std::string ALL; //!< Static string to indicate a sender that sends to all NotificationQueues. … … 144 146 //! Commands 145 147 static const std::string COMMAND_CLEAR; 148 static const std::string COMMAND_NONE; 146 149 147 150 protected: 148 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. 149 152 150 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. 151 155 }; 152 156 }
Note: See TracChangeset
for help on using the changeset viewer.