tizen 2.4 release
[framework/web/wrt-commons.git] / modules / event / include / dpl / event / property.h
@@ -67,6 +67,10 @@ namespace Event {
  *                               been received from external source, it will
  *                               never be updated externally.
  *
+ * PropertyStorageDynamicInitCached: The data is stored internally at construction
+ *                                   with read delegate. Changed data is stored
+ *                                   internally and also set remotely with delegate.
+ *
  * Property access modes:
  *
  * PropertyReadOnly: Property is a read-only property.
@@ -196,9 +200,10 @@ namespace Event {
  *         std::bind(&Receiver::OnValueChanged, &receiver));
  * }
  */
-struct PropertyStorageCached {};        ///< Always use cached
-struct PropertyStorageDynamic {};       ///< Always use dynamic
-struct PropertyStorageDynamicCached {}; ///< Use dynamic then cache
+struct PropertyStorageCached {};              ///< Always use cached
+struct PropertyStorageDynamic {};             ///< Always use dynamic
+struct PropertyStorageDynamicCached {};       ///< Use dynamic then cache
+struct PropertyStorageDynamicInitCached {};   ///< Use cached with dynamic initialization
 
 struct PropertyReadOnly {};  ///< Read only, not setter available
 struct PropertyReadWrite {}; ///< Read and write
@@ -369,6 +374,41 @@ class PropertyStorageMethod<Type,
     }
 };
 
+template<typename Type,
+         typename ReadDelegateType,
+         typename WriteDelegateType>
+class PropertyStorageMethod<Type,
+                            PropertyStorageDynamicInitCached,
+                            ReadDelegateType,
+                            WriteDelegateType>:
+    protected PropertyStorageMethodBase,
+    protected PropertyStorageMethodDynamicBase<ReadDelegateType,
+                                               WriteDelegateType>,
+    protected PropertyStorageMethodCachedBase<Type>
+{
+  public:
+    PropertyStorageMethod(Model *model,
+                          ReadDelegateType readValue,
+                          WriteDelegateType writeValue) :
+        PropertyStorageMethodBase(model),
+        PropertyStorageMethodDynamicBase<ReadDelegateType, WriteDelegateType>(
+            readValue, writeValue)
+    {
+        this->m_value = this->m_readValue(m_model);
+    }
+
+    Type Get() const
+    {
+        return this->m_value;
+    }
+
+    void Set(const Type& value)
+    {
+        this->m_value = value;
+        this->m_writeValue(value, m_model);
+    }
+};
+
 template<typename Type, typename StorageMethod>
 class PropertyBase :
     protected EventSupport<PropertyEvent<Type> >