Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/coll_rect/src/lib/collision_reaction/collision_filter.h @ 9896

Last change on this file since 9896 was 9896, checked in by patrick, 18 years ago

more design, thinner interface

File size: 3.0 KB
Line 
1/*!
2 * @file collision_filter.h
3 * @brief Definition of a collision filter: checks if a certain WorldEntity is responsive for another WorldEntity
4 *
5*/
6
7#ifndef _COLLISION_FILTER_H
8#define _COLLISION_FILTER_H
9
10#include "base_object.h"
11#include "cr_engine.h"
12
13#include <vector>
14#include <list>
15
16
17class Collision;
18class WorldEntity;
19
20namespace CoRe
21{
22
23  class CollisionReaction;
24
25
26
27  /**
28   * A class for defining collision reactions and storing events (functional object)
29   *
30   * This class basically checks if the owner of this filter (a WorldEntity) is responsive for a certain other WorldEntity.
31   * The check is performed via the operator() (therefore it's a functional objects). For each CollisionReaction there is a list
32   * of WorldEntities (their ClassIDs) to which it listens to.
33   */
34  class CollisionFilter : public BaseObject
35  {
36    ObjectListDeclaration(CollisionFilter);
37
38
39    /* Constructor/Deconstructors */
40  public:
41    CollisionFilter(WorldEntity* owner);
42    virtual ~CollisionFilter();
43
44  private:
45    CollisionFilter(const CollisionFilter& collisionFilter) {}
46    WorldEntity*                  _owner;                   //!< the worldenity this reaction will be applied on
47
48
49    /* Defines Operators */
50    bool operator()(const WorldEntity* entity) const;
51
52
53    /* Collision Reaction subscription unsubscription Block */
54  public:
55    void subscribeReaction(CoRe::CREngine::ReactionType type, const ClassID& target1);
56    void subscribeReaction(CoRe::CREngine::ReactionType type, const ClassID& target1, const ClassID& target2);
57    void subscribeReaction(CoRe::CREngine::ReactionType type, const ClassID& target1, const ClassID& target2, const ClassID& target3);
58
59    void unsubscribeReaction(CoRe::CREngine::ReactionType type);
60    void unsubscribeReactions();
61
62  private:
63    std::vector<ClassID>          _filters[CREngine::CR_NUMBER];  //!< an array of filter targets: for each collision type a list of filter objects
64
65
66    /* Misc State Informations */
67  public:
68    /** @returns true if this handle should be pulled also if there are no collisions, can also be set with this function (reference)*/
69    inline bool& bContinousPoll() { return this->_bContinuousPoll; }
70    /** @returns true if this filter should be pulled always */
71    inline bool bContinousPoll() const { return this->_bContinuousPoll; }
72    /** @returns true if this @param type Collision Reaction type is a valid number */
73    inline bool validCRType(const CREngine::ReactionType& type) const {return (type >= 0 && type < CREngine::CR_NUMBER); }
74    /** @returns true if this filter is reactive i.e. at least one filter criterion installed */
75    inline bool bReactive() const { return this->_bReactive; }
76
77  private:
78    bool                          _bContinuousPoll;         //!< if this is true
79    bool                          _bStopOnFirstCollision;   //!< true if the cd of this object should be terminated after one match
80    bool                          _bReactive;               //!< true if this class has at least one filter criterion == one target
81
82  };
83
84}
85#endif /* _COLLISION_FILTER_H */
Note: See TracBrowser for help on using the repository browser.