Added support for loading image files synchronously
[platform/core/uifw/dali-adaptor.git] / platform-abstractions / slp / resource-loader / resource-requester-base.h
1 #ifndef __DALI_SLP_PLATFORM_RESOURCE_REQUESTER_BASE_H__
2 #define __DALI_SLP_PLATFORM_RESOURCE_REQUESTER_BASE_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 #include <platform-abstractions/slp/resource-loader/resource-loader.h>
21 #include <dali/integration-api/resource-request.h>
22 #include <dali/integration-api/resource-cache.h>
23
24 namespace Dali
25 {
26 namespace Integration
27 {
28 class ResourceRequest;
29 }
30
31 namespace SlpPlatform
32 {
33
34 /**
35  * Base class to handle resource requests
36  */
37 class ResourceRequesterBase
38 {
39 public:
40   /**
41    * Constructor
42    * @param[in] resourceLoader The resource loader with which to communicate results
43    */
44   ResourceRequesterBase( ResourceLoader& resourceLoader );
45
46   /**
47    * Destructor
48    */
49   virtual ~ResourceRequesterBase();
50
51   /**
52    * Pause starting new work on background threads, but keep that work queued.
53    */
54   virtual void Pause() = 0;
55
56   /**
57    * Resume processing tasks on background threads.
58    */
59   virtual void Resume() = 0;
60
61   /**
62    * Load a resource.
63    * @param[in] request The resource request
64    */
65   virtual void LoadResource( Integration::ResourceRequest& request ) = 0;
66
67   /**
68    * Load a resource synchronously.
69    * @param[in] type The type of resource
70    * @param[in] path The path to the resource
71    * @return A pointer to the resource
72    */
73   virtual Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& type, const std::string& path ) = 0;
74
75   /**
76    * Load more resources (for partial loading)
77    * @param[in] request The initial load request
78    * @param[in] partialResource The resources loaded by the last request
79    * @return LOADING or PARTIALLY_LOADED if more resources to come, COMPLETELY_LOADED if complete
80    */
81   virtual Integration::LoadStatus LoadFurtherResources( Integration::ResourceRequest& request, LoadedResource partialResource ) = 0;
82
83   /**
84    * Save a resource
85    * @param[in] request The initial save request
86    */
87   virtual void SaveResource(const Integration::ResourceRequest& request ) = 0;
88
89   /**
90    * Cancal load requests
91    * @param[in] id The request id of the loading request
92    * @param[in] typeId The resource type id of the loading request
93    */
94   virtual void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId) = 0;
95
96 protected:
97   ResourceLoader& mResourceLoader; ///< The resource loader to which to send results
98
99 private:
100   /**
101    * Undefined default constructor
102    */
103   ResourceRequesterBase();
104
105   /**
106    * Undefined Copy constructor
107    */
108   ResourceRequesterBase(const ResourceRequesterBase& rhs );
109
110   /**
111    * Undefined Assignment operator
112    */
113   ResourceRequesterBase& operator=(const ResourceRequesterBase& rhs );
114 };
115
116 } // SlpPlatform
117 } // Dali
118
119 #endif // __DALI_SLP_PLATFORM_RESOURCE_REQUESTER_BASE_H__