191a7b8e054b30c640d2356b3bcb922d0836701e
[platform/core/uifw/dali-core.git] / dali / public-api / common / type-traits.h
1 #ifndef __DALI_TYPE_TRAITS_H__
2 #define __DALI_TYPE_TRAITS_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 namespace Dali
22 {
23 /**
24  * @addtogroup dali_core_common
25  * @{
26  */
27
28 /**
29  * @brief Basic type traits that every type has by default.
30  *
31  * This allows specializations to not have to repeat all flags
32  * @SINCE_1_0.0
33  */
34 template <typename Type>
35 struct BasicTypes
36 {
37   /**
38    * @brief This flag tells Dali if a class can be considered POD.
39    *
40    * If it declares copy constructor and/or destructor, its not considered trivial
41    * and cannot be copied by using memcpy etc.
42    * @SINCE_1_0.0
43    */
44   enum { IS_TRIVIAL_TYPE = __has_trivial_destructor(Type) && __has_trivial_copy(Type) };
45 };
46
47 /**
48  * @brief Type traits.
49  *
50  * An example of overriding a traits flag for a custom type can be done by:
51  *
52  * @code
53  *
54  * namespace Dali
55  * {
56  *   /// Tell DALi that Dali::Matrix is POD, even though it has a copy constructor
57  *   template <> struct TypeTraits< Dali::Matrix > : public BasicTypes< Dali::Matrix > { enum { IS_TRIVIAL_TYPE = true }; };
58  * }
59  *
60  * @endcode
61  *
62  * @SINCE_1_0.0
63  */
64 template <typename Type>
65 struct TypeTraits : public BasicTypes< Type >
66 {
67 };
68
69 /**
70  * @}
71  */
72 } // namespace Dali
73
74 #endif /* __DALI_TYPE_TRAITS_H__ */