Merge "Change PixelData to use the handle/body pattern" into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / common / message.h
1 #ifndef __DALI_INTERNAL_MESSAGE_H__
2 #define __DALI_INTERNAL_MESSAGE_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/common/buffer-index.h>
23 #include <dali/internal/common/type-abstraction.h>
24 #include <dali/internal/update/common/scene-graph-buffers.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 /**
33  * An abstract base class for messages queued across threads.
34  * Messages are only allowed to contain value objects, either copies of the parameters or pointers
35  * If message parameter type is & or const& the message will try to take a copy of the actual type
36  */
37 class MessageBase
38 {
39 public:
40
41   /**
42    * Construct the message base.
43    */
44   MessageBase( )
45   {
46   }
47
48   /**
49    * Virtual destructor
50    */
51   virtual ~MessageBase()
52   {
53   }
54
55   /**
56    * Called to process the message.
57    * @param [in] bufferIndex The current update/render buffer index (depending on which thread processes the message).
58    */
59   virtual void Process( BufferIndex bufferIndex ) = 0;
60
61 private:
62 };
63
64 /**
65  * Templated message which calls a member function of an object.
66  * This allows nodes etc. to be modified in a thread-safe manner, when the update occurs in a separate thread.
67  * The object lifetime must controlled i.e. not destroyed before the message is processed.
68  */
69 template< typename T >
70 class Message : public MessageBase
71 {
72 public:
73
74   typedef void(T::*MemberFunction)();
75
76   /**
77    * Create a message.
78    * @note The object is expected to be const in the thread which sends this message.
79    * However it can be modified when Process() is called in a different thread.
80    * @param[in] obj The object to be updated in a separate thread.
81    * @param[in] member The member function of the object.
82    */
83   Message( const T* obj, MemberFunction member )
84   : MessageBase(),
85     object( const_cast< T* >( obj ) ),
86     memberFunction( member )
87   {
88   }
89
90   /**
91    * Virtual destructor
92    */
93   virtual ~Message()
94   {
95   }
96
97   /**
98    * @copydoc MessageBase::Process
99    */
100   virtual void Process( BufferIndex /*bufferIndex*/ )
101   {
102     DALI_ASSERT_DEBUG( object && "Message does not have an object" );
103     (object->*memberFunction)();
104   }
105
106 private:
107
108   T* object;
109   MemberFunction memberFunction;
110
111 };
112
113 /**
114  * Templated message which calls a member function of an object.
115  * This overload passes one value-type parameter.
116  * Template parameters need to match the MemberFunction!
117  * The message will contain copy of the value (in case of & or const&)
118  */
119 template< typename T, typename P >
120 class MessageValue1 : public MessageBase
121 {
122 public:
123
124   typedef void(T::*MemberFunction)( typename ParameterType< P >::PassingType );
125
126   /**
127    * Create a message.
128    * @note The object is expected to be const in the thread which sends this message.
129    * However it can be modified when Process() is called in a different thread.
130    * @param[in] obj The object.
131    * @param[in] member The member function of the object.
132    * @param[in] p1 The first value-type parameter to pass to the member function.
133    */
134   MessageValue1( const T* obj,
135                  MemberFunction member,
136                  typename ParameterType< P >::PassingType p1 )
137   : MessageBase(),
138     object( const_cast< T* >( obj ) ),
139     memberFunction( member ),
140     param1( p1 )
141   {
142   }
143
144   /**
145    * Virtual destructor
146    */
147   virtual ~MessageValue1()
148   {
149   }
150
151   /**
152    * @copydoc MessageBase::Process
153    */
154   virtual void Process( BufferIndex /*bufferIndex*/ )
155   {
156     DALI_ASSERT_DEBUG( object && "Message does not have an object" );
157     (object->*memberFunction)( ParameterType< P >::PassObject( param1 ) );
158   }
159
160 private:
161
162   T* object;
163   MemberFunction memberFunction;
164   typename ParameterType< P >::HolderType param1;
165
166 };
167
168 /**
169  * Templated message which calls a member function of an object.
170  * This overload passes two value-type parameters.
171  * Template parameters need to match the MemberFunction!
172  * The message will contain copy of the value (in case of & or const&)
173  */
174
175 template< typename T, typename P1, typename P2 >
176 class MessageValue2 : public MessageBase
177 {
178 public:
179
180   typedef void(T::*MemberFunction)(
181       typename ParameterType< P1 >::PassingType,
182       typename ParameterType< P2 >::PassingType );
183
184   /**
185    * Create a message.
186    * @note The object is expected to be const in the thread which sends this message.
187    * However it can be modified when Process() is called in a different thread.
188    * @param[in] obj The object.
189    * @param[in] member The member function of the object.
190    * @param[in] p1 The first parameter to pass to the member function.
191    * @param[in] p2 The second parameter to pass to the member function.
192    */
193   MessageValue2( const T* obj,
194                  MemberFunction member,
195                  typename ParameterType< P1 >::PassingType p1,
196                  typename ParameterType< P2 >::PassingType p2 )
197   : MessageBase(),
198     object( const_cast< T* >( obj ) ),
199     memberFunction( member ),
200     param1( p1 ),
201     param2( p2 )
202   {
203   }
204
205   /**
206    * Virtual destructor
207    */
208   virtual ~MessageValue2()
209   {
210   }
211
212   /**
213    * @copydoc MessageBase::Process
214    */
215   virtual void Process( BufferIndex /*bufferIndex*/ )
216   {
217     DALI_ASSERT_DEBUG( object && "Message does not have an object" );
218     (object->*memberFunction)(
219         ParameterType< P1 >::PassObject( param1 ),
220         ParameterType< P2 >::PassObject( param2 ) );
221   }
222
223 private:
224
225   T* object;
226   MemberFunction memberFunction;
227   typename ParameterType< P1 >::HolderType param1;
228   typename ParameterType< P2 >::HolderType param2;
229
230 };
231
232 /**
233  * Templated message which calls a member function of an object.
234  * This overload passes three value-type parameters.
235  * Template parameters need to match the MemberFunction!
236  * The message will contain copy of the value (in case of & or const&)
237  */
238 template< typename T, typename P1, typename P2, typename P3 >
239 class MessageValue3 : public MessageBase
240 {
241 public:
242
243   typedef void(T::*MemberFunction)(
244       typename ParameterType< P1 >::PassingType,
245       typename ParameterType< P2 >::PassingType,
246       typename ParameterType< P3 >::PassingType );
247
248   /**
249    * Create a message.
250    * @note The object is expected to be const in the thread which sends this message.
251    * However it can be modified when Process() is called in a different thread.
252    * @param[in] obj The object.
253    * @param[in] member The member function of the object.
254    * @param[in] p1 The first parameter to pass to the member function.
255    * @param[in] p2 The second parameter to pass to the member function.
256    * @param[in] p3 The third parameter to pass to the member function.
257    */
258   MessageValue3( const T* obj,
259                  MemberFunction member,
260                  typename ParameterType< P1 >::PassingType p1,
261                  typename ParameterType< P2 >::PassingType p2,
262                  typename ParameterType< P3 >::PassingType p3 )
263   : MessageBase(),
264     object( const_cast< T* >( obj ) ),
265     memberFunction( member ),
266     param1( p1 ),
267     param2( p2 ),
268     param3( p3 )
269   {
270   }
271
272   /**
273    * Virtual destructor
274    */
275   virtual ~MessageValue3()
276   {
277   }
278
279   /**
280    * @copydoc MessageBase::Process
281    */
282   virtual void Process( BufferIndex /*bufferIndex*/ )
283   {
284     DALI_ASSERT_DEBUG( object && "Message does not have an object" );
285     (object->*memberFunction)(
286         ParameterType< P1 >::PassObject( param1 ),
287         ParameterType< P2 >::PassObject( param2 ),
288         ParameterType< P3 >::PassObject( param3 ) );
289   }
290
291 private:
292
293   T* object;
294   MemberFunction memberFunction;
295   typename ParameterType< P1 >::HolderType param1;
296   typename ParameterType< P2 >::HolderType param2;
297   typename ParameterType< P3 >::HolderType param3;
298
299 };
300
301 /**
302  * Templated message which calls a member function of an object.
303  * This overload passes four value-type parameters.
304  * Template parameters need to match the MemberFunction!
305  * The message will contain copy of the value (in case of & or const&)
306  */
307 template< typename T, typename P1, typename P2, typename P3, typename P4 >
308 class MessageValue4 : public MessageBase
309 {
310 public:
311
312   typedef void(T::*MemberFunction)(
313       typename ParameterType< P1 >::PassingType,
314       typename ParameterType< P2 >::PassingType,
315       typename ParameterType< P3 >::PassingType,
316       typename ParameterType< P4 >::PassingType );
317
318   /**
319    * Create a message.
320    * @note The object is expected to be const in the thread which sends this message.
321    * However it can be modified when Process() is called in a different thread.
322    * @param[in] obj The object.
323    * @param[in] member The member function of the object.
324    * @param[in] p1 The first parameter to pass to the member function.
325    * @param[in] p2 The second parameter to pass to the member function.
326    * @param[in] p3 The third parameter to pass to the member function.
327    * @param[in] p4 The fourth parameter to pass to the member function.
328    */
329   MessageValue4( const T* obj,
330                  MemberFunction member,
331                  typename ParameterType< P1 >::PassingType p1,
332                  typename ParameterType< P2 >::PassingType p2,
333                  typename ParameterType< P3 >::PassingType p3,
334                  typename ParameterType< P4 >::PassingType p4 )
335   : MessageBase(),
336     object( const_cast< T* >( obj ) ),
337     memberFunction( member ),
338     param1( p1 ),
339     param2( p2 ),
340     param3( p3 ),
341     param4( p4 )
342   {
343   }
344
345   /**
346    * Virtual destructor
347    */
348   virtual ~MessageValue4()
349   {
350   }
351
352   /**
353    * @copydoc MessageBase::Process
354    */
355   virtual void Process( BufferIndex /*bufferIndex*/ )
356   {
357     DALI_ASSERT_DEBUG( object && "Message does not have an object" );
358     (object->*memberFunction)(
359         ParameterType< P1 >::PassObject( param1 ),
360         ParameterType< P2 >::PassObject( param2 ),
361         ParameterType< P3 >::PassObject( param3 ),
362         ParameterType< P4 >::PassObject( param4 ) );
363   }
364
365 private:
366
367   T* object;
368   MemberFunction memberFunction;
369   typename ParameterType< P1 >::HolderType param1;
370   typename ParameterType< P2 >::HolderType param2;
371   typename ParameterType< P3 >::HolderType param3;
372   typename ParameterType< P4 >::HolderType param4;
373
374 };
375
376 /**
377  * Templated message which calls a member function of an object.
378  * This overload passes five value-type parameters.
379  * Template parameters need to match the MemberFunction!
380  * The message will contain copy of the value (in case of & or const&)
381  */
382 template< typename T, typename P1, typename P2, typename P3, typename P4, typename P5 >
383 class MessageValue5 : public MessageBase
384 {
385 public:
386
387   typedef void(T::*MemberFunction)(
388       typename ParameterType< P1 >::PassingType,
389       typename ParameterType< P2 >::PassingType,
390       typename ParameterType< P3 >::PassingType,
391       typename ParameterType< P4 >::PassingType,
392       typename ParameterType< P5 >::PassingType );
393
394   /**
395    * Create a message.
396    * @note The object is expected to be const in the thread which sends this message.
397    * However it can be modified when Process() is called in a different thread.
398    * @param[in] obj The object.
399    * @param[in] member The member function of the object.
400    * @param[in] p1 The first parameter to pass to the member function.
401    * @param[in] p2 The second parameter to pass to the member function.
402    * @param[in] p3 The third parameter to pass to the member function.
403    * @param[in] p4 The fourth parameter to pass to the member function.
404    * @param[in] p5 The fifth parameter to pass to the member function.
405    */
406   MessageValue5( const T* obj,
407                  MemberFunction member,
408                  typename ParameterType< P1 >::PassingType p1,
409                  typename ParameterType< P2 >::PassingType p2,
410                  typename ParameterType< P3 >::PassingType p3,
411                  typename ParameterType< P4 >::PassingType p4,
412                  typename ParameterType< P5 >::PassingType p5 )
413   : MessageBase(),
414     object( const_cast< T* >( obj ) ),
415     memberFunction( member ),
416     param1( p1 ),
417     param2( p2 ),
418     param3( p3 ),
419     param4( p4 ),
420     param5( p5 )
421   {
422   }
423
424   /**
425    * Virtual destructor
426    */
427   virtual ~MessageValue5()
428   {
429   }
430
431   /**
432    * @copydoc MessageBase::Process
433    */
434   virtual void Process( BufferIndex /*bufferIndex*/ )
435   {
436     DALI_ASSERT_DEBUG( object && "Message does not have an object" );
437     (object->*memberFunction)(
438         ParameterType< P1 >::PassObject( param1 ),
439         ParameterType< P2 >::PassObject( param2 ),
440         ParameterType< P3 >::PassObject( param3 ),
441         ParameterType< P4 >::PassObject( param4 ),
442         ParameterType< P5 >::PassObject( param5 ) );
443
444   }
445
446 private:
447
448   T* object;
449   MemberFunction memberFunction;
450   typename ParameterType< P1 >::HolderType param1;
451   typename ParameterType< P2 >::HolderType param2;
452   typename ParameterType< P3 >::HolderType param3;
453   typename ParameterType< P4 >::HolderType param4;
454   typename ParameterType< P5 >::HolderType param5;
455
456 };
457
458 /**
459  * Templated message which calls a member function of an object.
460  * This overload passes six value-type parameters.
461  * Template parameters need to match the MemberFunction!
462  * The message will contain copy of the value (in case of & or const&)
463  */
464 template< typename T, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6 >
465 class MessageValue6 : public MessageBase
466 {
467 public:
468
469   typedef void(T::*MemberFunction)(
470       typename ParameterType< P1 >::PassingType,
471       typename ParameterType< P2 >::PassingType,
472       typename ParameterType< P3 >::PassingType,
473       typename ParameterType< P4 >::PassingType,
474       typename ParameterType< P5 >::PassingType,
475       typename ParameterType< P6 >::PassingType );
476
477   /**
478    * Create a message.
479    * @note The object is expected to be const in the thread which sends this message.
480    * However it can be modified when Process() is called in a different thread.
481    * @param[in] obj The object.
482    * @param[in] member The member function of the object.
483    * @param[in] p1 The first parameter to pass to the member function.
484    * @param[in] p2 The second parameter to pass to the member function.
485    * @param[in] p3 The third parameter to pass to the member function.
486    * @param[in] p4 The fourth parameter to pass to the member function.
487    * @param[in] p5 The fifth parameter to pass to the member function.
488    * @param[in] p6 The sixth parameter to pass to the member function.
489    */
490   MessageValue6( const T* obj,
491                  MemberFunction member,
492                  typename ParameterType< P1 >::PassingType p1,
493                  typename ParameterType< P2 >::PassingType p2,
494                  typename ParameterType< P3 >::PassingType p3,
495                  typename ParameterType< P4 >::PassingType p4,
496                  typename ParameterType< P5 >::PassingType p5,
497                  typename ParameterType< P6 >::PassingType p6 )
498   : MessageBase(),
499     object( const_cast< T* >( obj ) ),
500     memberFunction( member ),
501     param1( p1 ),
502     param2( p2 ),
503     param3( p3 ),
504     param4( p4 ),
505     param5( p5 ),
506     param6( p6 )
507   {
508   }
509
510   /**
511    * Virtual destructor
512    */
513   virtual ~MessageValue6()
514   {
515   }
516
517   /**
518    * @copydoc MessageBase::Process
519    */
520   virtual void Process( BufferIndex /*bufferIndex*/ )
521   {
522     DALI_ASSERT_DEBUG( object && "Message does not have an object" );
523     (object->*memberFunction)(
524         ParameterType< P1 >::PassObject( param1 ),
525         ParameterType< P2 >::PassObject( param2 ),
526         ParameterType< P3 >::PassObject( param3 ),
527         ParameterType< P4 >::PassObject( param4 ),
528         ParameterType< P5 >::PassObject( param5 ),
529         ParameterType< P6 >::PassObject( param6 ) );
530
531   }
532
533 private:
534
535   T* object;
536   MemberFunction memberFunction;
537   typename ParameterType< P1 >::HolderType param1;
538   typename ParameterType< P2 >::HolderType param2;
539   typename ParameterType< P3 >::HolderType param3;
540   typename ParameterType< P4 >::HolderType param4;
541   typename ParameterType< P5 >::HolderType param5;
542   typename ParameterType< P6 >::HolderType param6;
543
544 };
545
546 /**
547  * Templated message which calls a member function of an object.
548  * This overload passes just the buffer index to the method, no parameters.
549  */
550 template< typename T >
551 class MessageDoubleBuffered0 : public MessageBase
552 {
553 public:
554
555   typedef void(T::*MemberFunction)( BufferIndex );
556
557   /**
558    * Create a message.
559    * @note The object is expected to be const in the thread which sends this message.
560    * However it can be modified when Process() is called in a different thread.
561    * @param[in] obj The object.
562    * @param[in] member The member function of the object.
563    */
564   MessageDoubleBuffered0( const T* obj, MemberFunction member )
565   : MessageBase(),
566     object( const_cast< T* >( obj ) ),
567     memberFunction( member )
568   {
569   }
570
571   /**
572    * Virtual destructor
573    */
574   virtual ~MessageDoubleBuffered0()
575   {
576   }
577
578   /**
579    * @copydoc MessageBase::Process
580    */
581   virtual void Process( BufferIndex bufferIndex )
582   {
583     DALI_ASSERT_DEBUG( object && "Message does not have an object" );
584     (object->*memberFunction)( bufferIndex );
585   }
586
587 private:
588
589   T* object;
590   MemberFunction memberFunction;
591
592 };
593
594
595 /**
596  * Templated message which calls a member function of an object.
597  * This overload passes a value-type to set a double-buffered property.
598  * Template parameters need to match the MemberFunction!
599  * The message will contain copy of the value (in case of & or const&)
600  */
601 template< typename T, typename P >
602 class MessageDoubleBuffered1 : public MessageBase
603 {
604 public:
605
606   typedef void(T::*MemberFunction)(
607       BufferIndex,
608       typename ParameterType< P >::PassingType );
609
610   /**
611    * Create a message.
612    * @note The object is expected to be const in the thread which sends this message.
613    * However it can be modified when Process() is called in a different thread.
614    * @param[in] obj The object.
615    * @param[in] member The member function of the object.
616    * @param[in] p The second parameter to pass.
617    */
618   MessageDoubleBuffered1( const T* obj,
619                           MemberFunction member,
620                           typename ParameterType< P >::PassingType p )
621   : MessageBase(),
622     object( const_cast< T* >( obj ) ),
623     memberFunction( member ),
624     param( p )
625   {
626   }
627
628   /**
629    * Virtual destructor
630    */
631   virtual ~MessageDoubleBuffered1()
632   {
633   }
634
635   /**
636    * @copydoc MessageBase::Process
637    */
638   virtual void Process( BufferIndex bufferIndex )
639   {
640     DALI_ASSERT_DEBUG( object && "Message does not have an object" );
641     (object->*memberFunction)(
642         bufferIndex,
643         ParameterType< P >::PassObject( param ) );
644   }
645
646 private:
647
648   T* object;
649   MemberFunction memberFunction;
650   typename ParameterType< P >::HolderType param;
651
652 };
653
654 /**
655  * Templated message which calls a member function of an object.
656  * This overload passes two value-types to set double-buffered properties.
657  * Template parameters need to match the MemberFunction!
658  * The message will contain copy of the value (in case of & or const&)
659  */
660 template< typename T, typename P2, typename P3 >
661 class MessageDoubleBuffered2 : public MessageBase
662 {
663 public:
664
665   typedef void(T::*MemberFunction)(
666       BufferIndex,
667       typename ParameterType< P2 >::PassingType,
668       typename ParameterType< P3 >::PassingType );
669
670   /**
671    * Create a message.
672    * @note The object is expected to be const in the thread which sends this message.
673    * However it can be modified when Process() is called in a different thread.
674    * @param[in] obj The object.
675    * @param[in] member The member function of the object.
676    * @param[in] p2 The second parameter to pass to the function.
677    * @param[in] p3 The third parameter to pass to the function.
678    */
679   MessageDoubleBuffered2( const T* obj,
680                           MemberFunction member,
681                           typename ParameterType< P2 >::PassingType p2,
682                           typename ParameterType< P3 >::PassingType p3 )
683   : MessageBase(),
684     object( const_cast< T* >( obj ) ),
685     memberFunction( member ),
686     param2( p2 ),
687     param3( p3 )
688   {
689   }
690
691   /**
692    * Virtual destructor
693    */
694   virtual ~MessageDoubleBuffered2()
695   {
696   }
697
698   /**
699    * @copydoc MessageBase::Process
700    */
701   virtual void Process( BufferIndex bufferIndex )
702   {
703     DALI_ASSERT_DEBUG( object && "Message does not have an object" );
704     (object->*memberFunction)(
705         bufferIndex,
706         ParameterType< P2 >::PassObject( param2 ),
707         ParameterType< P3 >::PassObject( param3 ) );
708   }
709
710 private:
711
712   T* object;
713   MemberFunction memberFunction;
714   typename ParameterType< P2 >::HolderType param2;
715   typename ParameterType< P3 >::HolderType param3;
716
717 };
718
719
720 /**
721  * Templated message which calls a member function of an object.
722  * This overload passes three value-types to set double-buffered properties.
723  * Template parameters need to match the MemberFunction!
724  * The message will contain copy of the value (in case of & or const&)
725  */
726 template< typename T, typename P2, typename P3, typename P4 >
727 class MessageDoubleBuffered3 : public MessageBase
728 {
729 public:
730
731   typedef void(T::*MemberFunction)(
732       BufferIndex,
733       typename ParameterType< P2 >::PassingType,
734       typename ParameterType< P3 >::PassingType,
735       typename ParameterType< P4 >::PassingType );
736
737   /**
738    * Create a message.
739    * @note The object is expected to be const in the thread which sends this message.
740    * However it can be modified when Process() is called in a different thread.
741    * @param[in] obj The object.
742    * @param[in] member The member function of the object.
743    * @param[in] p2 The second parameter to pass.
744    * @param[in] p3 The third parameter to pass.
745    * @param[in] p4 The forth parameter to pass.
746    */
747   MessageDoubleBuffered3( const T* obj,
748                           MemberFunction member,
749                           typename ParameterType< P2 >::PassingType p2,
750                           typename ParameterType< P3 >::PassingType p3,
751                           typename ParameterType< P4 >::PassingType p4 )
752   : MessageBase(),
753     object( const_cast< T* >( obj ) ),
754     memberFunction( member ),
755     param2( p2 ),
756     param3( p3 ),
757     param4( p4 )
758   {
759   }
760
761   /**
762    * Virtual destructor
763    */
764   virtual ~MessageDoubleBuffered3()
765   {
766   }
767
768   /**
769    * @copydoc MessageBase::Process
770    */
771   virtual void Process( BufferIndex bufferIndex )
772   {
773     DALI_ASSERT_DEBUG( object && "Message does not have an object" );
774     (object->*memberFunction)(
775         bufferIndex,
776         ParameterType< P2 >::PassObject( param2 ),
777         ParameterType< P3 >::PassObject( param3 ),
778         ParameterType< P4 >::PassObject( param4 ) );
779   }
780
781 private:
782
783   T* object;
784   MemberFunction memberFunction;
785   typename ParameterType< P2 >::HolderType param2;
786   typename ParameterType< P3 >::HolderType param3;
787   typename ParameterType< P4 >::HolderType param4;
788
789 };
790
791 /**
792  * Templated message which calls a member function of an object.
793  * This overload passes four value-types to set double-buffered properties.
794  * Template parameters need to match the MemberFunction!
795  * The message will contain copy of the value (in case of & or const&)
796  */
797 template< typename T, typename P2, typename P3, typename P4, typename P5 >
798 class MessageDoubleBuffered4 : public MessageBase
799 {
800 public:
801
802   typedef void(T::*MemberFunction)(
803       BufferIndex,
804       typename ParameterType< P2 >::PassingType,
805       typename ParameterType< P3 >::PassingType,
806       typename ParameterType< P4 >::PassingType,
807       typename ParameterType< P5 >::PassingType );
808
809   /**
810    * Create a message.
811    * @note The object is expected to be const in the thread which sends this message.
812    * However it can be modified when Process() is called in a different thread.
813    * @param[in] obj The object.
814    * @param[in] member The member function of the object.
815    * @param[in] p2 The second parameter to pass.
816    * @param[in] p3 The third parameter to pass.
817    * @param[in] p4 The forth parameter to pass.
818    * @param[in] p5 The fifth parameter to pass.
819    */
820   MessageDoubleBuffered4( const T* obj,
821                           MemberFunction member,
822                           typename ParameterType< P2 >::PassingType p2,
823                           typename ParameterType< P3 >::PassingType p3,
824                           typename ParameterType< P4 >::PassingType p4,
825                           typename ParameterType< P5 >::PassingType p5 )
826   : MessageBase(),
827     object( const_cast< T* >( obj ) ),
828     memberFunction( member ),
829     param2( p2 ),
830     param3( p3 ),
831     param4( p4 ),
832     param5( p5 )
833   {
834   }
835
836   /**
837    * Virtual destructor
838    */
839   virtual ~MessageDoubleBuffered4()
840   {
841   }
842
843   /**
844    * @copydoc MessageBase::Process
845    */
846   virtual void Process( BufferIndex bufferIndex )
847   {
848     DALI_ASSERT_DEBUG( object && "Message does not have an object" );
849     (object->*memberFunction)(
850         bufferIndex,
851         ParameterType< P2 >::PassObject( param2 ),
852         ParameterType< P3 >::PassObject( param3 ),
853         ParameterType< P4 >::PassObject( param4 ),
854         ParameterType< P5 >::PassObject( param5 ) );
855   }
856
857 private:
858
859   T* object;
860   MemberFunction memberFunction;
861   typename ParameterType< P2 >::HolderType param2;
862   typename ParameterType< P3 >::HolderType param3;
863   typename ParameterType< P4 >::HolderType param4;
864   typename ParameterType< P5 >::HolderType param5;
865
866 };
867
868 } // namespace Internal
869
870 } // namespace Dali
871
872 #endif // __DALI_INTERNAL_MESSAGE_H__