Updated non-capi public API documentation to new style.
[platform/core/uifw/dali-core.git] / dali / public-api / modeling / model.h
1 #ifndef __DALI_MODEL_H__
2 #define __DALI_MODEL_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // EXTERNAL INCLUDES
22 #include <boost/function.hpp>
23 #include <string>
24
25 // INTERNAL INCLUDES
26 #include <dali/public-api/common/loading-state.h>
27 #include <dali/public-api/object/base-handle.h>
28 #include <dali/public-api/signals/dali-signal-v2.h>
29
30 namespace Dali DALI_IMPORT_API
31 {
32
33 class MeshActor;
34 class Animation;
35
36 namespace Internal DALI_INTERNAL
37 {
38 class Model;
39 }
40
41 /**
42  * @brief A handle to 3D model data loaded as a resource.
43  *
44  * Use ModelActorFactory::BuildActorTree() to create actors from this model.
45  * Use ModelActorFactory::BuildAnimation() to create animations on such actors.
46  */
47 class Model : public BaseHandle
48 {
49 public:
50
51   typedef SignalV2<void (Model)> ModelSignalV2; ///< Signal type
52   typedef SignalV2<void (Model,bool)> ModelSaveSignalV2; ///< Signal type for saving models
53
54   //Signal Names
55   static const char* const SIGNAL_MODEL_LOADING_FINISHED; ///< name "model-loading-finished"
56   static const char* const SIGNAL_MODEL_SAVING_FINISHED;  ///< name "model-saving-finished"
57
58 public:
59   /**
60    * @brief Create an uninitialized Model.
61    *
62    * This can be initialised with Model::New().  Calling member
63    * functions with an uninitialized Dali::Object is not allowed.
64    */
65   Model();
66
67   /**
68    * @brief Asynchronously load a model.
69    *
70    * Connect to SignalLoadingFinished() to determine when the model
71    * has finished loading.
72    *
73    * @param [in] url The url of the model data.
74    * @return A handle to a newly allocated Dali resource.
75    */
76   static Model New(const std::string& url);
77
78   /**
79    * @brief Downcast an Object handle to Model handle.
80    *
81    * If handle points to a Model object the downcast produces valid
82    * handle. If not the returned handle is left uninitialized.
83    *
84    * @param[in] handle to An object
85    * @return handle to an Model object or an uninitialized handle
86    */
87   static Model DownCast( BaseHandle handle );
88
89   /**
90    * @brief Virtual destructor.
91    *
92    * Dali::Object derived classes typically do not contain member data.
93    */
94   virtual ~Model();
95
96   /**
97    * @copydoc Dali::BaseHandle::operator=
98    */
99   using BaseHandle::operator=;
100
101   /**
102    * @brief Query whether the model data has loaded.
103    *
104    * The asynchronous loading begins when the Model object is created.
105    * After the Model object is discarded, the model data will be released from memory.
106    * @return The loading state, either Loading, Success or Failed.
107    */
108   LoadingState GetLoadingState();
109
110   /**
111    * @brief Emitted when the model data loads successfully or when the loading fails.
112    *
113    * @return A signal object to Connect() with.
114    */
115   ModelSignalV2& LoadingFinishedSignal();
116
117   /**
118    * @brief Emitted when the model data save request completes.
119    *
120    * @return A signal object to Connect() with.
121    */
122   ModelSaveSignalV2& SavingFinishedSignal();
123
124   /**
125    * @brief Get number of animations in the model.
126    *
127    * @pre The model has been loaded.
128    * @return The number of animations encoded in the model, or zero if the model
129    * hasn't finished loading.
130    */
131   size_t NumberOfAnimations() const;
132
133   /**
134    * @brief Get the index of a named animation map in the model.
135    *
136    * @param[in] animationName The name of the animation to find
137    * @param[out] animationIndex The index of the named animation if found
138    * @return true if the animation was foud, false if not found.
139    */
140   bool FindAnimation(const std::string& animationName, unsigned int& animationIndex);
141
142   /**
143    * @brief Write the model data to the standard output in textual format.
144    *
145    * Note - will assert if any part of the model is on the scene graph (i.e. if
146    * an actor has been created from this model)
147    */
148   void Write();
149
150   /**
151    * @brief Save a Dali representation of the mode data.
152    *
153    * Used for faster loading on subsequent uses.
154    * @param[in] url The resource url for the data
155    */
156   void Save(const std::string& url);
157
158 public: // Not intended for application developers
159
160   /**
161    * @brief This constructor is used by Dali New() methods.
162    *
163    * @param [in] model A pointer to a newly allocated Dali resource
164    */
165   explicit DALI_INTERNAL Model(Internal::Model* model);
166 };
167
168 } // namespace Dali
169
170 #endif // __DALI_MODEL_H__