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