1 #ifndef __DALI_INTERNAL_MODEL_H__
2 #define __DALI_INTERNAL_MODEL_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.
22 #include <dali/public-api/object/ref-object.h>
23 #include <dali/public-api/common/dali-common.h>
24 #include <dali/public-api/modeling/material.h>
25 #include <dali/public-api/modeling/model.h>
26 #include <dali/public-api/object/base-object.h>
27 #include <dali/internal/event/modeling/model-data-impl.h>
28 #include <dali/internal/event/resources/resource-ticket.h>
29 #include <dali/internal/event/resources/resource-ticket-observer.h>
30 #include <dali/internal/event/resources/resource-client.h>
40 typedef IntrusivePtr<Model> ModelPtr;
43 * Encapsulates a Dali 3D model/scene.
45 class Model : public BaseObject, public ResourceTicketObserver
49 * Create a model from the given filename
50 * @param[in] name The filename of the model.
51 * @return A smart-pointer to a newly allocated model
53 static ModelPtr New(const std::string& name);
55 public: // From ResourceTicketObserver
57 * @copydoc Dali::Internal::ResourceTicketObserver::ResourceLoadingFailed()
59 virtual void ResourceLoadingFailed(const ResourceTicket& ticket);
62 * @copydoc Dali::Internal::ResourceTicketObserver::ResourceLoadingSucceeded()
64 virtual void ResourceLoadingSucceeded(const ResourceTicket& ticket);
67 * @copydoc Dali::Internal::ResourceTicketObserver::ResourceUploaded()
69 virtual void ResourceUploaded(const ResourceTicket& ticket);
72 * @copydoc Dali::Internal::ResourceTicketObserver::ResourceSavingFailed()
74 virtual void ResourceSavingFailed(const ResourceTicket& ticket);
77 * @copydoc Dali::Internal::ResourceTicketObserver::ResourceSavingSucceeded()
79 virtual void ResourceSavingSucceeded(const ResourceTicket& ticket);
82 public: // Query methods from external model
84 * @copydoc Dali::Model::GetLoadingState()
86 LoadingState GetLoadingState()
88 return mTicket->GetLoadingState();
92 * @copydoc Dali::Model::LoadingFinishedSignal()
94 Dali::Model::ModelSignalType& LoadingFinishedSignal()
96 return mLoadingFinished;
100 * @copydoc Dali::Model::SavingFinishedSignal()
102 Dali::Model::ModelSaveSignalType& SavingFinishedSignal()
104 return mSavingFinished;
108 * Connects a callback function with the object's signals.
109 * @param[in] object The object providing the signal.
110 * @param[in] tracker Used to disconnect the signal.
111 * @param[in] signalName The signal to connect to.
112 * @param[in] functor A newly allocated FunctorDelegate.
113 * @return True if the signal was connected.
114 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
116 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
119 * returns the Id used for lookups
120 * @return the unique ID of the image data resource
122 ResourceId GetResourceId() const;
125 * @copydoc Dali::Model::NumberOfAnimations().
127 unsigned int NumberOfAnimations() const;
130 * @copydoc Dali::Model::FindAnimation().
132 bool FindAnimation(const std::string& animationName, unsigned int & animationIndex);
135 * @copydoc Dali::Model::Write()
140 * @copydoc Dali::Model::Save()
142 void Save(const std::string& url);
146 * Accessor for internal classes only.
147 * @return The model data, or NULL if not loaded yet
149 Internal::ModelDataPtr GetModelData() const;
155 * @param[in] name The filename of the model.
158 Model(const std::string& name);
161 * A reference counted object may only be deleted by calling Unreference()
167 ResourceTicketPtr mTicket;
169 Dali::Model::ModelSignalType mLoadingFinished;
170 Dali::Model::ModelSaveSignalType mSavingFinished;
172 ResourceClient* mResourceClient;
175 } // namespace Internal
177 // Helpers for public-api forwarding methods
178 inline Internal::Model& GetImplementation(Dali::Model& model)
180 DALI_ASSERT_ALWAYS( model && "Model handle is empty" );
182 BaseObject& handle = model.GetBaseObject();
184 return static_cast<Internal::Model&>(handle);
187 inline const Internal::Model& GetImplementation(const Dali::Model& model)
189 DALI_ASSERT_ALWAYS( model && "Model handle is empty" );
191 const BaseObject& handle = model.GetBaseObject();
193 return static_cast<const Internal::Model&>(handle);
198 #endif // __DALI_INTERNAL_MODEL_H__