[3.0] Update doxygen comments
[platform/core/uifw/dali-core.git] / dali / public-api / object / type-registry-helper.h
1 #ifndef __DALI_TYPE_REGISTRY_HELPER_H__
2 #define __DALI_TYPE_REGISTRY_HELPER_H__
3
4 /*
5  * Copyright (c) 2016 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 // INTERNAL INCLUDES
22 #include <dali/public-api/common/compile-time-assert.h>
23 #include <dali/public-api/object/type-registry.h>
24
25 /**
26  * @brief Definition for macros that are used internally by the property macros.
27  * Use the the property macros in the section below this one (without the _INTERNAL postfix) when defining properties.
28  * These internal macros exist as to perform the compile-time check on the enumeration order, the __COUNTER__ macro is used twice.
29  * Using it twice within the same macro would result in two different values.
30  */
31 #define DALI_TOKEN_PASTE_EXPAND( x, y ) x ## y
32 #define DALI_TOKEN_PASTE( x, y ) DALI_TOKEN_PASTE_EXPAND(x, y)
33
34 #define DALI_PROPERTY_REGISTRATION_INTERNAL( count, typeRegistrationObject, objectNamespace, objectType, text, valueType, enumIndex ) \
35   Dali::PropertyRegistration DALI_TOKEN_PASTE( property, count ) ( typeRegistrationObject, text, objectNamespace::objectType::Property::enumIndex, Dali::Property::valueType, &objectType::SetProperty, &objectType::GetProperty ); \
36   DALI_COMPILE_TIME_ASSERT( ( objectNamespace::objectType::Property::enumIndex - objectNamespace::objectType::PROPERTY_START_INDEX ) == count );
37 #define DALI_ANIMATABLE_PROPERTY_REGISTRATION_INTERNAL( count, typeRegistrationObject, objectNamespace, objectType, text, valueType, enumIndex) \
38   Dali::AnimatablePropertyRegistration DALI_TOKEN_PASTE( property, count ) ( typeRegistrationObject, text, objectNamespace::objectType::Property::enumIndex, Dali::Property::valueType );
39 #define DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT_INTERNAL( count, typeRegistrationObject, objectNamespace, objectType, text, value, enumIndex) \
40   Dali::AnimatablePropertyRegistration DALI_TOKEN_PASTE( property, count ) ( typeRegistrationObject, text, objectNamespace::objectType::Property::enumIndex, value );
41 #define DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION_INTERNAL( count, typeRegistrationObject, objectNamespace, objectType, text, enumIndex, baseEnumIndex, componentIndex) \
42   Dali::AnimatablePropertyComponentRegistration DALI_TOKEN_PASTE( property, count ) ( typeRegistrationObject, text, objectNamespace::objectType::Property::enumIndex, objectNamespace::objectType::Property::baseEnumIndex, componentIndex );
43 #define DALI_CHILD_PROPERTY_REGISTRATION_INTERNAL( count, typeRegistrationObject, objectNamespace, objectType, text, valueType, enumIndex ) \
44   Dali::ChildPropertyRegistration DALI_TOKEN_PASTE( property, count ) ( typeRegistrationObject, text, objectNamespace::objectType::ChildProperty::enumIndex, Property::valueType );
45 #define DALI_SIGNAL_REGISTRATION_INTERNAL( count, typeRegistrationObject, objectNamespace, objectType, text, textVariable ) \
46   const char* const textVariable = text; \
47   Dali::SignalConnectorType DALI_TOKEN_PASTE( signalConnector, count ) ( typeRegistrationObject, text, &objectNamespace::Internal::objectType::DoConnectSignal );
48 #define DALI_ACTION_REGISTRATION_INTERNAL( count, typeRegistrationObject, objectNamespace, objectType, text, textVariable ) \
49   const char* const textVariable = text; \
50   Dali::TypeAction DALI_TOKEN_PASTE( signalConnector, count ) ( typeRegistrationObject, text, &objectNamespace::Internal::objectType::DoAction );
51
52
53 /**
54  * @brief These macros are used to define properties for implementations of CustomActor.
55  * @SINCE_1_1.36
56  *
57  * These macros should be used when defining properties, signals and actions.
58  * They provide the following benefits:
59  * - A standard and consistent way to define properties.
60  * - Concise definition promotes readability, especially with large numbers of properties.
61  * - Provides a built-in compile-time check. This checks the order of the properties within the enumeration match the order of the property macros. Note: This check is not performed for animatable properties.
62  * - Enforces how properties are enumerated in the object handles header file.
63  *
64  * Note: The compile-type check will produce the following message on failure:
65  *       error: invalid application of 'sizeof' to incomplete type 'Dali::CompileTimeAssertBool<false>'
66  *
67  * Macro usage example:
68  *
69  * Within the your object's implementation cpp:
70  * @code
71  * #include <dali/public-api/object/type-registry-helper.h>
72  * ...
73  * DALI_TYPE_REGISTRATION_BEGIN( MyApp::MyCustomActor, Dali::CustomActor, Create )
74  * DALI_PROPERTY_REGISTRATION( MyApp, MyCustomActor, "myProperty", INTEGER, MY_PROPERTY )
75  * DALI_TYPE_REGISTRATION_END()
76  * @endcode
77  *
78  * Within your handle's header:
79  *
80  * @code
81  * #include <dali/public-api/common/dali-common.h>
82  *
83  *
84  * ///< @brief The start and end property ranges for this control.
85  * enum PropertyRange
86  * {
87  *   PROPERTY_START_INDEX = Dali::PROPERTY_REGISTRATION_START_INDEX,
88  *   PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000
89  * };
90  *
91  * ///< @brief Enumeration for the instance of properties belonging to the Button class.
92  * struct Property
93  * {
94  *   enum
95  *   {
96  *     MY_PROPERTY = PROPERTY_START_INDEX    ///< @brief name "myProperty", type Integer
97  *   };
98  * };
99  * @endcode
100  *
101  * Using these macros have certain prerequisites on how the property enumeration is defined.
102  * Please see the Programming Guide (within the generated Doxygen) for full details.
103  */
104 #define DALI_TYPE_REGISTRATION_BEGIN( thisType, baseType, createFunction ) \
105   Dali::TypeRegistration typeRegistration( typeid( thisType ), typeid( baseType ), createFunction );
106
107 #define DALI_TYPE_REGISTRATION_BEGIN_CREATE( thisType, baseType, createFunction, createAtStartup ) \
108   Dali::TypeRegistration typeRegistration( typeid( thisType ), typeid( baseType ), createFunction, createAtStartup );
109
110 #define DALI_PROPERTY_REGISTRATION( objectNamespace, objectType, text, valueType, enumIndex ) \
111   DALI_PROPERTY_REGISTRATION_INTERNAL( __COUNTER__, typeRegistration, objectNamespace, objectType, text, valueType, enumIndex )
112
113 #define DALI_ANIMATABLE_PROPERTY_REGISTRATION( objectNamespace, objectType, text, valueType, enumIndex ) \
114   DALI_ANIMATABLE_PROPERTY_REGISTRATION_INTERNAL( __COUNTER__, typeRegistration, objectNamespace, objectType, text, valueType, enumIndex )
115
116 #define DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT( objectNamespace, objectType, text, value, enumIndex ) \
117   DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT_INTERNAL( __COUNTER__, typeRegistration, objectNamespace, objectType, text, value, enumIndex )
118
119 #define DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( objectNamespace, objectType, text, enumIndex, baseEnumIndex, componentIndex ) \
120   DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION_INTERNAL( __COUNTER__, typeRegistration, objectNamespace, objectType, text, enumIndex, baseEnumIndex, componentIndex )
121
122 #define DALI_CHILD_PROPERTY_REGISTRATION( objectNamespace, objectType, text, valueType, enumIndex ) \
123   DALI_CHILD_PROPERTY_REGISTRATION_INTERNAL( __COUNTER__, typeRegistration, objectNamespace, objectType, text, valueType, enumIndex )
124
125 #define DALI_SIGNAL_REGISTRATION( objectNamespace, objectType, text, textVariable ) \
126   DALI_SIGNAL_REGISTRATION_INTERNAL( __COUNTER__, typeRegistration, objectNamespace, objectType, text, textVariable )
127
128 #define DALI_ACTION_REGISTRATION( objectNamespace, objectType, text, textVariable ) \
129   DALI_ACTION_REGISTRATION_INTERNAL( __COUNTER__, typeRegistration, objectNamespace, objectType, text, textVariable )
130
131 #define DALI_TYPE_REGISTRATION_END( ) // This macro exists for consistency and readability.
132
133
134 #endif // __DALI_TYPE_REGISTRY_HELPER_H__