![]() |
User Manual, Developers Guide and API Documentation |
![]() |
#include <events/MemberFunction.hpp>

Public Member Functions | |
| DelayedMemberFunction (typename TFunctor< T >::functionPointer _fptr, wns::simulator::Time _delay) | |
| Takes a member function pointer and the delay. | |
| virtual void | operator() (T &obj) |
| This is for value objects. | |
| virtual void | operator() (T *obj) |
| This is for pointers. | |
| virtual | ~DelayedMemberFunction () |
| Destructor. | |
Private Attributes | |
| wns::simulator::Time | delay |
| TFunctor< T >::functionPointer | fptr |
std::vector<TestObject*> tos; tos.push_back(new TestObject); tos.push_back(new TestObject); tos.push_back(new TestObject); // counter should be zero for all objects ASSERT_EQUAL(0, tos[0]->foo); ASSERT_EQUAL(0, tos[1]->foo); ASSERT_EQUAL(0, tos[2]->foo); // queue Events for all objects, calling increaseFoo after 1 second std::for_each( tos.begin(), tos.end(), DelayedMemberFunction<TestObject>(&TestObject::increaseFoo, 1.0)); // only one of the objects should have the counter // increased. Since events may be executed in unperdictble order // we're testing the sum rather than one specifc element! wns::simulator::getEventScheduler()->processOneEvent(); ASSERT_EQUAL(1, tos[0]->foo + tos[1]->foo + tos[2]->foo); // two of the objects should have the counter // increased. None of them should be called twice! wns::simulator::getEventScheduler()->processOneEvent(); ASSERT_EQUAL(2, tos[0]->foo + tos[1]->foo + tos[2]->foo); ASSERT(tos[0]->foo < 2 && tos[1]->foo < 2 && tos[2]->foo < 2); // two of the objects should have the counter // increased. None of them should be called twice! wns::simulator::getEventScheduler()->processOneEvent(); ASSERT_EQUAL(3, tos[0]->foo + tos[1]->foo + tos[2]->foo); ASSERT(tos[0]->foo < 2 && tos[1]->foo < 2 && tos[2]->foo < 2);
Definition at line 74 of file MemberFunction.hpp.
| wns::events::DelayedMemberFunction< T >::DelayedMemberFunction | ( | typename TFunctor< T >::functionPointer | _fptr, | |
| wns::simulator::Time | _delay | |||
| ) | [inline] |
Definition at line 80 of file MemberFunction.hpp.
| virtual wns::events::DelayedMemberFunction< T >::~DelayedMemberFunction | ( | ) | [inline, virtual] |
Definition at line 92 of file MemberFunction.hpp.
| virtual void wns::events::DelayedMemberFunction< T >::operator() | ( | T & | obj | ) | [inline, virtual] |
Definition at line 109 of file MemberFunction.hpp.
| virtual void wns::events::DelayedMemberFunction< T >::operator() | ( | T * | obj | ) | [inline, virtual] |
Definition at line 100 of file MemberFunction.hpp.
wns::simulator::Time wns::events::DelayedMemberFunction< T >::delay [private] |
Definition at line 115 of file MemberFunction.hpp.
TFunctor<T>::functionPointer wns::events::DelayedMemberFunction< T >::fptr [private] |
Definition at line 114 of file MemberFunction.hpp.
1.5.5