Changeset 11071 for code/trunk/src/orxonox/interfaces
- Timestamp:
- Jan 17, 2016, 10:29:21 PM (9 years ago)
- Location:
- code/trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/interfaces/NotificationListener.cc
r10624 r11071 74 74 The type of the notification, can be either 'info' or 'important'. 75 75 */ 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) 77 77 { 78 78 // 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)) 80 80 { 81 81 sendHelper(message, sender, isCommand, messageType); 82 82 } 83 83 // 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) 85 85 { 86 callStaticNetworkFunction(&NotificationListener::sendHelper, clientId, message, sender, isCommand, (unsigned int)messageType);86 callStaticNetworkFunction(&NotificationListener::sendHelper, clientId, message, sender, isCommand, messageType); 87 87 } 88 else if(GameMode::isServer() && sendMode == notificationSendMode::broadcast)88 else if(GameMode::isServer() && sendMode == NotificationSendMode::broadcast) 89 89 { 90 90 // 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); 92 92 } 93 93 } … … 105 105 The type of the notification. 106 106 */ 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) 108 108 { 109 109 // 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>()) 111 111 { 112 112 // If the notification is a message. 113 113 if(!isCommand) 114 it->registerNotification(message, sender, notificationMessageType::Value(messageType));114 listener->registerNotification(message, sender, type); 115 115 116 116 // If the notification is a command. 117 117 if(isCommand) 118 118 { 119 notificationCommand::Valuecommand = 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); 122 122 } 123 123 } … … 130 130 The string to be converted. 131 131 @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. 133 133 */ 134 /*static*/ notificationCommand::ValueNotificationListener::str2Command(const std::string& string)134 /*static*/ NotificationCommand NotificationListener::str2Command(const std::string& string) 135 135 { 136 notificationCommand::Value command = notificationCommand::none;136 NotificationCommand command = NotificationCommand::none; 137 137 138 138 if(string == NotificationListener::COMMAND_CLEAR) 139 command = notificationCommand::clear;139 command = NotificationCommand::clear; 140 140 141 141 return command; … … 150 150 Returns the corresponding string. 151 151 */ 152 /*static*/ const std::string& NotificationListener::command2Str( notificationCommand::Valuecommand)152 /*static*/ const std::string& NotificationListener::command2Str(NotificationCommand command) 153 153 { 154 154 switch(command) 155 155 { 156 case notificationCommand::clear:156 case NotificationCommand::clear: 157 157 return NotificationListener::COMMAND_CLEAR; 158 158 default: -
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 } -
code/trunk/src/orxonox/interfaces/PickupCarrier.cc
r10624 r11071 101 101 // Go recursively through all children to check whether they are a target. 102 102 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) 104 104 { 105 if( (*it)->isTarget(pickup))105 if(carrier->isTarget(pickup)) 106 106 { 107 107 isTarget = true; … … 127 127 { 128 128 if(!this->isTarget(pickup)) 129 return NULL;129 return nullptr; 130 130 131 131 if(pickup->isTarget(this)) // If the PickupCarrier itself is a target. 132 132 return this; 133 133 134 PickupCarrier* target = NULL;134 PickupCarrier* target = nullptr; 135 135 // Go recursively through all children to check whether they are the target. 136 136 std::vector<PickupCarrier*>* children = this->getCarrierChildren(); 137 for( std::vector<PickupCarrier*>::iterator it = children->begin(); it != children->end(); it++)137 for(PickupCarrier* child : *children) 138 138 { 139 if(pickup->isTarget( *it))139 if(pickup->isTarget(child)) 140 140 { 141 target = *it;141 target = child; 142 142 break; 143 143 } -
code/trunk/src/orxonox/interfaces/PickupCarrier.h
r9667 r11071 59 59 But this structure has to be established first. 60 60 - <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 NULLif 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. 62 62 63 63 @author … … 77 77 PickupCarrier(); //!< Constructor. 78 78 virtual ~PickupCarrier(); //!< Destructor. 79 v oid preDestroy(void); //!< Is called before the PickupCarrier is effectively destroyed.79 virtual void preDestroy(void) override; //!< Is called before the PickupCarrier is effectively destroyed. 80 80 81 81 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 74 74 75 75 // 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); 78 78 } 79 79 … … 92 92 93 93 // 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); 96 96 } 97 97 -
code/trunk/src/orxonox/interfaces/Pickupable.cc
r10624 r11071 56 56 RegisterObject(Pickupable); 57 57 58 this->carrier_ = NULL;58 this->carrier_ = nullptr; 59 59 60 60 this->beingDestroyed_ = false; … … 143 143 bool Pickupable::isTarget(const PickupCarrier* carrier) const 144 144 { 145 if(carrier == NULL)145 if(carrier == nullptr) 146 146 return false; 147 147 … … 160 160 { 161 161 // 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_) 163 163 { 164 if(identifier->isA( *it))164 if(identifier->isA(target)) 165 165 return true; 166 166 } … … 210 210 bool Pickupable::pickup(PickupCarrier* carrier) 211 211 { 212 if(carrier == NULL || this->isPickedUp()) // If carrier is NULLor the Pickupable is already picked up.212 if(carrier == nullptr || this->isPickedUp()) // If carrier is nullptr or the Pickupable is already picked up. 213 213 return false; 214 214 … … 237 237 return false; 238 238 239 assert(this->getCarrier()); // The Carrier cannot be NULLat this point.239 assert(this->getCarrier()); // The Carrier cannot be nullptr at this point. 240 240 if(!this->getCarrier()->removePickup(this)) //TODO Shouldn't this be a little later? 241 241 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; … … 249 249 created = this->createSpawner(); 250 250 251 this->setCarrier( NULL);251 this->setCarrier(nullptr); 252 252 253 253 if(!created && createSpawner) // If a PickupSpawner should have been created but wasn't. … … 301 301 orxout(verbose, context::pickups) << "Pickupable (&" << this << ") changed Carrier (& " << carrier << ")." << endl; 302 302 303 if(carrier != NULL&& tell)303 if(carrier != nullptr && tell) 304 304 { 305 305 if(!carrier->addPickup(this)) -
code/trunk/src/orxonox/interfaces/Pickupable.h
r10624 r11071 144 144 145 145 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. 147 147 virtual void destroyPickup(void); //!< Destroys a Pickupable. 148 148 virtual void carrierDestroyed(void); //!< Is called by the PickupCarrier when it is being destroyed. … … 182 182 // For implementing the Rewardable interface: 183 183 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. 185 185 186 186 }; -
code/trunk/src/orxonox/interfaces/RadarViewable.cc
r10624 r11071 49 49 , wePtr_(wePtr) 50 50 , radarObjectCamouflage_(0.0f) 51 , radarObjectShape_( Dot)51 , radarObjectShape_(Shape::Dot) 52 52 , radarObjectDescription_("staticObject") 53 53 , scale_(1.0f) -
code/trunk/src/orxonox/interfaces/RadarViewable.h
r10624 r11071 49 49 { 50 50 public: 51 enum Shape51 enum class Shape 52 52 { 53 53 Square, … … 66 66 if (name == "HIDDEN") 67 67 { 68 this->bVisibility_ = 0;68 this->bVisibility_ = false; 69 69 this->settingsChanged(); 70 70 }
Note: See TracChangeset
for help on using the changeset viewer.