29 #ifndef Pt_Remoting_ServiceDefinition_h
30 #define Pt_Remoting_ServiceDefinition_h
32 #include <Pt/Remoting/Api.h>
33 #include <Pt/Remoting/ServiceProcedure.h>
34 #include <Pt/System/Mutex.h>
35 #include <Pt/NonCopyable.h>
46 class PT_REMOTING_API ServiceDefinition :
private NonCopyable
51 virtual ~ServiceDefinition();
58 void registerProcedure(
const std::string& name, R (*fn)())
60 ServiceProcedureDef* proc =
new BasicProcedureDef<R>(Pt::callable(fn));
61 this->registerProcedure(name, proc);
64 template <
typename R,
typename A1>
65 void registerProcedure(
const std::string& name, R (*fn)(A1))
67 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1>(Pt::callable(fn));
68 this->registerProcedure(name, proc);
71 template <
typename R,
typename A1,
typename A2>
72 void registerProcedure(
const std::string& name, R (*fn)(A1, A2))
74 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2>(Pt::callable(fn));
75 this->registerProcedure(name, proc);
78 template <
typename R,
typename A1,
typename A2,
typename A3>
79 void registerProcedure(
const std::string& name, R (*fn)(A1, A2, A3))
81 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2, A3>(Pt::callable(fn));
82 this->registerProcedure(name, proc);
85 template <
typename R,
typename A1,
typename A2,
typename A3,
typename A4>
86 void registerProcedure(
const std::string& name, R (*fn)(A1, A2, A3, A4))
88 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2, A3, A4>(Pt::callable(fn));
89 this->registerProcedure(name, proc);
92 template <
typename R,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5>
93 void registerProcedure(
const std::string& name, R (*fn)(A1, A2, A3, A4, A5))
95 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2, A3, A4, A5>(Pt::callable(fn));
96 this->registerProcedure(name, proc);
99 template <
typename R,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5,
typename A6>
100 void registerProcedure(
const std::string& name, R (*fn)(A1, A2, A3, A4, A5, A6))
102 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2, A3, A4, A5, A6>(Pt::callable(fn));
103 this->registerProcedure(name, proc);
106 template <
typename R,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5,
typename A6,
typename A7>
107 void registerProcedure(
const std::string& name, R (*fn)(A1, A2, A3, A4, A5, A6, A7))
109 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2, A3, A4, A5, A6, A7>(Pt::callable(fn));
110 this->registerProcedure(name, proc);
113 template <
typename R,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5,
typename A6,
typename A7,
typename A8>
114 void registerProcedure(
const std::string& name, R (*fn)(A1, A2, A3, A4, A5, A6, A7, A8))
116 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2, A3, A4, A5, A6, A7, A8>(Pt::callable(fn));
117 this->registerProcedure(name, proc);
120 template <
typename R,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5,
typename A6,
typename A7,
typename A8,
typename A9>
121 void registerProcedure(
const std::string& name, R (*fn)(A1, A2, A3, A4, A5, A6, A7, A8, A9))
123 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2, A3, A4, A5, A6, A7, A8, A9>(Pt::callable(fn));
124 this->registerProcedure(name, proc);
127 template <
typename R,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5,
typename A6,
typename A7,
typename A8,
typename A9,
typename A10>
128 void registerProcedure(
const std::string& name, R (*fn)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10))
130 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>(Pt::callable(fn));
131 this->registerProcedure(name, proc);
134 template <
typename R,
class C>
135 void registerProcedure(
const std::string& name, C& obj, R (C::*method)() )
137 ServiceProcedureDef* proc =
new BasicProcedureDef<R>( callable(obj, method) );
138 this->registerProcedure(name, proc);
141 template <
typename R,
class C,
typename A1>
142 void registerProcedure(
const std::string& name, C& obj, R (C::*method)(A1) )
144 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1>( callable(obj, method) );
145 this->registerProcedure(name, proc);
148 template <
typename R,
class C,
typename A1,
typename A2>
149 void registerProcedure(
const std::string& name, C& obj, R (C::*method)(A1, A2) )
151 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2>( callable(obj, method) );
152 this->registerProcedure(name, proc);
155 template <
typename R,
class C,
typename A1,
typename A2,
typename A3>
156 void registerProcedure(
const std::string& name, C& obj, R (C::*method)(A1, A2, A3) )
158 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2, A3>( callable(obj, method) );
159 this->registerProcedure(name, proc);
162 template <
typename R,
class C,
typename A1,
typename A2,
typename A3,
typename A4>
163 void registerProcedure(
const std::string& name, C& obj, R (C::*method)(A1, A2, A3, A4) )
165 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2, A3, A4>( callable(obj, method) );
166 this->registerProcedure(name, proc);
169 template <
typename R,
class C,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5>
170 void registerProcedure(
const std::string& name, C& obj, R (C::*method)(A1, A2, A3, A4, A5) )
172 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2, A3, A4, A5>( callable(obj, method) );
173 this->registerProcedure(name, proc);
176 template <
typename R,
class C,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5,
typename A6>
177 void registerProcedure(
const std::string& name, C& obj, R (C::*method)(A1, A2, A3, A4, A5, A6) )
179 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2, A3, A4, A5, A6>( callable(obj, method) );
180 this->registerProcedure(name, proc);
183 template <
typename R,
class C,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5,
typename A6,
typename A7>
184 void registerProcedure(
const std::string& name, C& obj, R (C::*method)(A1, A2, A3, A4, A5, A6, A7) )
186 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2, A3, A4, A5, A6, A7>( callable(obj, method) );
187 this->registerProcedure(name, proc);
190 template <
typename R,
class C,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5,
typename A6,
typename A7,
typename A8>
191 void registerProcedure(
const std::string& name, C& obj, R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8) )
193 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2, A3, A4, A5, A6, A7, A8>( callable(obj, method) );
194 this->registerProcedure(name, proc);
197 template <
typename R,
class C,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5,
typename A6,
typename A7,
typename A8,
typename A9>
198 void registerProcedure(
const std::string& name, C& obj, R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9) )
200 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2, A3, A4, A5, A6, A7, A8, A9>( callable(obj, method) );
201 this->registerProcedure(name, proc);
204 template <
typename R,
class C,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5,
typename A6,
typename A7,
typename A8,
typename A9,
typename A10>
205 void registerProcedure(
const std::string& name, C& obj, R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) )
207 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>( callable(obj, method) );
208 this->registerProcedure(name, proc);
211 template <
typename R>
212 void registerProcedure(
const std::string& name,
const Callable<R>& cb)
214 ServiceProcedureDef* proc =
new BasicProcedureDef<R>(cb);
215 this->registerProcedure(name, proc);
218 template <
typename R,
typename A1>
219 void registerProcedure(
const std::string& name,
const Callable<R, A1>& cb)
221 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1>(cb);
222 this->registerProcedure(name, proc);
225 template <
typename R,
typename A1,
typename A2>
228 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2>(cb);
229 this->registerProcedure(name, proc);
232 template <
typename R,
typename A1,
typename A2,
typename A3>
235 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2, A3>(cb);
236 this->registerProcedure(name, proc);
239 template <
typename R,
typename A1,
typename A2,
typename A3,
typename A4>
242 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2, A3, A4>(cb);
243 this->registerProcedure(name, proc);
246 template <
typename R,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5>
249 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2, A3, A4, A5>(cb);
250 this->registerProcedure(name, proc);
253 template <
typename R,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5,
typename A6>
256 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2, A3, A4, A5, A6>(cb);
257 this->registerProcedure(name, proc);
260 template <
typename R,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5,
typename A6,
typename A7>
263 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2, A3, A4, A5, A6, A7>(cb);
264 this->registerProcedure(name, proc);
267 template <
typename R,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5,
typename A6,
typename A7,
typename A8>
270 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2, A3, A4, A5, A6, A7, A8>(cb);
271 this->registerProcedure(name, proc);
274 template <
typename R,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5,
typename A6,
typename A7,
typename A8,
typename A9>
275 void registerProcedure(
const std::string& name,
const Callable<R, A1, A2, A3, A4, A5, A6, A7, A8, A9>& cb)
277 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2, A3, A4, A5, A6, A7, A8, A9>(cb);
278 this->registerProcedure(name, proc);
281 template <
typename R,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5,
typename A6,
typename A7,
typename A8,
typename A9,
typename A10>
282 void registerProcedure(
const std::string& name,
const Callable<R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>& cb)
284 ServiceProcedureDef* proc =
new BasicProcedureDef<R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>(cb);
285 this->registerProcedure(name, proc);
288 template <
typename A,
class C>
289 void registerActiveProcedure(
const std::string& name, A* (*fn)(
Responder&) )
291 ServiceProcedureDef* proc =
new ActiveProcedureDef<A>( callable(fn) );
292 this->registerProcedure(name, proc);
295 template <
typename A,
class C>
296 void registerActiveProcedure(
const std::string& name, C& obj, A* (C::*method)(
Responder&) )
298 ServiceProcedureDef* proc =
new ActiveProcedureDef<A>( callable(obj, method) );
299 this->registerProcedure(name, proc);
302 template <
typename A,
class C>
303 void registerActiveProcedure(
const std::string& name, C& obj, A* (C::*method)(
Responder&)
const )
305 ServiceProcedureDef* proc =
new ActiveProcedureDef<A>( callable(obj, method) );
306 this->registerProcedure(name, proc);
310 void registerProcedure(
const std::string& name, ServiceProcedureDef* proc);
317 typedef std::map<std::string, ServiceProcedureDef*> ProcedureMap;
318 ProcedureMap _procedures;
328 #endif // Pt_Remoting_ServiceDefinition_h
XML-RPC service procedure.
Definition: ServiceProcedure.h:44
Protects derived classes from being copied.
Definition: NonCopyable.h:54
Mutual exclusion device.
Definition: Mutex.h:48
Dispatches requests to a service procedure.
Definition: Responder.h:49