AGX Dynamics  2.35.0.1
EventListener.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGXSDK_EVENTLISTENER_H
18 #define AGXSDK_EVENTLISTENER_H
19 
20 #include <agxSDK/agxSDK.h>
21 #include <agx/Component.h>
22 
23 #include <agxStream/Serializable.h>
24 #include <agx/SetVector.h>
25 
26 namespace agxSDK
27 {
28 
29  class Simulation;
30 
34 
35 
41  {
42  public:
43 
45  enum Type {
49  GUI_EVENT_LISTENER
50  };
51 
56  virtual void setMask(int f);
57 
59  int getMask() const;
60 
65  void setEnable( bool enable );
66 
70  bool isEnabled( ) const;
71 
76 
80  const Simulation* getSimulation() const;
81 
86  virtual void addNotification() {}
87 
91  virtual void removeNotification() {}
92 
94  Type getType() const;
95 
98 
99 #ifndef SWIG
101 #endif
102 
103  private:
105  void setPriority( agx::UInt32 priority );
106 
107  protected:
112  EventListener( Type type = UNDEFINED_TYPE );
113 
114 
115  friend class Simulation;
116  friend class EventManager;
117 
119  void setSimulation( Simulation* simulation );
120 
122  virtual ~EventListener();
123 
125 
126  int m_mask;
127  bool m_enabled;
129  private:
130 
131  Simulation* m_simulation;
132  };
133 
134 }
135 
136 #endif
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:207
#define AGXPHYSICS_EXPORT
An EventListener can be associated to a Simulation and triggered upon various events.
Definition: EventListener.h:41
Type
Type of EventListener.
Definition: EventListener.h:45
@ CONTACT_EVENT_LISTENER
Of type ContactEventListener.
Definition: EventListener.h:48
@ UNDEFINED_TYPE
Undefined type.
Definition: EventListener.h:46
@ STEP_EVENT_LISTENER
Of type StepEventListener.
Definition: EventListener.h:47
void setEnable(bool enable)
Specify whether the listener should react at all at events.
virtual void addNotification()
Called when this listener is added to the simulation.
Definition: EventListener.h:86
virtual void setMask(int f)
Specifies a bit mask which determines which event types that will activate this listener.
EventListener(Type type=UNDEFINED_TYPE)
Default constructor.
virtual void removeNotification()
Called when this listener is removed from the simulation.
Definition: EventListener.h:91
Simulation * getSimulation()
virtual ~EventListener()
Destructor.
Type getType() const
void setSimulation(Simulation *simulation)
Set the associated simulation for this EventListener.
const Simulation * getSimulation() const
bool isEnabled() const
agx::UInt32 getPriority() const
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:127
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:45
A component is an object containing other objects, enabling hierarchical structuring.
Definition: Component.h:39
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
Definition: SetVector.h:38
Templated vector class.
Definition: agx/Vector.h:53
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:31
agx::SetVector< agx::ref_ptr< agxSDK::EventListener > > EventListenerRefSetVector
Definition: EventListener.h:33
agx::Vector< EventListener * > EventListenerPtrVector
Definition: EventListener.h:32
uint32_t UInt32
Definition: Integer.h:40