00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef ACEDIA_MOCKACTOR_HPP
00031 #define ACEDIA_MOCKACTOR_HPP
00032
00033 #include "actorref.hpp"
00034 #include "invoker.hpp"
00035 #include "acedia.hpp"
00036
00037 namespace acedia
00038 {
00039
00040 namespace details { struct MockActorPrivate; }
00041
00057 class MockActor
00058 {
00059
00060 details::MockActorPrivate *d;
00061 ActorRef m_self;
00062 boost::int32_t m_exitReason;
00063
00064
00065 MockActor(const MockActor&);
00066 MockActor& operator=(const MockActor&);
00067
00068 public:
00069
00070 MockActor();
00071 ~MockActor();
00072
00076 void setExitReason(boost::int32_t reason);
00077
00081 void receiveAndInvoke(Invoker &imp);
00082
00086 template<class CaseClass>
00087 void waitFor()
00088 {
00089 Invoker inv;
00090 inv.add(on<CaseClass>() >> boost::function0<void>(discard));
00091 receiveAndInvoke(inv);
00092 }
00093
00097 bool tryReceiveAndInvoke(Invoker &imp);
00098
00102 bool receiveAndInvokeWithin(Invoker &imp, boost::uint16_t msTimeout);
00103
00107 Message receive();
00108
00112 bool tryReceive(Message &storage);
00113
00117 bool receiveWithin(Message &storage, boost::uint16_t msTimeout);
00118
00122 inline operator ActorRef() const { return m_self; }
00123
00127 void send(ActorRef &receiver, const Any &v1);
00128
00129 void send(ActorRef &receiver, const Any &v1, const Any &v2);
00130
00131 void send(ActorRef &receiver, const Any &v1, const Any &v2,
00132 const Any &v3);
00133
00134 void send(ActorRef &receiver,
00135 const Any &v1, const Any &v2, const Any &v3, const Any &v4);
00136
00137 void send(ActorRef &receiver,
00138 const Any &v1, const Any &v2, const Any &v3, const Any &v4,
00139 const Any &v5);
00140
00141 void send(ActorRef &receiver,
00142 const Any &v1, const Any &v2, const Any &v3, const Any &v4,
00143 const Any &v5, const Any &v6);
00144
00145 void send(ActorRef &receiver,
00146 const Any &v1, const Any &v2, const Any &v3, const Any &v4,
00147 const Any &v5, const Any &v6, const Any &v7);
00148
00149 void send(ActorRef &receiver,
00150 const Any &v1, const Any &v2, const Any &v3, const Any &v4,
00151 const Any &v5, const Any &v6, const Any &v7, const Any &v8);
00152
00153 void send(ActorRef &receiver,
00154 const Any &v1, const Any &v2, const Any &v3, const Any &v4,
00155 const Any &v5, const Any &v6, const Any &v7, const Any &v8,
00156 const Any &v9);
00157
00161 void reply(const Any &val1);
00162
00163 void reply(const acedia::Any &val1, const acedia::Any &val2);
00164
00165 };
00166 }
00167
00168 #endif // ACEDIA_MOCKACTOR_HPP