CARMA C++
RemoteObjMethodFunctorGroup.h
1 #ifndef CARMA_CONTROL_REMOTE_OBJ_METHOD_FUNCTOR_GROUP_H
2 #define CARMA_CONTROL_REMOTE_OBJ_METHOD_FUNCTOR_GROUP_H
3 
4 
5 #include <map>
6 #include <set>
7 #include <string>
8 
9 #include "carma/control/RemoteObjMethodFunctor.h"
10 
11 
12 namespace carma {
13 namespace control {
14 
15 
16 ::std::string
17 makeRemoteObjCallString( const ::std::string & methodName,
18  const ::std::string & paramString );
19 
20 
21 template < typename T, typename H >
22 ::std::map< ::std::string, RemoteObjMethodFunctor0< T > >
23 makeRemoteObjMethodFunctorGroup(
24  const ::std::set< H * > & hGroup,
25  const ::std::string & methodName,
26  const ::std::string & paramString,
27  void (T::*methodPtr)( ) );
28 
29 
30 template < typename T, typename H, typename A0 >
31 ::std::map< ::std::string, RemoteObjMethodFunctor1< T, A0 > >
32 makeRemoteObjMethodFunctorGroup(
33  const ::std::set< H * > & hGroup,
34  const ::std::string & methodName,
35  const ::std::string & paramString,
36  void (T::*methodPtr)( A0 ),
37  const A0 & arg0 );
38 
39 
40 template < typename T, typename H, typename A0, typename A1 >
41 ::std::map< ::std::string, RemoteObjMethodFunctor2< T, A0, A1 > >
42 makeRemoteObjMethodFunctorGroup(
43  const ::std::set< H * > & hGroup,
44  const ::std::string & methodName,
45  const ::std::string & paramString,
46  void (T::*methodPtr)( A0, A1 ),
47  const A0 & arg0,
48  const A1 & arg1 );
49 
50 
51 template < typename T, typename H,
52  typename A0,
53  typename A1,
54  typename A2 >
55 ::std::map< ::std::string, RemoteObjMethodFunctor3< T, A0, A1, A2 > >
56 makeRemoteObjMethodFunctorGroup(
57  const ::std::set< H * > & hGroup,
58  const ::std::string & methodName,
59  const ::std::string & paramString,
60  void (T::*methodPtr)( A0, A1, A2 ),
61  const A0 & arg0,
62  const A1 & arg1,
63  const A2 & arg2 );
64 
65 
66 template < typename T, typename H,
67  typename A0,
68  typename A1,
69  typename A2,
70  typename A3 >
71 ::std::map< ::std::string, RemoteObjMethodFunctor4< T, A0, A1, A2, A3 > >
72 makeRemoteObjMethodFunctorGroup(
73  const ::std::set< H * > & hGroup,
74  const ::std::string & methodName,
75  const ::std::string & paramString,
76  void (T::*methodPtr)( A0, A1, A2, A3 ),
77  const A0 & arg0,
78  const A1 & arg1,
79  const A2 & arg2,
80  const A3 & arg3 );
81 
82 
83 template < typename T, typename H,
84  typename A0,
85  typename A1,
86  typename A2,
87  typename A3,
88  typename A4 >
89 ::std::map< ::std::string, RemoteObjMethodFunctor5< T, A0, A1, A2, A3, A4 > >
90 makeRemoteObjMethodFunctorGroup(
91  const ::std::set< H * > & hGroup,
92  const ::std::string & methodName,
93  const ::std::string & paramString,
94  void (T::*methodPtr)( A0, A1, A2, A3, A4 ),
95  const A0 & arg0,
96  const A1 & arg1,
97  const A2 & arg2,
98  const A3 & arg3,
99  const A4 & arg4 );
100 
101 template < typename T, typename H,
102  typename A0,
103  typename A1,
104  typename A2,
105  typename A3,
106  typename A4,
107  typename A5,
108  typename A6,
109  typename A7,
110  typename A8 >
111 ::std::map< ::std::string, RemoteObjMethodFunctor9< T, A0, A1, A2, A3, A4, A5, A6, A7, A8 > >
112 makeRemoteObjMethodFunctorGroup(
113  const ::std::set< H * > & hGroup,
114  const ::std::string & methodName,
115  const ::std::string & paramString,
116  void (T::*methodPtr)( A0, A1, A2, A3, A4, A5, A6, A7, A8 ),
117  const A0 & arg0,
118  const A1 & arg1,
119  const A2 & arg2,
120  const A3 & arg3,
121  const A4 & arg4,
122  const A5 & arg5,
123  const A6 & arg6,
124  const A7 & arg7,
125  const A8 & arg8 );
126 
127 
128 
129 // NOTE: Below here is simply implementation
130 
131 
132 template < typename T, typename H >
133 ::std::map< ::std::string, RemoteObjMethodFunctor0< T > >
134 makeRemoteObjMethodFunctorGroup(
135  const ::std::set< H * > & hGroup,
136  const ::std::string & methodName,
137  const ::std::string & paramString,
138  void (T::*methodPtr)( ) ) {
139  typedef typename ::std::set< H * >::const_iterator HGroupConstIterator;
140  typedef ::std::map< ::std::string, RemoteObjMethodFunctor0< T > > FunctorGroup;
141 
142  FunctorGroup result;
143 
144  HGroupConstIterator i = hGroup.begin( );
145  const HGroupConstIterator iEnd = hGroup.end( );
146 
147  for ( ; i != iEnd; ++i ) {
148  RemoteObjHandleT< T > * const h = *i;
149 
150  if ( h == 0 )
151  continue;
152 
153  result.insert(
154  ::std::make_pair(
155  h->doName( ),
156  RemoteObjMethodFunctor0< T >(
157  h,
158  makeRemoteObjCallString( methodName, paramString ),
159  methodPtr ) ) );
160  }
161 
162  return result;
163 }
164 
165 
166 template < typename T, typename H, typename A0 >
167 ::std::map< ::std::string, RemoteObjMethodFunctor1< T, A0 > >
168 makeRemoteObjMethodFunctorGroup(
169  const ::std::set< H * > & hGroup,
170  const ::std::string & methodName,
171  const ::std::string & paramString,
172  void (T::*methodPtr)( A0 ),
173  const A0 & arg0 ) {
174  typedef typename ::std::set< H * >::const_iterator HGroupConstIterator;
175  typedef ::std::map< ::std::string, RemoteObjMethodFunctor1< T, A0 > > FunctorGroup;
176 
177  FunctorGroup result;
178 
179  HGroupConstIterator i = hGroup.begin( );
180  const HGroupConstIterator iEnd = hGroup.end( );
181 
182  for ( ; i != iEnd; ++i ) {
183  RemoteObjHandleT< T > * const h = *i;
184 
185  if ( h == 0 )
186  continue;
187 
188  result.insert(
189  ::std::make_pair(
190  h->doName( ),
191  RemoteObjMethodFunctor1< T, A0 >(
192  h,
193  makeRemoteObjCallString( methodName, paramString ),
194  methodPtr,
195  arg0 ) ) );
196  }
197 
198  return result;
199 }
200 
201 
202 template < typename T, typename H, typename A0, typename A1 >
203 ::std::map< ::std::string, RemoteObjMethodFunctor2< T, A0, A1 > >
204 makeRemoteObjMethodFunctorGroup(
205  const ::std::set< H * > & hGroup,
206  const ::std::string & methodName,
207  const ::std::string & paramString,
208  void (T::*methodPtr)( A0, A1 ),
209  const A0 & arg0,
210  const A1 & arg1 ) {
211  typedef typename ::std::set< H * >::const_iterator HGroupConstIterator;
212  typedef ::std::map< ::std::string, RemoteObjMethodFunctor2< T, A0, A1 > > FunctorGroup;
213 
214  FunctorGroup result;
215 
216  HGroupConstIterator i = hGroup.begin( );
217  const HGroupConstIterator iEnd = hGroup.end( );
218 
219  for ( ; i != iEnd; ++i ) {
220  RemoteObjHandleT< T > * const h = *i;
221 
222  if ( h == 0 )
223  continue;
224 
225  result.insert(
226  ::std::make_pair(
227  h->doName( ),
228  RemoteObjMethodFunctor2< T, A0, A1 >(
229  h,
230  makeRemoteObjCallString( methodName, paramString ),
231  methodPtr,
232  arg0,
233  arg1 ) ) );
234  }
235 
236  return result;
237 }
238 
239 
240 template < typename T, typename H,
241  typename A0,
242  typename A1,
243  typename A2 >
244 ::std::map< ::std::string, RemoteObjMethodFunctor3< T, A0, A1, A2 > >
245 makeRemoteObjMethodFunctorGroup(
246  const ::std::set< H * > & hGroup,
247  const ::std::string & methodName,
248  const ::std::string & paramString,
249  void (T::*methodPtr)( A0, A1, A2 ),
250  const A0 & arg0,
251  const A1 & arg1,
252  const A2 & arg2 ) {
253  typedef typename ::std::set< H * >::const_iterator HGroupConstIterator;
254  typedef ::std::map< ::std::string,
255  RemoteObjMethodFunctor3< T, A0, A1, A2 > >
256  FunctorGroup;
257 
258  FunctorGroup result;
259 
260  HGroupConstIterator i = hGroup.begin( );
261  const HGroupConstIterator iEnd = hGroup.end( );
262 
263  for ( ; i != iEnd; ++i ) {
264  RemoteObjHandleT< T > * const h = *i;
265 
266  if ( h == 0 )
267  continue;
268 
269  result.insert(
270  ::std::make_pair(
271  h->doName( ),
272  RemoteObjMethodFunctor3< T, A0, A1, A2 >(
273  h,
274  makeRemoteObjCallString( methodName, paramString ),
275  methodPtr,
276  arg0,
277  arg1,
278  arg2 ) ) );
279  }
280 
281  return result;
282 }
283 
284 
285 template < typename T, typename H,
286  typename A0,
287  typename A1,
288  typename A2,
289  typename A3 >
290 ::std::map< ::std::string, RemoteObjMethodFunctor4< T, A0, A1, A2, A3 > >
291 makeRemoteObjMethodFunctorGroup(
292  const ::std::set< H * > & hGroup,
293  const ::std::string & methodName,
294  const ::std::string & paramString,
295  void (T::*methodPtr)( A0, A1, A2, A3 ),
296  const A0 & arg0,
297  const A1 & arg1,
298  const A2 & arg2,
299  const A3 & arg3 ) {
300  typedef typename ::std::set< H * >::const_iterator HGroupConstIterator;
301  typedef ::std::map< ::std::string,
302  RemoteObjMethodFunctor4< T, A0, A1, A2, A3 > >
303  FunctorGroup;
304 
305  FunctorGroup result;
306 
307  HGroupConstIterator i = hGroup.begin( );
308  const HGroupConstIterator iEnd = hGroup.end( );
309 
310  for ( ; i != iEnd; ++i ) {
311  RemoteObjHandleT< T > * const h = *i;
312 
313  if ( h == 0 )
314  continue;
315 
316  result.insert(
317  ::std::make_pair(
318  h->doName( ),
319  RemoteObjMethodFunctor4< T, A0, A1, A2, A3 >(
320  h,
321  makeRemoteObjCallString( methodName, paramString ),
322  methodPtr,
323  arg0,
324  arg1,
325  arg2,
326  arg3 ) ) );
327  }
328 
329  return result;
330 }
331 
332 
333 template < typename T, typename H,
334  typename A0,
335  typename A1,
336  typename A2,
337  typename A3,
338  typename A4 >
339 ::std::map< ::std::string, RemoteObjMethodFunctor5< T, A0, A1, A2, A3, A4 > >
340 makeRemoteObjMethodFunctorGroup(
341  const ::std::set< H * > & hGroup,
342  const ::std::string & methodName,
343  const ::std::string & paramString,
344  void (T::*methodPtr)( A0, A1, A2, A3, A4 ),
345  const A0 & arg0,
346  const A1 & arg1,
347  const A2 & arg2,
348  const A3 & arg3,
349  const A4 & arg4 ) {
350  typedef typename ::std::set< H * >::const_iterator HGroupConstIterator;
351  typedef ::std::map< ::std::string,
352  RemoteObjMethodFunctor5< T, A0, A1, A2, A3, A4 > >
353  FunctorGroup;
354 
355  FunctorGroup result;
356 
357  HGroupConstIterator i = hGroup.begin( );
358  const HGroupConstIterator iEnd = hGroup.end( );
359 
360  for ( ; i != iEnd; ++i ) {
361  RemoteObjHandleT< T > * const h = *i;
362 
363  if ( h == 0 )
364  continue;
365 
366  result.insert(
367  ::std::make_pair(
368  h->doName( ),
369  RemoteObjMethodFunctor5< T, A0, A1, A2, A3, A4 >(
370  h,
371  makeRemoteObjCallString( methodName, paramString ),
372  methodPtr,
373  arg0,
374  arg1,
375  arg2,
376  arg3,
377  arg4 ) ) );
378  }
379 
380  return result;
381 }
382 
383 
384 template < typename T, typename H,
385  typename A0,
386  typename A1,
387  typename A2,
388  typename A3,
389  typename A4,
390  typename A5,
391  typename A6,
392  typename A7,
393  typename A8 >
394 ::std::map< ::std::string,
395  RemoteObjMethodFunctor9< T, A0, A1, A2, A3, A4, A5, A6, A7, A8 > >
396 makeRemoteObjMethodFunctorGroup(
397  const ::std::set< H * > & hGroup,
398  const ::std::string & methodName,
399  const ::std::string & paramString,
400  void (T::*methodPtr)( A0, A1, A2, A3, A4, A5, A6, A7, A8 ),
401  const A0 & arg0,
402  const A1 & arg1,
403  const A2 & arg2,
404  const A3 & arg3,
405  const A4 & arg4,
406  const A5 & arg5,
407  const A6 & arg6,
408  const A7 & arg7,
409  const A8 & arg8 ) {
410  typedef typename ::std::set< H * >::const_iterator HGroupConstIterator;
411  typedef ::std::map< ::std::string,
412  RemoteObjMethodFunctor9< T, A0, A1, A2, A3, A4, A5, A6, A7, A8 > >
413  FunctorGroup;
414 
415  FunctorGroup result;
416 
417  HGroupConstIterator i = hGroup.begin( );
418  const HGroupConstIterator iEnd = hGroup.end( );
419 
420  for ( ; i != iEnd; ++i ) {
421  RemoteObjHandleT< T > * const h = *i;
422 
423  if ( h == 0 )
424  continue;
425 
426  result.insert(
427  ::std::make_pair(
428  h->doName( ),
429  RemoteObjMethodFunctor9< T, A0, A1, A2, A3, A4, A5, A6, A7, A8 >(
430  h,
431  makeRemoteObjCallString( methodName, paramString ),
432  methodPtr,
433  arg0,
434  arg1,
435  arg2,
436  arg3,
437  arg4,
438  arg5,
439  arg6,
440  arg7,
441  arg8 ) ) );
442  }
443 
444  return result;
445 }
446 
447 } // namespace carma::control
448 } // namespace carma
449 
450 
451 #endif