Initialize Tizen 2.3
[framework/web/wrt-plugins-common.git] / src_mobile / Commons / FunctionDefinition.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 #ifndef WRTDEVICEAPIS_COMMONS_FUNCTION_DEFINITION_
17 #define WRTDEVICEAPIS_COMMONS_FUNCTION_DEFINITION_
18
19 #include <map>
20 #include <string>
21 #include <Commons/FunctionDeclaration.h>
22
23 namespace WrtDeviceApis {
24 namespace Commons {
25 /**
26  * Creates an empty device cap list. Additional device-caps may be added by
27  * ACE_CREATE_DEVICE_CAP and ACE_ADD_DEVICE_CAP macros
28  */
29 #define ACE_CREATE_DEVICE_CAPS_LIST(device) \
30     WrtDeviceApis::Commons::AceDeviceCaps ace_##device
31
32 /**
33  * Creates an empty api features list. Additional api features may be added by
34  * ACE_CREATE_FEATURE and ACE_ADD_API_FEATURE macros
35  */
36 #define ACE_CREATE_FEATURE_LIST(apifeature) \
37     WrtDeviceApis::Commons::AceFeatures ace_##apifeature
38
39 /**
40  * Creates a device capability which should be later added to device cap list
41  */
42 #define ACE_CREATE_DEVICE_CAP(device_cap_id, cap_id)                      \
43     WrtDeviceApis::Commons::AceDeviceCapability ace_##device_cap_id = \
44         AceDeviceCapability(cap_id, WrtDeviceApis::Commons::AceDeviceCapParams());
45
46 /**
47  * Create an api feature which should be later added to api features list
48  */
49 #define ACE_CREATE_FEATURE(feature_id, feature_api) \
50     WrtDeviceApis::Commons::AceFeature ace_##feature_id = { feature_api \
51     };
52
53 /**
54  * Adds an existing device-cap created by ACE_CREATE_DEVICE_CAP macro to
55  * device cap list
56  */
57 #define ACE_ADD_DEVICE_CAP(device, device_cap_id)   \
58     WrtDeviceApis::Commons::aceAddDeviceCap(ace_##device_cap_id, ace_##device)
59
60 /**
61  * Adds an existing api feature created by ACE_CREATE_FEATURE macro to
62  * api feature list
63  */
64 #define ACE_ADD_API_FEATURE(apifeature, feature_id)     \
65     WrtDeviceApis::Commons::aceAddApiFeature(ace_##feature_id, \
66                                              ace_##apifeature)
67
68 /**
69  * Creates a function definition with given id that uses provided api feature
70  * and device capability lists
71  */
72 #define ACE_CREATE_FUNCTION(function_id, function_name, feature_id, device) \
73     { function_name, ace_##feature_id, ace_##device }
74
75 // Support for param:name begin
76 #define ACE_CREATE_PARAM(param_definition, param_name, position)            \
77     static WrtDeviceApis::Commons::AceDeviceCapParam ace_param_## \
78     param_definition = \
79     { std::string(param_name), position };
80
81 // Support for param:name end
82
83 typedef std::map <std::string, AceFunction> FunctionMapping;
84
85 int aceAddDeviceCap(const AceDeviceCapability &cap,
86                     AceDeviceCaps & instance);
87 int aceAddApiFeature(const AceFeature &apiFeature,
88                      AceFeatures & instance);
89 }
90 } // WrtDeviceApisCommon
91
92 #endif // WRTDEVICEAPIS_COMMONS_FUNCTION_DEFINITION