Remove SystemOverlay.
[platform/core/uifw/dali-core.git] / dali / internal / common / message.h
index a1068ae..1aaa4c9 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_MESSAGE_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -85,6 +85,7 @@ public:
     object( const_cast< T* >( obj ) ),
     memberFunction( member )
   {
+    DALI_ASSERT_DEBUG( object && "nullptr passed into message as object" );
   }
 
   /**
@@ -99,7 +100,6 @@ public:
    */
   virtual void Process( BufferIndex /*bufferIndex*/ )
   {
-    DALI_ASSERT_DEBUG( object && "Message does not have an object" );
     (object->*memberFunction)();
   }
 
@@ -139,6 +139,7 @@ public:
     memberFunction( member ),
     param1( p1 )
   {
+    DALI_ASSERT_DEBUG( object && "nullptr passed into message as object" );
   }
 
   /**
@@ -153,8 +154,7 @@ public:
    */
   virtual void Process( BufferIndex /*bufferIndex*/ )
   {
-    DALI_ASSERT_DEBUG( object && "Message does not have an object" );
-    (object->*memberFunction)( ParameterType< P >::PassObject( param1 ) );
+    (object->*memberFunction)( param1 );
   }
 
 private:
@@ -200,6 +200,7 @@ public:
     param1( p1 ),
     param2( p2 )
   {
+    DALI_ASSERT_DEBUG( object && "nullptr passed into message as object" );
   }
 
   /**
@@ -214,10 +215,7 @@ public:
    */
   virtual void Process( BufferIndex /*bufferIndex*/ )
   {
-    DALI_ASSERT_DEBUG( object && "Message does not have an object" );
-    (object->*memberFunction)(
-        ParameterType< P1 >::PassObject( param1 ),
-        ParameterType< P2 >::PassObject( param2 ) );
+    (object->*memberFunction)( param1, param2 );
   }
 
 private:
@@ -267,6 +265,7 @@ public:
     param2( p2 ),
     param3( p3 )
   {
+    DALI_ASSERT_DEBUG( object && "nullptr passed into message as object" );
   }
 
   /**
@@ -281,11 +280,7 @@ public:
    */
   virtual void Process( BufferIndex /*bufferIndex*/ )
   {
-    DALI_ASSERT_DEBUG( object && "Message does not have an object" );
-    (object->*memberFunction)(
-        ParameterType< P1 >::PassObject( param1 ),
-        ParameterType< P2 >::PassObject( param2 ),
-        ParameterType< P3 >::PassObject( param3 ) );
+    (object->*memberFunction)( param1, param2, param3 );
   }
 
 private:
@@ -340,6 +335,7 @@ public:
     param3( p3 ),
     param4( p4 )
   {
+    DALI_ASSERT_DEBUG( object && "nullptr passed into message as object" );
   }
 
   /**
@@ -354,12 +350,7 @@ public:
    */
   virtual void Process( BufferIndex /*bufferIndex*/ )
   {
-    DALI_ASSERT_DEBUG( object && "Message does not have an object" );
-    (object->*memberFunction)(
-        ParameterType< P1 >::PassObject( param1 ),
-        ParameterType< P2 >::PassObject( param2 ),
-        ParameterType< P3 >::PassObject( param3 ),
-        ParameterType< P4 >::PassObject( param4 ) );
+    (object->*memberFunction)( param1, param2, param3, param4 );
   }
 
 private:
@@ -419,6 +410,7 @@ public:
     param4( p4 ),
     param5( p5 )
   {
+    DALI_ASSERT_DEBUG( object && "nullptr passed into message as object" );
   }
 
   /**
@@ -433,14 +425,87 @@ public:
    */
   virtual void Process( BufferIndex /*bufferIndex*/ )
   {
-    DALI_ASSERT_DEBUG( object && "Message does not have an object" );
-    (object->*memberFunction)(
-        ParameterType< P1 >::PassObject( param1 ),
-        ParameterType< P2 >::PassObject( param2 ),
-        ParameterType< P3 >::PassObject( param3 ),
-        ParameterType< P4 >::PassObject( param4 ),
-        ParameterType< P5 >::PassObject( param5 ) );
+    (object->*memberFunction)( param1, param2, param3, param4, param5 );
+  }
+
+private:
+
+  T* object;
+  MemberFunction memberFunction;
+  typename ParameterType< P1 >::HolderType param1;
+  typename ParameterType< P2 >::HolderType param2;
+  typename ParameterType< P3 >::HolderType param3;
+  typename ParameterType< P4 >::HolderType param4;
+  typename ParameterType< P5 >::HolderType param5;
+
+};
+
+/**
+ * Templated message which calls a member function of an object.
+ * This overload passes six value-type parameters.
+ * Template parameters need to match the MemberFunction!
+ * The message will contain copy of the value (in case of & or const&)
+ */
+template< typename T, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6 >
+class MessageValue6 : public MessageBase
+{
+public:
+
+  typedef void(T::*MemberFunction)(
+      typename ParameterType< P1 >::PassingType,
+      typename ParameterType< P2 >::PassingType,
+      typename ParameterType< P3 >::PassingType,
+      typename ParameterType< P4 >::PassingType,
+      typename ParameterType< P5 >::PassingType,
+      typename ParameterType< P6 >::PassingType );
 
+  /**
+   * Create a message.
+   * @note The object is expected to be const in the thread which sends this message.
+   * However it can be modified when Process() is called in a different thread.
+   * @param[in] obj The object.
+   * @param[in] member The member function of the object.
+   * @param[in] p1 The first parameter to pass to the member function.
+   * @param[in] p2 The second parameter to pass to the member function.
+   * @param[in] p3 The third parameter to pass to the member function.
+   * @param[in] p4 The fourth parameter to pass to the member function.
+   * @param[in] p5 The fifth parameter to pass to the member function.
+   * @param[in] p6 The sixth parameter to pass to the member function.
+   */
+  MessageValue6( const T* obj,
+                 MemberFunction member,
+                 typename ParameterType< P1 >::PassingType p1,
+                 typename ParameterType< P2 >::PassingType p2,
+                 typename ParameterType< P3 >::PassingType p3,
+                 typename ParameterType< P4 >::PassingType p4,
+                 typename ParameterType< P5 >::PassingType p5,
+                 typename ParameterType< P6 >::PassingType p6 )
+  : MessageBase(),
+    object( const_cast< T* >( obj ) ),
+    memberFunction( member ),
+    param1( p1 ),
+    param2( p2 ),
+    param3( p3 ),
+    param4( p4 ),
+    param5( p5 ),
+    param6( p6 )
+  {
+    DALI_ASSERT_DEBUG( object && "nullptr passed into message as object" );
+  }
+
+  /**
+   * Virtual destructor
+   */
+  virtual ~MessageValue6()
+  {
+  }
+
+  /**
+   * @copydoc MessageBase::Process
+   */
+  virtual void Process( BufferIndex /*bufferIndex*/ )
+  {
+    (object->*memberFunction)( param1, param2, param3, param4, param5, param6 );
   }
 
 private:
@@ -452,11 +517,61 @@ private:
   typename ParameterType< P3 >::HolderType param3;
   typename ParameterType< P4 >::HolderType param4;
   typename ParameterType< P5 >::HolderType param5;
+  typename ParameterType< P6 >::HolderType param6;
 
 };
 
 /**
  * Templated message which calls a member function of an object.
+ * This overload passes just the buffer index to the method, no parameters.
+ */
+template< typename T >
+class MessageDoubleBuffered0 : public MessageBase
+{
+public:
+
+  typedef void(T::*MemberFunction)( BufferIndex );
+
+  /**
+   * Create a message.
+   * @note The object is expected to be const in the thread which sends this message.
+   * However it can be modified when Process() is called in a different thread.
+   * @param[in] obj The object.
+   * @param[in] member The member function of the object.
+   */
+  MessageDoubleBuffered0( const T* obj, MemberFunction member )
+  : MessageBase(),
+    object( const_cast< T* >( obj ) ),
+    memberFunction( member )
+  {
+    DALI_ASSERT_DEBUG( object && "nullptr passed into message as object" );
+  }
+
+  /**
+   * Virtual destructor
+   */
+  virtual ~MessageDoubleBuffered0()
+  {
+  }
+
+  /**
+   * @copydoc MessageBase::Process
+   */
+  virtual void Process( BufferIndex bufferIndex )
+  {
+    (object->*memberFunction)( bufferIndex );
+  }
+
+private:
+
+  T* object;
+  MemberFunction memberFunction;
+
+};
+
+
+/**
+ * Templated message which calls a member function of an object.
  * This overload passes a value-type to set a double-buffered property.
  * Template parameters need to match the MemberFunction!
  * The message will contain copy of the value (in case of & or const&)
@@ -486,6 +601,7 @@ public:
     memberFunction( member ),
     param( p )
   {
+    DALI_ASSERT_DEBUG( object && "nullptr passed into message as object" );
   }
 
   /**
@@ -500,10 +616,7 @@ public:
    */
   virtual void Process( BufferIndex bufferIndex )
   {
-    DALI_ASSERT_DEBUG( object && "Message does not have an object" );
-    (object->*memberFunction)(
-        bufferIndex,
-        ParameterType< P >::PassObject( param ) );
+    (object->*memberFunction)( bufferIndex,  param );
   }
 
 private:
@@ -549,6 +662,7 @@ public:
     param2( p2 ),
     param3( p3 )
   {
+    DALI_ASSERT_DEBUG( object && "nullptr passed into message as object" );
   }
 
   /**
@@ -563,11 +677,7 @@ public:
    */
   virtual void Process( BufferIndex bufferIndex )
   {
-    DALI_ASSERT_DEBUG( object && "Message does not have an object" );
-    (object->*memberFunction)(
-        bufferIndex,
-        ParameterType< P2 >::PassObject( param2 ),
-        ParameterType< P3 >::PassObject( param3 ) );
+    (object->*memberFunction)( bufferIndex, param2, param3 );
   }
 
 private:
@@ -619,6 +729,7 @@ public:
     param3( p3 ),
     param4( p4 )
   {
+    DALI_ASSERT_DEBUG( object && "nullptr passed into message as object" );
   }
 
   /**
@@ -633,12 +744,7 @@ public:
    */
   virtual void Process( BufferIndex bufferIndex )
   {
-    DALI_ASSERT_DEBUG( object && "Message does not have an object" );
-    (object->*memberFunction)(
-        bufferIndex,
-        ParameterType< P2 >::PassObject( param2 ),
-        ParameterType< P3 >::PassObject( param3 ),
-        ParameterType< P4 >::PassObject( param4 ) );
+    (object->*memberFunction)( bufferIndex, param2, param3, param4 );
   }
 
 private:
@@ -694,6 +800,7 @@ public:
     param4( p4 ),
     param5( p5 )
   {
+    DALI_ASSERT_DEBUG( object && "nullptr passed into message as object" );
   }
 
   /**
@@ -708,13 +815,7 @@ public:
    */
   virtual void Process( BufferIndex bufferIndex )
   {
-    DALI_ASSERT_DEBUG( object && "Message does not have an object" );
-    (object->*memberFunction)(
-        bufferIndex,
-        ParameterType< P2 >::PassObject( param2 ),
-        ParameterType< P3 >::PassObject( param3 ),
-        ParameterType< P4 >::PassObject( param4 ),
-        ParameterType< P5 >::PassObject( param5 ) );
+    (object->*memberFunction)( bufferIndex, param2, param3, param4, param5 );
   }
 
 private: