Merge "Remove RenderableActor" into devel/master
[platform/core/uifw/dali-core.git] / dali / integration-api / resource-cache.h
1 #ifndef __DALI_INTEGRATION_RESOURCE_CACHE_H__
2 #define __DALI_INTEGRATION_RESOURCE_CACHE_H__
3
4 /*
5  * Copyright (c) 2014 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/intrusive-ptr.h>
23 #include <dali/integration-api/resource-request.h>
24
25 namespace Dali
26 {
27
28 namespace Integration
29 {
30 /**
31  * Used to determine why a resource IO operation has failed.
32  */
33 enum ResourceFailure
34 {
35   FailureUnknown,
36   FailureFileNotFound,
37   FailureInvalidPath
38 };
39
40 /**
41  * Used to return loaded resources for rendering etc.
42  */
43 typedef IntrusivePtr<Dali::RefObject> ResourcePointer;
44
45 /**
46  * Abstract interface to receive notifications of resource IO operations.
47  * This is used when pulling loaded resources from the PlatformAbstraction.
48  */
49 class ResourceCache
50 {
51 protected:
52
53   /**
54    * Virtual protected destructor, no deletion through this interface
55    */
56   virtual ~ResourceCache() {}
57
58 public:
59
60   /**
61    * Provide the results of a resource loading operation to the cache.
62    * @param[in] id The unique ID of the load request.
63    *               This should match an ID previously passed into PlatformAbstraction::LoadResource().
64    *               LoadResponse() may be called multiple times with the same ID, when results are available
65    *               at different stages e.g. a thumbnail image may be provided, before the full image is loaded.
66    * @param[in] type The type of the resource.
67    * @param[in] resource A pointer to a resource (Bitmap etc).
68    * @param[in] status The current loading status. RESOURCE_LOADING and RESOURCE_PARTIALLY_LOADED indicate there are more responses to come, RESOURCE_COMPLETELY_LOADED indicates this is the last response for this id.
69    */
70   virtual void LoadResponse(ResourceId id, ResourceTypeId type, ResourcePointer resource, LoadStatus status) = 0;
71
72   /**
73    * Provide the results of a resource saving operation.
74    * @param[in] id The unique ID of the resource.
75    *               This should match an ID previously passed into PlatformAbstraction::SaveResource().
76    * @param[in] type The type of the resource.
77    */
78   virtual void SaveComplete(ResourceId id, ResourceTypeId type) = 0;
79
80   /**
81    * Report that a resource loading operation has failed.
82    * @param[in] id The unique ID of the load request.
83    *               This should match an ID previously passed into PlatformAbstraction::LoadResource().
84    * @param[in] failure An error code, used to determine why the load failed.
85    */
86   virtual void LoadFailed(ResourceId id, ResourceFailure failure) = 0;
87
88   /**
89    * Report that a resource saving operation has failed.
90    * @param[in] id The unique ID of the save request.
91    *               This should match an ID previously passed into PlatformAbstraction::LoadResource().
92    * @param[in] failure An error code, used to determine why the save failed.
93    */
94   virtual void SaveFailed(ResourceId id, ResourceFailure failure) = 0;
95 };
96
97
98 } // namespace Integration
99
100 } // namespace Dali
101
102 #endif // __DALI_INTEGRATION_RESOURCE_CACHE_H__