Initialize Tizen 2.3
[framework/web/wrt-plugins-common.git] / src_wearable / plugins-api-support / detail / traits.h
1 /*
2  * Copyright (c) 2012 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   traits.h
18  * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
19  */
20
21 #ifndef _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_DETAIL_TRAITS_H_
22 #define _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_DETAIL_TRAITS_H_
23
24 namespace WrtPluginsApi {
25 namespace Traits {
26 namespace Detail {
27 template<size_t, typename RequiredType, typename ... TupleArgTypes>
28 struct index_of_;
29
30 /*
31  * CurrentArgType is not equal to RequiredType, check next tuple's argument
32  */
33 template<size_t n,
34          typename RequiredType,
35          typename CurrentArgType,
36          typename ... TupleArgTypes>
37 struct index_of_<n, RequiredType, CurrentArgType, TupleArgTypes ...>
38 {
39     static const size_t value = index_of_<n + 1,
40                                           RequiredType,
41                                           TupleArgTypes ...>::value;
42 };
43
44 /*
45  * RequiredType found on tuple's args list
46  * return position on tuple's list
47  */
48 template<size_t n, typename RequiredType, typename ... TupleArgTypes>
49 struct index_of_<n, RequiredType, RequiredType, TupleArgTypes ...>
50 {
51     static const size_t value = n;
52 };
53
54 /*
55  * RequiredType found on last position of tuple's args list
56  * return position on tuple's list
57  */
58 template<size_t n, typename RequiredType>
59 struct index_of_<n, RequiredType, RequiredType>
60 {
61     static const size_t value = n;
62 };
63
64 /*
65  * RequiredType was not found on tuple args list
66  */
67 template<size_t n, typename RequiredType, typename LastArgType>
68 struct index_of_<n, RequiredType, LastArgType>
69 {
70     static const size_t value = -1;
71 };
72 }
73 }
74 }
75
76 #endif