Initialize Tizen 2.3
[framework/web/wrt-commons.git] / modules_mobile / event / include / dpl / event / model_bind_to_dao.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /**
17  * @file    model_bind_to_dao.h
18  * @author  Grzegorz Krawczyk (g.krawczyk@samsung.com)
19  * @version 1.0
20  * @brief
21  */
22
23 #ifndef DPL_MODEL_BIND_TO_DAO_H_
24 #define DPL_MODEL_BIND_TO_DAO_H_
25
26 namespace DPL {
27 namespace Event {
28 /**
29  * @param ObjectType type of object used as delegate argument
30  * @param RetType Type returned from the external function
31  * @param ExtArg Type of argument required by external fun
32  * @param getterFun Object Type method which returns value of type ExtArg
33  * used as argument for external function
34  * */
35 //STATIC FUNCTION
36 template <
37     typename ObjectType,
38     typename ValueType,
39     typename ExtArg,
40     ExtArg(ObjectType::*argGetter) () const,
41     ValueType(*externalGetter) (ExtArg)
42     >
43 struct BindToDAO_Static
44 {
45     static ValueType Get(DPL::Event::Model* obj)
46     {
47         ObjectType* instance = static_cast<ObjectType*>(obj);
48
49         return externalGetter((instance->*argGetter)());
50     }
51 };
52
53 template <
54     typename ObjectType,
55     typename ValueType,
56     typename ExtArg,
57     typename ExtObject,
58     ExtArg(ObjectType::*argGetter) () const,
59     ValueType(ExtObject::*externalGetter) () const
60     >
61 struct BindToDAO
62 {
63     static ValueType Get(DPL::Event::Model* obj)
64     {
65         ObjectType* instance = static_cast<ObjectType*>(obj);
66         ExtObject extObject((instance->*argGetter)());
67         return (extObject.*externalGetter)();
68     }
69 };
70 }
71 }
72
73 #endif