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>
24 #include <dali/public-api/common/vector-wrapper.h>
29 class ConnectionTrackerInterface;
30 class FunctorDelegate;
32 namespace Internal DALI_INTERNAL
37 typedef std::vector<Property::Value> PropertyValueContainer;
38 typedef PropertyValueContainer::iterator PropertyValueIter; ///< Iterator for Dali::PropertyValueContainer
39 typedef PropertyValueContainer::const_iterator PropertyValueConstIter; ///< Const iterator for Dali::PropertyValueContainer
42 * @brief TypeInfo class for instantiation of registered types and introspection of
43 * their actions and signals.
45 * See TypeRegistry for methods of type registration and TypeInfo retrieval.
47 class DALI_IMPORT_API TypeInfo : public BaseHandle
50 typedef BaseHandle (*CreateFunction)(); ///< Function signature for creating an instance of the associated object type.
52 typedef bool (*ActionFunction)(BaseObject*, const std::string&, const PropertyValueContainer&); ///< Function signature for creating scriptable actions
55 * @brief Connects a callback function with the object's signals.
57 * @param[in] object The object providing the signal.
58 * @param[in] tracker Used to disconnect the signal.
59 * @param[in] signalName The signal to connect to.
60 * @param[in] functor A newly allocated FunctorDelegate.
61 * @return True if the signal was connected.
62 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
64 typedef bool (*SignalConnectorFunctionV2)(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
67 * @brief Callback to set an event-thread only property.
69 * @see PropertyRegistration.
70 * @param[in] object The object whose property should be set.
71 * @param[in] index The index of the property being set.
72 * @param[in] value The new value of the property for the object specified.
74 typedef void (*SetPropertyFunction)( BaseObject* object, Property::Index index, const Property::Value& value );
77 * @brief Callback to get the value of an event-thread only property.
79 * @see PropertyRegistration.
80 * @param[in] object The object whose property value is required.
81 * @param[in] index The index of the property required.
82 * @return The current value of the property for the object specified.
84 typedef Property::Value (*GetPropertyFunction)( BaseObject* object, Property::Index index );
86 typedef std::vector<std::string> NameContainer; ///< Container of names for signals and actions
89 * @brief Allows the creation of an empty TypeInfo handle.
96 * This is non-virtual since derived Handle types must not contain data or virtual methods.
101 * @brief This copy constructor is required for (smart) pointer semantics.
103 * @param [in] handle A reference to the copied handle
105 TypeInfo(const TypeInfo& handle);
108 * @brief This assignment operator is required for (smart) pointer semantics.
110 * @param [in] rhs A reference to the copied handle
111 * @return A reference to this
113 TypeInfo& operator=(const TypeInfo& rhs);
116 * @brief Retrieve the type name for this type.
118 * @return string name
120 const std::string& GetName() const;
123 * @brief Retrieve the base type name for this type.
125 * @return string of base name
127 const std::string& GetBaseName() const;
130 * @brief Create an object from this type.
132 * @return the BaseHandle for the newly created object
134 BaseHandle CreateInstance() const;
137 * @brief Retrieve the creator function for this type.
139 * @return the creator function
141 CreateFunction GetCreator() const;
144 * @brief Retrieve the actions for this type.
146 * @param[in] container of action names
148 void GetActions( NameContainer &container ) const;
151 * @brief Retrieve the signals for this type.
153 * @param[in] container of action names
155 void GetSignals( NameContainer &container ) const;
158 * @brief Retrieve the event side registered properties for this type.
160 * @param[in] container of action names
162 void GetProperties( NameContainer &container ) const;
167 * @brief Retrieve all the property indices for this type.
169 * @param[out] indices Container of property indices
170 * @note The container will be cleared
172 void GetPropertyIndices( Property::IndexContainer& indices ) const;
175 * @brief Given a property index, retrieve the property name associated with it.
177 * @param[in] index The property index.
178 * @return The name of the property at the given index.
180 const std::string& GetPropertyName( Property::Index index ) const;
182 public: // Not intended for application developers
185 * @brief This constructor is used by Dali Get() method.
187 * @param [in] typeInfo A pointer to a Dali resource
189 explicit DALI_INTERNAL TypeInfo(Internal::TypeInfo* typeInfo);
195 #endif // __DALI_TYPE_INFO_H__