1 #ifndef __DALI_TYPE_INFO_H__
2 #define __DALI_TYPE_INFO_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 #include <dali/public-api/object/base-handle.h>
25 namespace Dali DALI_IMPORT_API
28 class ConnectionTrackerInterface;
29 class FunctorDelegate;
31 namespace Internal DALI_INTERNAL
37 * @brief TypeInfo class for instantiation of registered types and introspection of
38 * their actions and signals.
40 * See TypeRegistry for methods of type registration and TypeInfo retrieval.
42 class TypeInfo : public BaseHandle
45 typedef BaseHandle (*CreateFunction)(); ///< Function signature for creating an instance of the associated object type.
47 typedef bool (*ActionFunction)(BaseObject*, const std::string&, const std::vector<Property::Value>&); ///< Function signature for creating scriptable actions
50 * @brief Connects a callback function with the object's signals.
52 * @param[in] object The object providing the signal.
53 * @param[in] tracker Used to disconnect the signal.
54 * @param[in] signalName The signal to connect to.
55 * @param[in] functor A newly allocated FunctorDelegate.
56 * @return True if the signal was connected.
57 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
59 typedef bool (*SignalConnectorFunctionV2)(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
62 * @brief Callback to set an event-thread only property.
64 * @see PropertyRegistration.
65 * @param[in] object The object whose property should be set.
66 * @param[in] index The index of the property being set.
67 * @param[in] value The new value of the property for the object specified.
69 typedef void (*SetPropertyFunction)( BaseObject* object, Property::Index index, const Property::Value& value );
72 * @brief Callback to get the value of an event-thread only property.
74 * @see PropertyRegistration.
75 * @param[in] object The object whose property value is required.
76 * @param[in] index The index of the property required.
77 * @return The current value of the property for the object specified.
79 typedef Property::Value (*GetPropertyFunction)( BaseObject* object, Property::Index index );
81 typedef std::vector<std::string> NameContainer; ///< Container of names for signals and actions
84 * @brief Allows the creation of an empty TypeInfo handle.
91 * This is non-virtual since derived Handle types must not contain data or virtual methods.
96 * @copydoc Dali::BaseHandle::operator=
98 using BaseHandle::operator=;
101 * @brief Retrieve the type name for this type.
103 * @return string name
105 const std::string& GetName();
108 * @brief Retrieve the base type name for this type.
110 * @return string of base name
112 const std::string& GetBaseName();
115 * @brief Create an object from this type.
117 * @return the BaseHandle for the newly created object
119 BaseHandle CreateInstance();
122 * @brief Retrieve the creator function for this type.
124 * @return the creator function
126 CreateFunction GetCreator();
129 * @brief Retrieve the actions for this type.
131 * @return Container of action names
133 NameContainer GetActions();
136 * @brief Retrieve the signals for this type.
138 * @return Container of signal names
140 NameContainer GetSignals();
145 * @brief Retrieve all the property indices for this type.
147 * @param[out] indices Container of property indices
148 * @note The container will be cleared
150 void GetPropertyIndices( Property::IndexContainer& indices ) const;
153 * @brief Given a property index, retrieve the property name associated with it.
155 * @param[in] index The property index.
156 * @return The name of the property at the given index.
158 const std::string& GetPropertyName( Property::Index index ) const;
160 public: // Not intended for application developers
163 * @brief This constructor is used by Dali Get() method.
165 * @param [in] typeInfo A pointer to a Dali resource
167 explicit DALI_INTERNAL TypeInfo(Internal::TypeInfo* typeInfo);
173 #endif // __DALI_TYPE_INFO_H__