101 template <
typename T1>
120 template <
typename T1,
typename T2>
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>
#define AGX_EVENT_TRIGGER_END()
#define AGX_EVENT_TRIGGER_START()
Templated callback with one argument.
Templated callback with two arguments.
void run(T1 arg1, T2 arg2) const
Templated callback with three arguments.
void run(T1 arg1, T2 arg2, T3 arg3) const
Generalized callback, using std::function.
An event with one argument.
void trigger(const T1 &arg)
Trigger the event.
void trigger()
Trigger the event with the default argument.
Event1(const agx::Name &name=agx::Name(), const T1 &defaultArg=T1())
An event with two arguments.
Event2(const agx::Name &name=agx::Name(), const T1 &defaultArg=T1())
void trigger(const T1 &arg1, const T2 &arg2)
Trigger the event.
void trigger(const T2 &arg2)
Trigger the event with default first argument.
An event with three arguments.
void trigger(const T1 &arg1, const T2 &arg2, const T3 &arg3)
Trigger the event.
Event3(const agx::Name &name=agx::Name(), const T1 &defaultArg=T1())
void trigger(const T2 &arg2, const T3 &arg3)
Trigger the event with default first argument.
An event has a list of listeners (agx::Callback), which are called when the event is triggered.
agx::UInt32 m_iterationIndex
void removeAllCallbacks()
Remove all callbacks.
bool removeCallback(const T *callback)
void addCallbackFirst(const T *callback)
Add a callback to the front of the callback list.
CallbackPtrVector m_callbacks
const agx::Name & getName() const
VectorPOD< const CallbackType * > CallbackPtrVector
EventT(const agx::Name &name=agx::Name())
bool containsCallback(const T *callback) const
const CallbackPtrVector & getCallbacks() const
void addCallback(const T *callback)
Add a callback to the event.
An event with no arguments.
void trigger()
Trigger the event.
Event(const agx::Name &name=agx::Name())
Representation of a name string.
agx::Thread is a representation of an OS specific implementation of a computational thread.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
std::ostream & operator<<(std::ostream &os, const agx::AddedMassInteraction::Matrix6x6 &m)
AGXCORE_EXPORT Thread * __agx_Event_getActiveThread()
void swap(agx::Name &lhs, agx::Name &rhs)