101 template <
typename T1>
111 void trigger(
const T1& arg );
120 template <
typename T1,
typename T2>
127 void trigger(
const T2& arg2 );
130 void trigger(
const T1& arg1,
const T2& arg2 );
139 template <
typename T1,
typename T2,
typename T3>
146 void trigger(
const T2& arg2,
const T3& arg3 );
149 void trigger(
const T1& arg1,
const T2& arg2,
const T3& arg3 );
160 #define INDEX this->m_iterationIndex 163 template <
typename T>
168 template <
typename T>
171 template <
typename T>
175 m_callbacks.push_back( callback );
179 for (
size_t i = m_callbacks.size() - 1; i > 0 ; --i)
181 if (m_callbacks[i].priority <= m_callbacks[i-1].priority)
184 std::swap(m_callbacks[i], m_callbacks[i-1]);
189 template <
typename T>
193 m_callbacks.insert( (
size_t)0, callback );
198 template <
typename T>
202 size_t index = m_callbacks.find(callback);
204 if (index == m_callbacks.size())
208 m_callbacks.erase(index);
210 if (index <= m_iterationIndex)
216 template <
typename T>
219 template <
typename T>
222 template <
typename T>
228 #define AGX_EVENT_TRIGGER_START(); this->m_activeThread = __agx_Event_getActiveThread(); 229 #define AGX_EVENT_TRIGGER_END(); this->m_activeThread = nullptr 231 #define AGX_EVENT_TRIGGER_START(); 232 #define AGX_EVENT_TRIGGER_END(); 252 template<
typename T1 >
255 template<
typename T1 >
258 this->trigger(m_defaultArg);
261 template<
typename T1 >
271 this->m_callbacks[
INDEX] = this->m_callbacks.back();
272 this->m_callbacks.pop_back();
282 template<
typename T1,
typename T2 >
285 template<
typename T1,
typename T2 >
288 this->trigger(m_defaultArg, arg2);
292 template<
typename T1,
typename T2 >
302 this->m_callbacks[
INDEX] = this->m_callbacks.back();
303 this->m_callbacks.pop_back();
306 callback->
run(arg1, arg2);
313 template<
typename T1,
typename T2,
typename T3 >
316 template<
typename T1,
typename T2,
typename T3 >
319 this->trigger(m_defaultArg, arg2, arg3);
322 template<
typename T1,
typename T2,
typename T3 >
332 this->m_callbacks[
INDEX] = this->m_callbacks.back();
333 this->m_callbacks.pop_back();
337 callback->
run(arg1, arg2, arg3);
344 template <
typename T>
347 stream << e.getName();
CallbackPtrVector m_callbacks
agx::Thread is a representation of an OS specific implementation of a computational thread...
An event has a list of listeners (agx::Callback), which are called when the event is triggered...
const agx::Name & getName() const
bool removeCallback(const T *callback)
Generalized callback, using std::function.
void run(T1 arg1, T2 arg2, T3 arg3) const
void addCallbackFirst(const T *callback)
Add a callback to the front of the callback list.
agx::UInt32 m_iterationIndex
#define AGX_EVENT_TRIGGER_START()
Representation of a name string.
Event1(const agx::Name &name=agx::Name(), const T1 &defaultArg=T1())
VectorPOD< const CallbackType *> CallbackPtrVector
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Templated callback with one argument.
Templated callback with three arguments.
#define AGX_EVENT_TRIGGER_END()
void removeAllCallbacks()
Remove all callbacks.
void trigger()
Trigger the event.
bool containsCallback(const T *callback) const
void run(T1 arg1, T2 arg2) const
AGXCORE_EXPORT Thread * __agx_Event_getActiveThread()
const CallbackPtrVector & getCallbacks() const
EventT(const agx::Name &name=agx::Name())
Templated callback with two arguments.
An event with two arguments.
void addCallback(const T *callback)
Add a callback to the event.
An event with three arguments.
An event with no arguments.
An event with one argument.