Changeset 10765 for code/branches/cpp11_v2/src/modules/objects/triggers
- Timestamp:
- Nov 4, 2015, 10:25:42 PM (9 years ago)
- Location:
- code/branches/cpp11_v2/src/modules/objects/triggers
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/modules/objects/triggers/DistanceMultiTrigger.cc
r10624 r10765 97 97 { 98 98 99 std::queue<MultiTriggerState*>* queue = NULL;99 std::queue<MultiTriggerState*>* queue = nullptr; 100 100 101 101 // Check for objects that were in range but no longer are. Iterate through all objects, that are in range. … … 105 105 106 106 // If the entity no longer exists. 107 if(entity == NULL)107 if(entity == nullptr) 108 108 { 109 109 this->range_.erase(it++); … … 118 118 119 119 // If no queue has been created, yet. 120 if(queue == NULL)120 if(queue == nullptr) 121 121 queue = new std::queue<MultiTriggerState*>(); 122 122 … … 186 186 187 187 // If no queue has been created, yet. 188 if(queue == NULL)188 if(queue == nullptr) 189 189 queue = new std::queue<MultiTriggerState*>(); 190 190 -
code/branches/cpp11_v2/src/modules/objects/triggers/DistanceTrigger.cc
r10624 r10765 106 106 this->setForPlayer(true); 107 107 108 if (targetId == NULL)108 if (targetId == nullptr) 109 109 { 110 110 orxout(internal_error, context::triggers) << "\"" << targetStr << "\" is not a valid class name to include in ClassTreeMask (in " << this->getName() << ", class " << this->getIdentifier()->getName() << ')' << endl; … … 147 147 { 148 148 // Check whether there is a cached object, it still exists and whether it is still in range, if so nothing further needs to be done. 149 if(this->cache_ != NULL)149 if(this->cache_ != nullptr) 150 150 { 151 151 if((this->cache_->getWorldPosition() - this->getWorldPosition()).length() < this->distance_) … … 206 206 207 207 Pawn* pawn = orxonox_cast<Pawn*>(entity); 208 if(pawn != NULL)208 if(pawn != nullptr) 209 209 this->setTriggeringPawn(pawn); 210 210 else 211 orxout(internal_warning, context::triggers) << "Pawn was NULL." << endl;211 orxout(internal_warning, context::triggers) << "Pawn was nullptr." << endl; 212 212 } 213 213 -
code/branches/cpp11_v2/src/modules/objects/triggers/EventMultiTrigger.cc
r9667 r10765 96 96 { 97 97 // If the originator is a MultiTriggerContainer, the event originates from a MultiTrigger and thus the event only triggers the EventMultiTrigger for the originator that caused the MultiTrigger to trigger. 98 if(originator != NULL&& originator->isA(ClassIdentifier<MultiTriggerContainer>::getIdentifier()))98 if(originator != nullptr && originator->isA(ClassIdentifier<MultiTriggerContainer>::getIdentifier())) 99 99 { 100 100 MultiTriggerContainer* container = static_cast<MultiTriggerContainer*>(originator); -
code/branches/cpp11_v2/src/modules/objects/triggers/MultiTrigger.cc
r9667 r10765 124 124 // Let the MultiTrigger return the states that trigger and process the new states if there are any. 125 125 std::queue<MultiTriggerState*>* queue = this->letTrigger(); 126 if(queue != NULL)126 if(queue != nullptr) 127 127 { 128 128 while(queue->size() > 0) 129 129 { 130 130 MultiTriggerState* state = queue->front(); 131 // If the state is NULL. (This really shouldn't happen)132 if(state == NULL)131 // If the state is nullptr. (This really shouldn't happen) 132 if(state == nullptr) 133 133 { 134 orxout(internal_error, context::triggers) << "In MultiTrigger '" << this->getName() << "' (&" << this << "), Error: State of new states queue was NULL. State ignored." << endl;134 orxout(internal_error, context::triggers) << "In MultiTrigger '" << this->getName() << "' (&" << this << "), Error: State of new states queue was nullptr. State ignored." << endl; 135 135 queue->pop(); 136 136 continue; … … 227 227 { 228 228 // If the MultiTrigger is set to broadcast and has no originator a boradcast is fired. 229 if(this->getBroadcast() && state->originator == NULL)229 if(this->getBroadcast() && state->originator == nullptr) 230 230 this->broadcast(bActive); 231 231 // Else a normal event is fired. … … 240 240 { 241 241 // Print some debug output if the state has changed. 242 if(state->originator != NULL)242 if(state->originator != nullptr) 243 243 orxout(verbose, context::triggers) << "MultiTrigger '" << this->getName() << "' (&" << this << ") changed state. originator: " << state->originator->getIdentifier()->getName() << " (&" << state->originator << "), active: " << bActive << ", triggered: " << state->bTriggered << "." << endl; 244 244 else 245 orxout(verbose, context::triggers) << "MultiTrigger '" << this->getName() << "' (&" << this << ") changed state. originator: NULL, active: " << bActive << ", triggered: " << state->bTriggered << "." << endl;245 orxout(verbose, context::triggers) << "MultiTrigger '" << this->getName() << "' (&" << this << ") changed state. originator: nullptr, active: " << bActive << ", triggered: " << state->bTriggered << "." << endl; 246 246 247 247 // If the MultiTrigger has a parent trigger, that is itself a MultiTrigger, it needs to call a method to notify him, that its activity has changed. 248 if(this->parent_ != NULL&& this->parent_->isMultiTrigger())248 if(this->parent_ != nullptr && this->parent_->isMultiTrigger()) 249 249 static_cast<MultiTrigger*>(this->parent_)->childActivityChanged(state->originator); 250 250 } … … 299 299 300 300 // If the target is not a valid class name display an error. 301 if (target == NULL)301 if (target == nullptr) 302 302 { 303 303 orxout(internal_error, context::triggers) << "'" << targetStr << "' is not a valid class name to include in ClassTreeMask (in " << this->getName() << ", class " << this->getIdentifier()->getName() << ")" << endl; … … 327 327 328 328 // If the target is not a valid class name display an error. 329 if (target == NULL)329 if (target == nullptr) 330 330 { 331 331 orxout(internal_error, context::triggers) << "'" << targetStr << "' is not a valid class name to include in ClassTreeMask (in " << this->getName() << ", class " << this->getIdentifier()->getName() << ")" << endl; … … 346 346 std::queue<MultiTriggerState*>* MultiTrigger::letTrigger(void) 347 347 { 348 return NULL;348 return nullptr; 349 349 } 350 350 … … 443 443 void MultiTrigger::fire(bool status, BaseObject* originator) 444 444 { 445 // If the originator is NULL, a normal event without MultiTriggerContainer is sent.446 if(originator == NULL)445 // If the originator is nullptr, a normal event without MultiTriggerContainer is sent. 446 if(originator == nullptr) 447 447 { 448 448 this->fireEvent(status); … … 479 479 bool MultiTrigger::addState(MultiTriggerState* state) 480 480 { 481 assert(state); // The state really shouldn't be NULL.481 assert(state); // The state really shouldn't be nullptr. 482 482 483 483 // If the originator is no target of this MultiTrigger. -
code/branches/cpp11_v2/src/modules/objects/triggers/MultiTrigger.h
r9667 r10765 76 76 - @b simultaneousTriggerers The number of simultaneous triggerers limits the number of objects that are allowed to trigger the MultiTrigger at the same time. Or more precisely, the number of distinct objects the MultiTrigger has <em>triggered</em> states for, at each point in time. The default is <code>-1</code>, which denotes infinity. 77 77 - @b mode The mode describes how the MultiTrigger acts in relation to all the triggers, that are appended to it. There are 3 modes: <em>and</em>, meaning that the MultiTrigger can only be triggered if all the appended triggers are active. <em>or</em>, meaning that the MultiTrigger can only triggered if at least one of the appended triggers is active. And <em>xor</em>, meaning that the MultiTrigger can only be triggered if one and only one appended trigger is active. Note, that I wrote <em>can only be active</em>, that implies, that there is an additional condition to the <em>activity</em> of the MultiTrigger and that is the fulfillment of the triggering condition (the MultiTrigger itself doesn't have one, but all derived classes should). Also bear in mind, that the <em>activity</em> of a MultiTrigger is still coupled to the object that triggered it. The default is <em>and</em>. 78 - @b broadcast Broadcast is a boolean, if true the MutliTrigger is in <em>broadcast-mode</em>, meaning, that all trigger events that are caused by no originator (originator is NULL) are broadcast as having come from every possible originator, or more precisely as having come from all objects that are specified targets of this MultiTrigger. The default is false.78 - @b broadcast Broadcast is a boolean, if true the MutliTrigger is in <em>broadcast-mode</em>, meaning, that all trigger events that are caused by no originator (originator is nullptr) are broadcast as having come from every possible originator, or more precisely as having come from all objects that are specified targets of this MultiTrigger. The default is false. 79 79 - @b target The target describes the kind of objects that are allowed to trigger this MultiTrigger. The default is @ref orxonox::Pawn "Pawn". 80 80 - Also there is the possibility of appending triggers (as long as they inherit from TriggerBase) to the MultiTrigger just by adding them as children in the XML description of your MultiTrigger. … … 110 110 */ 111 111 inline bool isActive(void) const 112 { return this->isActive( NULL); }113 bool isActive(BaseObject* triggerer = NULL) const; //!< Check whether the MultiTrigger is active for a given object.112 { return this->isActive(nullptr); } 113 bool isActive(BaseObject* triggerer = nullptr) const; //!< Check whether the MultiTrigger is active for a given object. 114 114 115 115 /** … … 145 145 */ 146 146 inline bool isTarget(BaseObject* target) 147 { if(target == NULL) return true; else return targetMask_.isIncluded(target->getIdentifier()); }147 { if(target == nullptr) return true; else return targetMask_.isIncluded(target->getIdentifier()); } 148 148 149 149 void addTarget(const std::string& targets); //!< Add some target to the MultiTrigger. … … 152 152 virtual std::queue<MultiTriggerState*>* letTrigger(void); //!< This method is called by the MultiTrigger to get information about new trigger events that need to be looked at. 153 153 154 void changeTriggered(BaseObject* originator = NULL); //!< This method can be called by any class inheriting from MultiTrigger to change it's triggered status for a specified originator.155 156 bool isModeTriggered(BaseObject* triggerer = NULL); //!< Checks whether the MultiTrigger is triggered concerning it's children.157 bool isTriggered(BaseObject* triggerer = NULL); //!< Get whether the MultiTrigger is triggered for a given object.158 159 virtual void fire(bool status, BaseObject* originator = NULL); //!< Helper method. Creates an Event for the given status and originator and fires it.154 void changeTriggered(BaseObject* originator = nullptr); //!< This method can be called by any class inheriting from MultiTrigger to change it's triggered status for a specified originator. 155 156 bool isModeTriggered(BaseObject* triggerer = nullptr); //!< Checks whether the MultiTrigger is triggered concerning it's children. 157 bool isTriggered(BaseObject* triggerer = nullptr); //!< Get whether the MultiTrigger is triggered for a given object. 158 159 virtual void fire(bool status, BaseObject* originator = nullptr); //!< Helper method. Creates an Event for the given status and originator and fires it. 160 160 void broadcast(bool status); //!< Helper method. Broadcasts an Event for every object that is a target. 161 161 -
code/branches/cpp11_v2/src/modules/objects/triggers/MultiTriggerContainer.cc
r9667 r10765 50 50 The creator. 51 51 */ 52 MultiTriggerContainer::MultiTriggerContainer(Context* context) : BaseObject(context), originator_( NULL), data_(NULL)52 MultiTriggerContainer::MultiTriggerContainer(Context* context) : BaseObject(context), originator_(nullptr), data_(nullptr) 53 53 { 54 54 RegisterObject(MultiTriggerContainer); … … 70 70 71 71 Pawn* pawn = orxonox_cast<Pawn*>(data); 72 if(pawn != NULL)72 if(pawn != nullptr) 73 73 { 74 74 this->setForPlayer(true); -
code/branches/cpp11_v2/src/modules/objects/triggers/TriggerBase.cc
r9667 r10765 67 67 this->mode_ = TriggerMode::EventTriggerAND; 68 68 69 this->parent_ = NULL;69 this->parent_ = nullptr; 70 70 71 71 this->bMultiTrigger_ = false; … … 170 170 The index. 171 171 @return 172 Returns a pointer ot the trigger. NULLif no such trigger exists.172 Returns a pointer ot the trigger. nullptr if no such trigger exists. 173 173 */ 174 174 const TriggerBase* TriggerBase::getTrigger(unsigned int index) const … … 176 176 // If the index is greater than the number of children. 177 177 if (this->children_.size() <= index) 178 return NULL;178 return nullptr; 179 179 180 180 std::set<TriggerBase*>::const_iterator it;
Note: See TracChangeset
for help on using the changeset viewer.