Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7301


Ignore:
Timestamp:
Aug 31, 2010, 11:31:37 PM (14 years ago)
Author:
dafrick
Message:

Improving documentation for MultiTriggers, also some small bugfixes, simplifications and added features.

Location:
code/trunk/src
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/libraries/core/EventIncludes.h

    r7284 r7301  
    5353    XMLPortEventStateIntern(xmlportevent##function, classname, statename, xmlelement, mode)
    5454
     55/**
     56    @brief Like XMLPortEventState but creates an event sink instead of an event state.
     57           The most important destinction between an EventState and an EventSink is, that an EventState only processes events which change the state of the EventState, where as an EventSink is an EventState that processes any Event that reaches it.
     58*/
     59
    5560#define XMLPortEventSink(classname, subclassname, statename, function, xmlelement, mode) \
    5661    orxonox::EventState* containername##function = this->getEventState(statename); \
     
    6267    XMLPortEventStateIntern(xmlportevent##function, classname, statename, xmlelement, mode)
    6368
    64 /**
    65     @brief Like XMLPortEventState but creates an event sink instead of an event state.
    66            The most important destinction between an EventState and an EventSink is, that an EventState only processes event which change the state of the EventState, where as an EventSink is an EventState that processes any Event that reaches it.
    67 */
     69
    6870#define XMLPortEventStateTemplate(classname, subclassname, statename, function, xmlelement, mode, ...) \
    6971    orxonox::EventState* containername##function = this->getEventState(statename); \
  • code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc

    r7163 r7301  
    6262    DistanceMultiTrigger::~DistanceMultiTrigger()
    6363    {
     64
    6465    }
    6566
     
    8182
    8283        In this implementation we iterate through all possible objects and check whether the fact that they are in range or not has changed and fire and hand a state ofer to the MultiTrigger if so.
     84    @return
     85        Returns a pointer to a queue of MultiTriggerState pointers, containing all the necessary information to decide whether these states should indeed become new states of the MultiTrigger.
    8386    */
    8487    std::queue<MultiTriggerState*>* DistanceMultiTrigger::letTrigger(void)
     
    9295            WorldEntity* entity = it->second->get();
    9396            WorldEntity* key = it->first;
     97            it++; // Incrementing the iterator in advance, since we don't need the current anymore and we potentially are going to delete the current element thus invalidating the iterator.
     98            // If the entity no longer exists.
    9499            if(entity == NULL)
    95100            {
    96                 ++it;
    97101                this->removeFromRange(key);
    98102                continue;
     
    103107            if (distanceVec.length() > this->distance_)
    104108            {
     109                // If for some reason the entity could not be removed.
    105110                if(!this->removeFromRange(key))
    106                 {
    107                     ++it;
    108111                    continue;
    109                 }
    110112
    111113                // If no queue has been created, yet.
     
    115117                // Create a state and append it to the queue.
    116118                MultiTriggerState* state = new MultiTriggerState;
    117                 state->bTriggered = false;
     119                state->bTriggered = false; // Because the entity went out of range.
    118120                state->originator = entity;
    119121                queue->push(state);
    120122            }
    121             else
    122                 ++it;
    123123        }
    124124
    125         ClassTreeMask& targetMask = this->getTargetMask();
    126 
    127125        // Check for new objects that are in range
    128         for(ClassTreeMaskObjectIterator it = targetMask.begin(); it != targetMask.end(); ++it)
     126        for(ClassTreeMaskObjectIterator it = this->getTargetMask().begin(); it != this->getTargetMask().end(); ++it)
    129127        {
    130128            WorldEntity* entity = static_cast<WorldEntity*>(*it);
    131             if (entity == NULL) //If the object is no WorldEntity or is already in range.
    132                 continue;
    133 
    134             // If the DistanceMultiTrigger is in single-target-mode.
     129
     130            // If the DistanceMultiTrigger is in single-target mode.
    135131            if(this->singleTargetMode_)
    136132            {
    137133                // If the object that is a target is no DistanceTriggerBeacon, then the DistanceMultiTrigger can't be in single-target-mode.
    138                 if(!(*it)->isA(ClassIdentifier<DistanceTriggerBeacon>::getIdentifier()))
     134                if(!entity->isA(ClassIdentifier<DistanceTriggerBeacon>::getIdentifier()))
     135                {
    139136                    this->singleTargetMode_ = false;
    140                 // If the target name and the name of the DistancTriggreBeacon don't match.
     137                    COUT(2) << "DistanceMultiTrigger " << this->getName() << " (&" << this <<  ")" << "is in single-target mode but the target is '" << entity->getIdentifier()->getName() << "' instead of DistanceTriggerBeacon. Setting single-target mode to false." << std::endl;
     138                }
     139                // If the target name and the name of the DistancTriggerBeacon don't match.
    141140                else if(entity->getName().compare(this->targetName_) != 0)
    142141                    continue;
     
    148147            {
    149148                // Add the object to the objects that are in range.
     149                // Objects that already are in range are not added twice, because in a map (this->range_) each key can only exist once and thus addToRange() will reject all attempts of duplicate entries.
    150150                if(!this->addToRange(entity))
    151151                    continue;
     
    161161                // Create a state and append it to the queue.
    162162                MultiTriggerState* state = new MultiTriggerState;
    163                 state->bTriggered = true;
     163                state->bTriggered = true; // Because the entity came into range.
    164164                state->originator = entity;
    165165                queue->push(state);
     
    170170    }
    171171
     172    /**
     173    @brief
     174        Set the target name of DistanceTriggerBeacons that triggers this DistanceMultiTrigger.
     175    @param targetname
     176        The name of the DistanceTriggerBeacon as a string.
     177    */
     178    void DistanceMultiTrigger::setTargetName(const std::string& targetname)
     179    {
     180        // If the targetname is no blank string single-target mode is enabled.
     181        if(targetname.compare(BLANKSTRING) != 0)
     182            this->singleTargetMode_ = true;
     183        else
     184            this->singleTargetMode_ = false;
     185
     186        this->targetName_ = targetname;
     187    }
     188
     189    /**
     190    @brief
     191        Add a given entity to the entities, that currently are in range of the DistanceMultiTrigger.
     192    @param entity
     193        A pointer to the entity.
     194    @return
     195        Returns true if successful, false if not.
     196    */
     197    bool DistanceMultiTrigger::addToRange(WorldEntity* entity)
     198    {
     199        WeakPtr<WorldEntity>* weakptr = new WeakPtr<WorldEntity>(entity);
     200        std::pair<std::map<WorldEntity*, WeakPtr<WorldEntity>* >::iterator, bool> pair = this->range_.insert(std::pair<WorldEntity*, WeakPtr<WorldEntity>* >(entity, weakptr));
     201
     202        if(!pair.second)
     203        {
     204            delete weakptr;
     205            return false;
     206        }
     207
     208        return true;
     209    }
     210
     211    /**
     212    @brief
     213        Remove a given entity from the set of entities, that currently are in range of the DistanceMultiTrigger.
     214    @param entity
     215        A pointer ot the entity.
     216    @return
     217        Returns true if successful.
     218    */
     219    bool DistanceMultiTrigger::removeFromRange(WorldEntity* entity)
     220    {
     221        WeakPtr<WorldEntity>* weakptr = this->range_.find(entity)->second;
     222        bool erased = this->range_.erase(entity) > 0;
     223        if(erased)
     224            delete weakptr;
     225        return erased;
     226    }
     227
    172228}
  • code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h

    r7163 r7301  
    4848    /**
    4949    @brief
    50         The DistanceMultiTrigger is a trigger that triggers whenever an object (that is of the specified target type) is in a specified range of the DistanceMultiTrigger. The object can be specified further by adding a DistanceTriggerBeacon (just attaching it) to the objects that can trigger this DistanceMultiTrigger and specify the name of the DistanceTriggerBeacon with the parameter targetname and only objects that hav a DistanceTriggerBeacon with that name attached will trigger the DistanceMultiTrigger.
     50        The DistanceMultiTrigger is a trigger that triggers whenever an object (that is of the specified target type) is in a specified range of the DistanceMultiTrigger. The object can be specified further by adding a DistanceTriggerBeacon (just attaching it) to the objects that can trigger this DistanceMultiTrigger and specify the name of the DistanceTriggerBeacon with the parameter targetname and only objects that have a DistanceTriggerBeacon with that name attached will trigger the DistanceMultiTrigger.
     51        Parameters are (additional to the ones of MultiTrigger):
     52            'distance', which specifies the maximum distance at which the DistanceMultiTrigger still triggers. Default is 100.
     53            'targetname', which, if not left blank, causes the DistancMultiTrigger to be in single-target mode, meaning, that it only reacts to objects that have a DistanceTriggerBeacon (therefore the target has to be set to DistanceTriggerBeacon for it to work), with the name specified by targetname, attached.
     54
     55        A simple DistanceMultiTrigger would look like this:
     56        @code
     57        <DistanceMultiTrigger position="0,0,0" switch="true" target="Pawn" distance="20" />
     58        @endcode
     59
     60        An implementation that only reacts to objects with a DistanceTriggerBeacon attached would look like this:
     61        @code
     62        <DistanceMultiTrigger position="0,0,0" target="DistanceMultiTrigger" targetname="beacon1" distance="30" />
     63        @endcode
     64        This particular DistanceMultiTrigger would only react if an object was in range, that had a DistanceTriggerBeacon with the name 'beacon1' attached.
    5165    @see MultiTrigger.h
    5266        For more information on MultiTriggers.
     
    5973        public:
    6074            DistanceMultiTrigger(BaseObject* creator); //!< Default Constructor. Registers the object and initializes default values.
    61             ~DistanceMultiTrigger(); //!< Destructor.
     75            virtual ~DistanceMultiTrigger(); //!< Destructor.
    6276
    6377            void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a DistanceMultiTrigger object through XML.
    6478
    65             /**
    66             @brief Set the target name of DistanceTriggerBeacons that triggers this DistanceMultiTrigger.
    67             @param targename The name of the DistanceTriggerBeacon as a string.
    68             */
    69             inline void setTargetName(const std::string& targetname)
    70                 { if(targetname.compare(BLANKSTRING) != 0) this->singleTargetMode_ = true; else this->singleTargetMode_ = false; this->targetName_ = targetname; }
     79            void setTargetName(const std::string& targetname); //!< Set the target name of DistanceTriggerBeacons that triggers this DistanceMultiTrigger.
    7180            /**
    7281            @brief Get the target name of the DistanceTriggerbeacon, that triggers this DistanceMultiTrigger.
     
    92101            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.
    93102
    94             /**
    95             @brief Add a given entity to the entities, that currently are in range of the DistanceMultiTrigger.
    96             @param entity A pointer to the entity.
    97             @return Returns true if successful, false if not.
    98             */
    99             inline bool addToRange(WorldEntity* entity)
    100                 { std::pair<std::map<WorldEntity*, WeakPtr<WorldEntity>* >::iterator, bool> pair = this->range_.insert(std::pair<WorldEntity*, WeakPtr<WorldEntity>* >(entity, new WeakPtr<WorldEntity>(entity))); return pair.second; }
    101             /**
    102             @brief Remove a given entity from the set of entities, that currently are in range of the DistanceMultiTrigger.
    103             @param entity A pointer ot the entity.
    104             @return Returns true if successful.
    105             */
    106             inline bool removeFromRange(WorldEntity* entity)
    107                 { WeakPtr<WorldEntity>* weakptr = this->range_.find(entity)->second; bool erased = this->range_.erase(entity) > 0; if(erased) delete weakptr; return erased; }
     103            bool addToRange(WorldEntity* entity); //!< Add a given entity to the entities, that currently are in range of the DistanceMultiTrigger.
     104            bool removeFromRange(WorldEntity* entity); //!< Remove a given entity from the set of entities, that currently are in range of the DistanceMultiTrigger.
    108105
    109106        private:
  • code/trunk/src/modules/objects/triggers/DistanceTrigger.cc

    r7163 r7301  
    129129        continue;
    130130
     131      // If the DistanceTrigger is in single-target mode.
    131132      if(this->singleTargetMode_)
    132133      {
     134        // If the object that is a target is no DistanceTriggerBeacon, then the DistanceTrigger can't be in single-target-mode.
    133135        if(!(*it)->isA(ClassIdentifier<DistanceTriggerBeacon>::getIdentifier()))
     136        {
    134137          this->singleTargetMode_ = false;
     138          COUT(2) << "DistanceTrigger " << this->getName() << " (&" << this <<  ")" << "is in single-target mode but the target is '" << entity->getIdentifier()->getName() << "' instead of DistanceTriggerBeacon. Setting single-target mode to false." << std::endl;
     139        }
     140        // If the target name and the name of the DistancTriggerBeacon don't match.
    135141        else if(entity->getName().compare(this->targetName_) != 0)
    136142          continue;
     
    145151        {
    146152
     153          // Change the entity to the parent of the DistanceTriggerBeacon (if in single-target-mode), which is the entity to which the beacon is attached.
    147154          if(this->singleTargetMode_)
    148155            entity = entity->getParent();
  • code/trunk/src/modules/objects/triggers/DistanceTrigger.h

    r6906 r7301  
    2323 *      Benjamin Knecht
    2424 *   Co-authors:
    25  *      ...
     25 *      Damian 'Mozork' Frick
    2626 *
    2727 */
  • code/trunk/src/modules/objects/triggers/DistanceTriggerBeacon.cc

    r7163 r7301  
    2727*/
    2828
     29/**
     30    @file DistanceTriggerBeacon.cc
     31    @brief Implementation of the DistanceTriggerBeacon class.
     32*/
     33
    2934#include "DistanceTriggerBeacon.h"
    3035
     
    3641    CreateFactory(DistanceTriggerBeacon);
    3742
     43    /**
     44    @brief
     45        Constructor. Registers the object.
     46    @param creator
     47        The creator of this object.
     48    */
    3849    DistanceTriggerBeacon::DistanceTriggerBeacon(BaseObject* creator) : StaticEntity(creator)
    3950    {
  • code/trunk/src/modules/objects/triggers/DistanceTriggerBeacon.h

    r7163 r7301  
    2727*/
    2828
     29/**
     30    @file DistanceTriggerBeacon.h
     31    @brief Definition of the DistanceTriggerBeacon class.
     32*/
     33
    2934#ifndef _DistanceTriggerBeacon_H__
    3035#define _DistanceTriggerBeacon_H__
     
    3742{
    3843
     44    /**
     45    @brief
     46        A DistanceTriggerBeacon can be used together with a DistanceTrigger or a DistanceMultiTrigger to make them only react to specific objects.
     47        This can be done by attaching a DistanceTriggerBeacon to an object, giving it a unique name and setting the targetname in the DistanceTrigger (or DistanceMultiTrigger) to that name and the target to DistanceTriggerBeacon.
     48    @author
     49        Damian 'Mozork' Frick
     50    */
    3951    class _ObjectsExport DistanceTriggerBeacon : public StaticEntity
    4052    {
    4153
    4254        public:
    43 
    44             DistanceTriggerBeacon(BaseObject* creator);
    45             ~DistanceTriggerBeacon() {}
     55            DistanceTriggerBeacon(BaseObject* creator); //!< Constructor.
     56            virtual ~DistanceTriggerBeacon() {} //!< Destructor.
    4657
    4758    };
  • code/trunk/src/modules/objects/triggers/EventMultiTrigger.cc

    r7163 r7301  
    3737#include "core/EventIncludes.h"
    3838#include "core/XMLPort.h"
     39#include "MultiTriggerContainer.h"
    3940
    4041namespace orxonox
     
    4344    CreateFactory(EventMultiTrigger);
    4445
     46    /**
     47    @brief
     48        Constructor. Registers the object.
     49    */
    4550    EventMultiTrigger::EventMultiTrigger(BaseObject* creator) : MultiTrigger(creator)
    4651    {
    4752        RegisterObject(EventMultiTrigger);
    48 
    49         this->bEventTriggered_ = false;
    5053    }
    5154
     55    /**
     56    @brief
     57        Destructor.
     58    */
    5259    EventMultiTrigger::~EventMultiTrigger()
    5360    {
     
    5562    }
    5663
     64    /**
     65    @brief
     66        Method for creating an EventMultiTrigger object through XML.
     67    */
    5768    void EventMultiTrigger::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    5869    {
     
    6273    }
    6374
     75    /**
     76    @brief
     77        Creates an event port.
     78    */
    6479    void EventMultiTrigger::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
    6580    {
     
    6984    }
    7085
     86    /**
     87    @brief
     88        Method that causes the EventMultiTrigger to trigger upon receiving an event.
     89    @param bTriggered
     90        Whether the event is a triggering or an un-triggering event.
     91    @param originator
     92        A pointer to the entity the event originates from.
     93    */
     94    void EventMultiTrigger::trigger(bool bTriggered, BaseObject* originator)
     95    {
     96        // 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.
     97        if(originator != NULL && originator->isA(ClassIdentifier<MultiTriggerContainer>::getIdentifier()))
     98        {
     99            MultiTriggerContainer* container = static_cast<MultiTriggerContainer*>(originator);
     100            // If the entity that triggered the MultiTrigger is no target of this EventMultiTrigger we process it as it weren't an event caused by a MultiTrigger.
     101            // But if it is the EventMultiTrigger only triggers for the entity tha caused the MultiTrigger to trigger.
     102            if(this->isTarget(container->getData()))
     103            {
     104                if(this->isTriggered(container->getData()) ^ bTriggered)
     105                    this->changeTriggered(container->getData());
     106
     107                return;
     108            }
     109        }
     110
     111        // If we don't know who exactly caused the event we just send a broadcast.
     112        if(this->isTriggered() ^ bTriggered)
     113            this->changeTriggered();
     114    }
     115
    71116}
    72117
  • code/trunk/src/modules/objects/triggers/EventMultiTrigger.h

    r7163 r7301  
    4242{
    4343
     44    /**
     45    @brief
     46        The EventMultiTrigger class is the equivalent of the EventTrigger class for MultiTriggers.
     47        Consequentially what it does is it provides a way to have a MultiTrigger triggered by any kinds of events.
     48        Events that are not caused by a MultiTrigger or by a MultiTrigger with an originator that is no target of this EventMultiTrigger are broadcasted to all entities that are the target of this EventMultitrigger. Events that are caused by MultiTriggers with an originator that is a target of this EventMultiTrigger just trigger the EventMultiTrigger for the originator that caused the MultiTrigger to trigger. Thus showing the equivalent behavior to the EventTrigger.
     49
     50        Example:
     51        @code
     52        <EventMultiTrigger invert="true">
     53            <events>
     54                <trigger>
     55                    <MultiTrigger ... />
     56                    <EventListener ... />
     57                </trigger>
     58            </events>
     59        </EventMultiTrigger>
     60        @endcode
     61    @see MultiTrigger.h
     62        For more information on MultiTriggers.
     63    @author
     64        Damian 'Mozork' Frick
     65    */
    4466    class _ObjectsExport EventMultiTrigger : public MultiTrigger
    4567    {
    4668
    4769        public:
    48             EventMultiTrigger(BaseObject* creator);
    49             ~EventMultiTrigger();
     70            EventMultiTrigger(BaseObject* creator); //!< Constructor. Registers the object.
     71            virtual ~EventMultiTrigger(); //!< Destructor.
    5072
    5173            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating an EventMultiTrigger object through XML.
    5274            virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
    5375
    54             inline void trigger(bool bTriggered)
    55                 { this->bEventTriggered_ = bTriggered; this->changeTriggered(); }
     76        private:
     77            void trigger(bool bTriggered, BaseObject* originator); //!< Method that causes the EventMultiTrigger to trigger upon receiving an event.
    5678
    57         private:
    58             bool bEventTriggered_;
    5979    };
    6080
  • code/trunk/src/modules/objects/triggers/MultiTrigger.cc

    r7163 r7301  
    2323 *      Damian 'Mozork' Frick
    2424 *   Co-authors:
    25  *      Benjamin Knecht
     25 *      ...
    2626 *
    2727*/
     
    6767
    6868        this->remainingActivations_ = INF_s;
    69         this->maxNumSimultaniousTriggerers_ = INF_s;
     69        this->maxNumSimultaneousTriggerers_ = INF_s;
    7070
    7171        this->bInvertMode_ = false;
     
    109109        XMLPortParam(MultiTrigger, "stayactive", setStayActive, getStayActive, xmlelement, mode);
    110110        XMLPortParam(MultiTrigger, "activations", setActivations, getActivations, xmlelement, mode);
    111         XMLPortParam(MultiTrigger, "simultaniousTriggerers", setSimultaniousTriggerers, getSimultaniousTriggerers, xmlelement, mode);
     111        XMLPortParam(MultiTrigger, "simultaneousTriggerers", setSimultaneousTriggerers, getSimultaneousTriggerers, xmlelement, mode);
    112112        XMLPortParam(MultiTrigger, "invert", setInvert, getInvert, xmlelement, mode);
    113113        XMLPortParamTemplate(MultiTrigger, "mode", setMode, getModeString, xmlelement, mode, const std::string&);
     
    115115        XMLPortParamLoadOnly(MultiTrigger, "target", addTargets, xmlelement, mode).defaultValues("Pawn"); //TODO: Remove load only
    116116
    117         //TODO: Maybe nicer with explicit subgroup, e.g. triggers
    118117        XMLPortObject(MultiTrigger, MultiTrigger, "", addTrigger, getTrigger, xmlelement, mode);
    119118
     
    131130    {
    132131        // If this is the first tick.
    133         //TODO: Determine need for this, else kick it out.
    134132        if(this->bFirstTick_)
    135133        {
    136134            this->bFirstTick_ = false;
    137             this->fire(false);
     135            // Fire for all objects that are targets.
     136            this->broadcast(false);
    138137        }
    139138
     
    154153                if(state == NULL)
    155154                {
    156                     COUT(1) << "In MultiTrigger '" << this->getName() << "' (&" << this << "), Error: State of new states queue was NULL." << std::endl;
     155                    COUT(1) << "In MultiTrigger '" << this->getName() << "' (&" << this << "), Error: State of new states queue was NULL. State ignored." << std::endl;
    157156                    queue->pop();
    158157                    continue;
     
    162161                bool bTriggered = (state->bTriggered & this->isModeTriggered(state->originator)) ^ this->bInvertMode_;
    163162
    164                 // If the 'triggered' state has changed a new state is added to the state queue.
    165                 //TODO: Do something against flooding, when there is delay.
    166                 if(this->delay_ != 0.0f || bTriggered ^ this->isTriggered(state->originator))
     163                // If the 'triggered' state has changed or the MultiTrigger has delay and thus we don't know whether this state will actually change the 'triggered' state, a new state is added to the state queue.
     164                if(this->delay_ > 0.0f || bTriggered ^ this->isTriggered(state->originator))
    167165                {
    168166                    state->bTriggered = bTriggered;
    169167                    this->addState(state);
    170168                }
     169                // Else the change is irrelevant.
    171170                else
    172                 {
    173                     COUT(1) << "BUH" << std::endl;
    174171                    delete state;
    175                 }
    176172
    177173                queue->pop();
     
    181177
    182178        // Go through the state queue and activate all pending states whose remaining time has expired.
    183         if (this->stateQueue_.size() > 0)
     179        if(this->stateQueue_.size() > 0)
    184180        {
    185181            MultiTriggerState* state;
     
    195191                if(timeRemaining <= dt)
    196192                {
    197                     // If the maximum number of objects simultaniously triggering this MultiTrigger is not exceeded.
    198                     if(this->maxNumSimultaniousTriggerers_ == INF_s || this->triggered_.size() < (unsigned int)this->maxNumSimultaniousTriggerers_)
     193                    // If the maximum number of objects simultaneously triggering this MultiTrigger is not exceeded.
     194                    if(this->maxNumSimultaneousTriggerers_ == INF_s || this->triggered_.size() < (unsigned int)this->maxNumSimultaneousTriggerers_)
    199195                    {
    200196                        bool bStateChanged = false;
    201                         // If the 'triggered' state is different form what it is now, change it.
     197                        // If the 'triggered' state is different from what it is now, change it.
    202198                        if(state->bTriggered ^ this->isTriggered(state->originator))
    203199                        {
    204200                            // Add the originator to the objects triggering this MultiTrigger.
    205201                            if(state->bTriggered == true)
    206                             {
    207202                                this->triggered_.insert(state->originator);
    208                             }
    209203                            // Remove the originator from the objects triggering this MultiTrigger.
    210204                            else
    211                             {
    212205                                this->triggered_.erase(state->originator);
    213                             }
    214206
    215207                            bStateChanged = true;
     
    218210                        // Get the activity of the new state.
    219211                        bool bActive;
    220                         // If the MultiTrigger is in switch mode.
     212                        // If the MultiTrigger is in switch mode the 'active'-state only changes of the state changed to triggered.
    221213                        if(this->bSwitch_ && !state->bTriggered)
    222214                            bActive = this->isActive(state->originator);
     
    233225                            if(bActive == true)
    234226                            {
    235                                 if(this->remainingActivations_ != 0)
     227                                // If the MultiTrigger has not exceeded its remaining activations.
     228                                if(this->remainingActivations_ > 0)
    236229                                {
    237230                                    this->active_.insert(state->originator);
     
    240233                                }
    241234                                else
    242                                 {
    243235                                    bFire = false;
    244                                 }
    245236                            }
    246237                            // Remove the originator from the objects activating this MultiTrigger.
    247238                            else
    248239                            {
    249                                 if(!this->bStayActive_ || this->remainingActivations_ != 0)
    250                                 {
     240                                // If the MultiTrigger doesn't stay active or hasn't' exceeded its remaining activations.
     241                                if(!this->bStayActive_ || this->remainingActivations_ > 0)
    251242                                    this->active_.erase(state->originator);
    252                                 }
    253243                                else
    254                                 {
    255244                                    bFire = false;
    256                                 }
    257245                            }
    258246
     
    260248                            if(bFire)
    261249                            {
     250                                // If the MultiTrigger is set to broadcast and has no originator a boradcast is fired.
    262251                                if(this->bBroadcast_ && state->originator == NULL)
    263                                 {
    264252                                    this->broadcast(bActive);
    265                                 }
     253                                // Else a normal event is fired.
    266254                                else
    267255                                    this->fire(bActive, state->originator);
     
    271259                        }
    272260
    273                         // Print some debug output if the state has changed.
    274261                        if(bStateChanged)
    275262                        {
     263                            // Print some debug output if the state has changed.
    276264                            if(state->originator != NULL)
    277265                                COUT(4) << "MultiTrigger '" << this->getName() << "' (&" << this << ") changed state. originator: " << state->originator->getIdentifier()->getName() << " (&" << state->originator << "), active: " << bActive << ", triggered: " << state->bTriggered << "." << std::endl;
    278266                            else
    279267                                COUT(4) << "MultiTrigger '" << this->getName() << "' (&" << this << ") changed state. originator: NULL, active: " << bActive << ", triggered: " << state->bTriggered << "." << std::endl;
     268
     269                            // If the MultiTrigger has a parent trigger it needs to call a method to notify him, that its activity has changed.
    280270                            if(this->parentTrigger_ != NULL)
    281                                 this->parentTrigger_->subTrigggerActivityChanged(state->originator);
     271                                this->parentTrigger_->subTriggerActivityChanged(state->originator);
    282272                        }
    283273
    284                         // If the MultiTrigger has exceeded its amount of activations and it doesn't stay active, it has to be destroyed,
     274                        // If the MultiTrigger has exceeded its amount of activations and it doesn't stay active, it has to be deactivated.
    285275                        if(this->remainingActivations_ == 0 && !bActive)
    286276                        {
     
    293283                    this->stateQueue_.pop_front();
    294284                    delete state;
    295                     size -= 1;
    296285                }
    297                 // If the remaining time has not yet expired. Decrement the remainig time.
     286                // If the remaining time has not yet expired. Decrement the remainig time and put the state at the end of the queue.
    298287                else
    299288                {
     
    308297    @brief
    309298        Get whether the MultiTrigger is active for a given object.
    310     @param triggerers
     299    @param triggerer
    311300        A pointer to the object.
    312301    @return
     
    335324        else if (modeName == MultiTrigger::xor_s)
    336325            this->setMode(MultiTriggerMode::EventTriggerXOR);
     326        else
     327            COUT(2) << "Invalid mode '" << modeName << "' in MultiTrigger " << this->getName() << " &(" << this << "). Leaving mode at '" << this->getModeString() << "'." << std::endl;
    337328    }
    338329
     
    351342        else if (this->mode_ == MultiTriggerMode::EventTriggerXOR)
    352343            return MultiTrigger::xor_s;
    353         else
     344        else // This can never happen, but the compiler needs it to feel secure.
    354345            return MultiTrigger::and_s;
    355346    }
     
    365356        Identifier* target = ClassByString(targetStr);
    366357
     358        // If the target is not a valid class name display an error.
    367359        if (target == NULL)
    368360        {
    369             COUT(1) << "Error: \"" << targetStr << "\" is not a valid class name to include in ClassTreeMask (in " << this->getName() << ", class " << this->getIdentifier()->getName() << ')' << std::endl;
     361            COUT(1) << "Error: '" << targetStr << "' is not a valid class name to include in ClassTreeMask (in " << this->getName() << ", class " << this->getIdentifier()->getName() << ")" << std::endl;
    370362            return;
    371363        }
     
    373365        this->targetMask_.include(target);
    374366
    375         // A MultiTriggers shouldn't react to itself or other MultiTriggers.
     367        // A MultiTrigger shouldn't react to itself or other MultiTriggers.
    376368        this->targetMask_.exclude(Class(MultiTrigger), true);
    377369
    378370        // We only want WorldEntities
     371        //TODO: Really?
    379372        ClassTreeMask WEMask;
    380373        WEMask.include(Class(WorldEntity));
    381374        this->targetMask_ *= WEMask;
    382 
    383         this->notifyMaskUpdate();
    384375    }
    385376
     
    393384    {
    394385        Identifier* target = ClassByString(targetStr);
     386
     387        // If the target is not a valid class name display an error.
     388        if (target == NULL)
     389        {
     390            COUT(1) << "Error: '" << targetStr << "' is not a valid class name to include in ClassTreeMask (in " << this->getName() << ", class " << this->getIdentifier()->getName() << ")" << std::endl;
     391            return;
     392        }
     393
    395394        this->targetMask_.exclude(target);
    396395    }
     
    401400        Beware: Loops are not prevented and potentially very bad, so just don't create any loops.
    402401    @param trigger
    403         The trigger to be added.
     402        The MultiTrigger to be added.
    404403    */
    405404    void MultiTrigger::addTrigger(MultiTrigger* trigger)
     
    436435    @brief
    437436        This method is called by the MultiTrigger to get information about new trigger events that need to be looked at.
    438         This method is the device for the behaviour (the conditions under which the MultiTrigger triggers) of any derived class from MultiTrigger.
    439     @return
    440         A pointer to a queue of MultiTriggerState pointers is returned, containing all the neccessary information to decide whether these states should indeed become new states of the MultiTrigger.
    441         Please be aware that both the queue and the states in the queue need to be deleted one they have been used. This is already done in the tick() method of this class but would have to be done by any method calling this method.
     437        This method is the device for the behavior (the conditions under which the MultiTrigger triggers) of any derived class of MultiTrigger.
     438    @return
     439        Returns a pointer to a queue of MultiTriggerState pointers, containing all the necessary information to decide whether these states should indeed become new states of the MultiTrigger.
     440        Please be aware that both the queue and the states in the queue need to be deleted once they have been used. This is already done in the tick() method of this class but would have to be done by any method calling this method.
    442441    */
    443442    std::queue<MultiTriggerState*>* MultiTrigger::letTrigger(void)
     
    464463    /**
    465464    @brief
    466         This method is called by any sub-trigger to advertise changes in it's state to it's parent-trigger.
     465        This method is called by any sub-trigger to advertise changes in its state to its parent-trigger.
    467466    @param originator
    468467        The object that caused the change in activity.
    469468    */
    470     void MultiTrigger::subTrigggerActivityChanged(BaseObject* originator)
     469    void MultiTrigger::subTriggerActivityChanged(BaseObject* originator)
    471470    {
    472471        MultiTriggerState* state = new MultiTriggerState;
     
    479478    @brief
    480479        Checks whether the sub-triggers are in such a way that, according to the mode of the MultiTrigger, the MultiTrigger is triggered (only considering the sub-triggers, not the state of MultiTrigger itself), for a given object.
    481         To make an example: When the mode is 'and', then this would be true or a given object if all the sub-triggers were triggered ofr the given object.
     480        To make an example: When the mode is 'and', then this would be true or a given object if all the sub-triggers were triggered for the given object.
    482481    @param triggerer
    483482        The object.
     
    487486    bool MultiTrigger::isModeTriggered(BaseObject* triggerer)
    488487    {
    489         if (this->subTriggers_.size() != 0)
     488        if(this->subTriggers_.size() != 0)
    490489        {
    491490            bool returnVal = false;
    492491
    493             switch (this->mode_)
     492            switch(this->mode_)
    494493            {
    495494                case MultiTriggerMode::EventTriggerAND:
     
    502501                    returnVal = checkXor(triggerer);
    503502                    break;
    504                 default:
     503                default: // This will never happen.
    505504                    returnVal = false;
    506505                    break;
     
    532531    @brief
    533532        Helper method. Creates an Event for the given status and originator and fires it.
    534         Or more precisely creates a MultiTriggerContainer to encompass all neccesary information and creates an Event from that and sends it.
     533        Or more precisely creates a MultiTriggerContainer to encompass all neccesary information, creates an Event from that and sends it.
    535534    @param status
    536535        The status of the Event to be fired. This is equivalent to the activity of the MultiTrigger.
     
    562561    void MultiTrigger::broadcast(bool status)
    563562    {
    564         ClassTreeMask& targetMask = this->getTargetMask();
    565 
    566         for(ClassTreeMaskObjectIterator it = targetMask.begin(); it != targetMask.end(); ++it)
    567         {
    568             BaseObject* object = static_cast<BaseObject*>(*it);
    569             this->fire(status, object);
    570         }
     563        for(ClassTreeMaskObjectIterator it = this->getTargetMask().begin(); it != this->getTargetMask().end(); ++it)
     564            this->fire(status, static_cast<BaseObject*>(*it));
    571565    }
    572566
     
    576570    @param state
    577571        The state to be added.
     572    @return
     573        Returns true if the state has been added, false if not. If the state has not been added this method destroys it.
    578574    */
    579575    bool MultiTrigger::addState(MultiTriggerState* state)
    580576    {
    581         assert(state);
     577        assert(state); // The state really shouldn't be NULL.
    582578
    583579        // If the originator is no target of this MultiTrigger.
    584580        if(!this->isTarget(state->originator))
     581        {
     582            delete state;
    585583            return false;
    586 
    587         // Add it ot the state queue.
     584        }
     585
     586        // Add it ot the state queue with the delay specified for the MultiTrigger.
    588587        this->stateQueue_.push_back(std::pair<float, MultiTriggerState*>(this->delay_, state));
    589588
     
    597596        The object.
    598597    @return
    599         Returns true if they do.
     598        Returns true if all the sub-triggers are active.
    600599    */
    601600    bool MultiTrigger::checkAnd(BaseObject* triggerer)
    602601    {
    603         std::set<MultiTrigger*>::iterator it;
    604         for(it = this->subTriggers_.begin(); it != this->subTriggers_.end(); ++it)
    605         {
    606             if (!(*it)->isActive(triggerer))
     602        for(std::set<MultiTrigger*>::iterator it = this->subTriggers_.begin(); it != this->subTriggers_.end(); ++it)
     603        {
     604            if(!(*it)->isActive(triggerer))
    607605                return false;
    608606        }
     
    616614        The object.
    617615    @return
    618         Returns true if they do.
     616        Returns true if at least one sub-trigger is active.
    619617    */
    620618    bool MultiTrigger::checkOr(BaseObject* triggerer)
    621619    {
    622         std::set<MultiTrigger*>::iterator it;
    623         for(it = this->subTriggers_.begin(); it != this->subTriggers_.end(); ++it)
    624         {
    625             if ((*it)->isActive(triggerer))
     620        for(std::set<MultiTrigger*>::iterator it = this->subTriggers_.begin(); it != this->subTriggers_.end(); ++it)
     621        {
     622            if((*it)->isActive(triggerer))
    626623                return true;
    627624        }
     
    635632        The object.
    636633    @return
    637         Returns true if they do.
     634        Returns true if exactly one sub-trigger is active.
    638635    */
    639636    bool MultiTrigger::checkXor(BaseObject* triggerer)
    640637    {
    641         std::set<MultiTrigger*>::iterator it;
    642638        bool test = false;
    643         for(it = this->subTriggers_.begin(); it != this->subTriggers_.end(); ++it)
    644         {
    645             if (test && (*it)->isActive(triggerer))
     639        for(std::set<MultiTrigger*>::iterator it = this->subTriggers_.begin(); it != this->subTriggers_.end(); ++it)
     640        {
     641            if(test && (*it)->isActive(triggerer))
    646642                return false;
    647             if ((*it)->isActive(triggerer))
     643
     644            if((*it)->isActive(triggerer))
    648645                test = true;
    649646        }
  • code/trunk/src/modules/objects/triggers/MultiTrigger.h

    r7271 r7301  
    2323 *      Damian 'Mozork' Frick
    2424 *   Co-authors:
    25  *      Benjamin Knecht
     25 *      ...
    2626 *
    2727*/
     
    7070    @brief
    7171        The MultiTrigger class implements a trigger that has a distinct state for each object triggering it.
    72         In more detail: A Trigger is an object that can either be active or inactive, whith a specified behaviour how to switch between the two. A MultiTrigger generalizes that behaviour for multiple objects trigggering the trigger. A MultiTrigger can be active or inactive for any object triggering it, with the state for each object being completely independent of the state for other objects. Each time a switch occurs an Event is fired with as the originator a MultiTriggerContainer, containig a pointer to the pointer that caused the Event and a pointer to the object that caused the trigger to change it's activity.
    73 
    74         MultiTriggers also allow for additional complexity which can be added trough the choice of the parameters explained (briefly) below:
    75         But first you must understand a small implementational detail. There is a distinction between the MultiTrigger being triggered (there is the state 'triggered' for that) and the MultiTrigger being active (for that is the state 'activity'). From the outside only the activity is visible. The state 'triggered' tells us whether the trigger is actually triggered, but it could pretend (for some reason, some of which we will see shortly) to be triggered (or to the outside, active), while it in fact isn't. The standard behaviour is, that the cativity changes, when the MultiTrigger transits from being triggered to not being triggered or the other way around.
     72        In more detail: A Trigger is an object that can either be active or inactive, with a specified behavior how to switch between the two. A MultiTrigger generalizes that behavior for multiple objects triggering the trigger. A MultiTrigger can be active or inactive for any object triggering it, with the state for each object being completely independent of the state for other objects. Each time a switch occurs an Event is fired with as the originator a MultiTriggerContainer, containing a pointer to the MultiTrigger that caused the Event and a pointer to the object that caused the trigger to change it's activity.
     73
     74        MultiTriggers also allow for additional complexity which can be added through the choice of the parameters explained (briefly) below:
     75        But first you must understand a small implementational detail. There is a distinction between the MultiTrigger being triggered (there is the state 'triggered' for that) and the MultiTrigger being active (for that is the state 'activity'). From the outside only the activity is visible. The state 'triggered' tells us whether the trigger is actually triggered, but it could pretend (for some reason, some of which we will see shortly) to be triggered (or to the outside, active), while it in fact isn't. The standard behavior is, that the activity changes, when the MultiTrigger transits from being triggered to not being triggered or the other way around.
    7676        The parameters are:
    7777            'delay':                    The delay is the time that the trigger waits until it reacts (i.e. changes it's state) to the triggering condition being fulfilled.
    7878            'switch':                   Switch is a bool, if true the MultiTrigger is in switch-mode, meaning, that the activity changes only when the trigger is triggered , this means, that now the activity only changes, when the trigger changes from not being triggered to being triggered but not the other way around. The default is false.
    79             'stayactive':               Stay active is also a bool, if true the MultiTrigger stays active after it has been activated as many times as specified by the parameter activations. The default is -1, which is infinity.
     79            'stayactive':               Stay active is also a bool, if true the MultiTrigger stays active after it has been activated as many times as specified by the parameter activations. The default is false.
    8080            'activations':              The number of activations until the trigger can't be triggered anymore. The default is -1, which is infinity.
    81             'invert':                   Invert is a bool, if true the trigger is in invert-mode, meaning, that if the triggering condition is fulfilled the MultiTrigger will have the state not triggered and and if the condition is not fulfilled it will have the state triggered. In short it just inverts the behaviour of the MultiTrigger. The default is false.
    82             'simultaniousTriggerers':   The number of simultanious triggerers limits the number of object that are allowed to trigger the MultiTrigger at the same time. Or a little more precisely, the number of distinct objects the MultiTrigger has 'triggered' states for, at each point in time.
    83             'mode':                     The mode describes how the MultiTrigger acts in relation to all the MultiTriggers, that are appended to it. There are 3 modes: 'and', meaning that the MultiTrigger can only be triggered if all the appended MultiTriggers are active. 'or', meaning that the MultiTrigger can only triggered if at least one of the appendend MultiTriggers is active. And 'xor', meaning that the MultiTrigger can only be triggered if one and only one appended MultiTrigger is active. Notice, that I wrote 'can only be active', that implies, that there is an addtitional condition to the activity 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 activity of a MultiTrigger is still coupled to the object that triggered it. The default is 'and'.
    84             'broadcast'                 Broadcast is a bool, if true the MutliTrigger is in broadcast-mode, meaining, 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.
     81            'invert':                   Invert is a bool, if true the trigger is in invert-mode, meaning, that if the triggering condition is fulfilled the MultiTrigger will have the state not triggered and and if the condition is not fulfilled it will have the state triggered. In short it just inverts the behavior of the MultiTrigger. The default is false.
     82            '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 'triggered' states for, at each point in time. The default is -1, which denotes infinity.
     83            'mode':                     The mode describes how the MultiTrigger acts in relation to all the MultiTriggers, that are appended to it. There are 3 modes: 'and', meaning that the MultiTrigger can only be triggered if all the appended MultiTriggers are active. 'or', meaning that the MultiTrigger can only triggered if at least one of the appended MultiTriggers is active. And 'xor', meaning that the MultiTrigger can only be triggered if one and only one appended MultiTrigger is active. Note, that I wrote 'can only be active', that implies, that there is an additional condition to the activity 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 activity of a MultiTrigger is still coupled to the object that triggered it. The default is 'and'.
     84            'broadcast'                 Broadcast is a bool, if true the MutliTrigger is in broadcast-mode, 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.
    8585            'target':                   The target describes the kind of objects that are allowed to trigger this MultiTrigger. The default is 'Pawn'.
    86             Also there is the possibility of appending MultiTriggers to the MultiTrigger just by adding them as subobjects in the XML description of your MultiTrigger.
     86            Also there is the possibility of appending MultiTriggers to the MultiTrigger just by adding them as sub-objects in the XML description of your MultiTrigger.
     87
     88        An example of a MultiTrigger created through XML would look like this:
     89        @code
     90        <MultiTrigger position="0,0,0" delay="1.3" switch="true" stayactive="true" activations="7" invert="true" simultaneousTriggerers="2" mode="xor" broadcast="false" target="Pawn">
     91            <MultiTrigger />
     92            ...
     93            <MultiTrigger />
     94        </MultiTrigger>
     95        @endcode
    8796
    8897    @author
    8998        Damian 'Mozork' Frick
     99        Many concepts and loads of inspiration from the Trigger class by Benjamin Knecht.
    90100    */
    91101    class _ObjectsExport MultiTrigger : public StaticEntity, public Tickable
     
    93103        public:
    94104            MultiTrigger(BaseObject* creator); //!< Constructor. Registers the objects and initializes default values.
    95             ~MultiTrigger(); //!< Destructor.
     105            virtual ~MultiTrigger(); //!< Destructor.
    96106
    97107            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a MultiTrigger object through XML.
     
    105115            */
    106116            inline void setDelay(float delay)
    107                 { if(delay > 0) this->delay_= delay; }
     117                { if(delay > 0.0f) this->delay_= delay; }
    108118            /**
    109119            @brief Get the delay of the MultiTrigger.
     
    140150
    141151            /**
    142             @brief Set the number of activations the MultiTrigger can go through.
    143             @param activations The number of activations. -1 denotes infinitely many activations.
    144             */
    145             inline void setActivations(int activations)
    146                 { if(activations >= 0 || activations == INF_s) this->remainingActivations_ = activations; }
    147             /**
    148152            @brief Get the number of remaining activations of the MultiTrigger.
    149153            @return The number of activations. -1 denotes infinity.
     
    153157
    154158            /**
    155             @brief Set the number of objects that are allowed to simultaniously trigger this MultiTrigger.
     159            @brief Set the number of objects that are allowed to simultaneously trigger this MultiTrigger.
    156160            @param triggerers The number of objects. -1 denotes infinitely many.
    157161            */
    158             inline void setSimultaniousTriggerers(int triggerers)
    159                 { if(triggerers >= 0 || triggerers == INF_s) this->maxNumSimultaniousTriggerers_ = triggerers; }
    160             /**
    161             @brief Get the number of objects that are allowed to simultaniously trigger this MultiTriggger.
     162            inline void setSimultaneousTriggerers(int triggerers)
     163                { if(triggerers >= 0 || triggerers == INF_s) this->maxNumSimultaneousTriggerers_ = triggerers; }
     164            /**
     165            @brief Get the number of objects that are allowed to simultaneously trigger this MultiTriggger.
    162166            @return Returns the number of objects. -1 denotes infinity.
    163167            */
    164             inline int getSimultaniousTriggerers(void)
    165                 { return this->maxNumSimultaniousTriggerers_; }
     168            inline int getSimultaneousTriggerers(void)
     169                { return this->maxNumSimultaneousTriggerers_; }
    166170
    167171            /**
     
    213217            inline bool isTarget(BaseObject* target)
    214218                { if(target == NULL) return true; else return targetMask_.isIncluded(target->getIdentifier()); }
     219
     220            void addTrigger(MultiTrigger* trigger); //!< Adds a MultiTrigger as a sub-trigger to the trigger.
     221            const MultiTrigger* getTrigger(unsigned int index) const; //!< Get the sub-trigger of this MultiTrigger at the given index.
     222
     223        protected:
     224            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.
     225
     226            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.
     227
     228            bool isModeTriggered(BaseObject* triggerer = NULL); //!< Checks whetherx the MultiTrigger is triggered concerning it's sub-triggers.
     229            bool isTriggered(BaseObject* triggerer = NULL); //!< Get whether the MultiTrigger is triggered for a given object.
     230
     231            void fire(bool status, BaseObject* originator = NULL);  //!< Helper method. Creates an Event for the given status and originator and fires it.
     232            void broadcast(bool status); //!< Helper method. Broadcasts an Event for every object that is a target.
     233
     234            /**
     235            @brief Set the number of activations the MultiTrigger can go through.
     236            @param activations The number of activations. -1 denotes infinitely many activations.
     237            */
     238            inline void setActivations(int activations)
     239                { if(activations >= 0 || activations == INF_s) this->remainingActivations_ = activations; }
     240
    215241            void addTargets(const std::string& targets); //!< Add some target to the MultiTrigger.
    216242            void removeTargets(const std::string& targets); //!< Remove some target from the MultiTrigger.
    217243
    218             void addTrigger(MultiTrigger* trigger); //!< Adds a MultiTrigger as a sub-trigger to the trigger.
    219             const MultiTrigger* getTrigger(unsigned int index) const; //!< Get the sub-trigger of this MultiTrigger at the given index.
    220 
    221         protected:
    222             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.
    223 
    224             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.
    225 
    226             bool isModeTriggered(BaseObject* triggerer = NULL); //!< Checks whetherx the MultiTrigger is triggered concerning it's sub-triggers.
    227             bool isTriggered(BaseObject* triggerer = NULL); //!< Get whether the MultiTrigger is triggered for a given object.
    228 
    229             void fire(bool status, BaseObject* originator = NULL);  //!< Helper method. Creates an Event for the given status and originator and fires it.
    230             void broadcast(bool status); //!< Helper method. Broadcasts an Event for every object that is a target.
    231 
    232244            /**
    233245            @brief Adds the parent of a MultiTrigger.
     
    243255            inline ClassTreeMask& getTargetMask(void)
    244256                { return this->targetMask_; }
    245             /**
    246             @brief Is called, when the target mask changes.
    247             */
    248             //TODO: Check if something mus be done here.
    249             virtual void notifyMaskUpdate(void) {}
    250257
    251258        private:
     
    256263            static const std::string xor_s;
    257264
    258             void subTrigggerActivityChanged(BaseObject* originator); //!< This method is called by any sub-trigger to advertise changes in it's state to it's parent-trigger.
     265            void subTriggerActivityChanged(BaseObject* originator); //!< This method is called by any sub-trigger to advertise changes in it's state to it's parent-trigger.
    259266
    260267            bool addState(MultiTriggerState* state); //!< Helper method. Adds a state to the state queue, where the state will wait to become active.
     
    278285
    279286            int remainingActivations_; //!< The remaining activations of this MultiTrigger.
    280             int maxNumSimultaniousTriggerers_; //!< The maximum number of objects simultaniously trigggering this MultiTrigger.
     287            int maxNumSimultaneousTriggerers_; //!< The maximum number of objects simultaneously trigggering this MultiTrigger.
    281288
    282289            bool bInvertMode_; //!< Bool for the invert-mode, if true the MultiTrigger is inverted.
     
    285292            bool bBroadcast_; //!< Bool for the broadcast-mode, if true all triggers go to all possible targets.
    286293
    287             MultiTrigger* parentTrigger_;
     294            MultiTrigger* parentTrigger_; //!< The parent-trigger of theis MultiTrigger.
    288295            std::set<MultiTrigger*> subTriggers_; //!< The sub-triggers of this MultiTrigger.
    289296
  • code/trunk/src/modules/objects/triggers/MultiTriggerContainer.cc

    r7163 r7301  
    2121 *
    2222 *   Author:
    23  *      ...
     23 *      Damian 'Mozork' Frick
    2424 *   Co-authors:
    2525 *      ...
     
    5858        The creator.
    5959    @param originator
    60         A pointer to the originator of the Event, i.e. the MultiTrigger that fired the Event. (or is about to)
     60        A pointer to the originator of the Event, i.e. the MultiTrigger that fired the Event. (or is about to fire)
    6161    @param data
    6262        A pointer to the data that should be sent with the container.
  • code/trunk/src/modules/objects/triggers/MultiTriggerContainer.h

    r7163 r7301  
    5454            MultiTriggerContainer(BaseObject* creator); //!< Default constructor. Registers the object and creates an empty container.
    5555            MultiTriggerContainer(BaseObject* creator, MultiTrigger* originator, BaseObject* data); //!< Constructor. Registers the object and sets the input values.
    56             ~MultiTriggerContainer(); //!< Destructor.
     56            virtual ~MultiTriggerContainer(); //!< Destructor.
    5757
    5858            /**
Note: See TracChangeset for help on using the changeset viewer.