- Timestamp:
- Jan 17, 2016, 10:29:21 PM (8 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/interfaces/NotificationListener.h
r9667 r11071 49 49 { 50 50 // TODO: Document. 51 namespace notificationMessageType 52 { 53 enum Value { 54 info, 55 important 56 }; 57 } 51 enum class NotificationMessageType { 52 info, 53 important 54 }; 58 55 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 }; 67 61 68 namespace notificationCommand 69 { 70 enum Value { 71 none, 72 clear 73 }; 74 } 62 enum class NotificationCommand { 63 none, 64 clear 65 }; 75 66 76 67 // TODO: Update doc. … … 101 92 @param sender The sender that sent the notification. Default is 'none'. 102 93 @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. 104 95 @param clientId The id of the client the notification should be sent to. Default is 0. 105 96 */ 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) 107 98 { NotificationListener::sendNetworkHelper(message, sender, sendMode, clientId, false, messageType); } 108 99 /** … … 110 101 @param command The command that should be sent (and later executed). 111 102 @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. 113 104 @param clientId The id of the client the command should be sent to. Default is 0. 114 105 */ 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) 116 107 { NotificationListener::sendNetworkHelper(command, sender, sendMode, clientId, true); } 117 108 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. 119 110 120 111 //TODO: Make protected? … … 128 119 @return Returns true if the notification was successfully registered, false if not. 129 120 */ 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) 131 122 { return false; } 132 123 /** … … 137 128 @return Returns true if the command was successfully executed, false if not. 138 129 */ 139 virtual bool executeCommand( notificationCommand::Valuecommand, const std::string& sender) { return false; }130 virtual bool executeCommand(NotificationCommand command, const std::string& sender) { return false; } 140 131 141 132 public: … … 149 140 150 141 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. 152 143 153 static notificationCommand::Valuestr2Command(const std::string& string); // Helper method. Converts a string into the enum for a command.154 static const std::string& command2Str( notificationCommand::Valuecommand); // 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. 155 146 }; 156 147 }
Note: See TracChangeset
for help on using the changeset viewer.