10 #ifndef __SOT_MAILBOX_T_CPP
11 #define __SOT_MAILBOX_T_CPP
23 template <
class Object>
25 : Entity(name), mainObjectMutex(), mainObject(), update(false)
28 SOUT(boost::bind(&
Mailbox::get, this, _1, _2), sotNOSIGNAL,
29 "Mailbox(" + name +
")::output(Object)::sout"),
30 objSOUT(boost::bind(&
Mailbox::getObject, this, _1, _2), SOUT,
31 "Mailbox(" + name +
")::output(Object)::object"),
32 timeSOUT(boost::bind(&
Mailbox::getTimestamp, this, _1, _2), SOUT,
33 "Mailbox(" + name +
")::output(Object)::timestamp") {
35 SOUT.setDependencyType(TimeDependency<int>::BOOL_DEPENDENT);
39 boost::timed_mutex::scoped_lock lockMain(mainObjectMutex);
46 boost::timed_mutex::scoped_try_lock lockMain(this->mainObjectMutex);
48 if (lockMain.owns_lock()) {
56 template <
class Object>
60 boost::timed_mutex::scoped_try_lock lockMain(this->mainObjectMutex);
62 if (lockMain.owns_lock()) {
63 res.
timestamp.tv_sec = this->mainTimeStamp.tv_sec;
64 res.
timestamp.tv_usec = this->mainTimeStamp.tv_usec;
67 res.
obj = this->mainObject;
75 boost::timed_mutex::scoped_lock lockMain(this->mainObjectMutex);
77 gettimeofday(&this->mainTimeStamp, NULL);
84 template <
class Object>
91 template <
class Object>
103 #define MAILBOX_TEMPLATE_SPE(S) \
104 namespace dynamicgraph { \
106 template void Mailbox<S>::post(const S &obj); \
107 template dynamicgraph::Vector &Mailbox<S>::getObject(S &res, \
109 template bool Mailbox<S>::hasBeenUpdated(void); \
110 template Mailbox<S>::~Mailbox(); \
111 template Mailbox<S>::sotTimestampedObject & \
112 Mailbox<S>::get(Mailbox<S>::sotTimestampedObject &res, const int &dummy); \
113 template Mailbox<S>::Mailbox(const std::string &name); \
115 } // namespace sot namespace dynamicgraph
118 #endif // #ifdef __SOT_MAILBOX_T_CPP