DALi Version 2.1.5
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / image-loader / image-url-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_IMAGE_URL_H
2 #define DALI_TOOLKIT_INTERNAL_IMAGE_URL_H
3
4 /*
5  * Copyright (c) 2021 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 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/base-object.h>
23 #include <dali/public-api/adaptor-framework/encoded-image-buffer.h>
24 #include <string>
25
26 // INTERNAL INCLUDES
27 #include <dali-toolkit/public-api/image-loader/image-url.h>
28
29 namespace Dali
30 {
31 namespace Toolkit
32 {
33 namespace Internal
34 {
35 class ImageUrl;
36 using ImageUrlPtr = IntrusivePtr<ImageUrl>;
37
38 class ImageUrl : public BaseObject
39 {
40 public:
41   /**
42    * @brief Constructor.
43    */
44   ImageUrl(Texture& texture);
45
46   /**
47    * @brief Constructor.
48    */
49   ImageUrl(const EncodedImageBuffer& encodedImageBuffer);
50
51   /**
52    * @copydoc Dali::Toolkit::ImageUrl::New
53    */
54   static ImageUrlPtr New(Texture& texture);
55
56   /**
57    * @copydoc Dali::Toolkit::ImageUrl::New
58    */
59   static ImageUrlPtr New(const EncodedImageBuffer& encodedImageBuffer);
60
61   /**
62    * @copydoc Dali::Toolkit::ImageUrl::GetUrl
63    */
64   const std::string& GetUrl() const;
65
66 protected:
67   /**
68    * @brief A reference counted object may only be deleted by calling Unreference()
69    */
70   virtual ~ImageUrl();
71
72 private:
73   // Undefined
74   ImageUrl(const ImageUrl&);
75
76   // Undefined
77   ImageUrl& operator=(const ImageUrl& rhs);
78
79 private:
80   std::string mUrl;
81 };
82
83 } // namespace Internal
84 } // namespace Toolkit
85
86 // Helpers for public-api forwarding methods
87
88 inline Toolkit::Internal::ImageUrl& GetImpl(Dali::Toolkit::ImageUrl& imageUrl)
89 {
90   DALI_ASSERT_ALWAYS(imageUrl && "ImageUrl handle is empty");
91
92   BaseObject& handle = imageUrl.GetBaseObject();
93
94   return static_cast<Toolkit::Internal::ImageUrl&>(handle);
95 }
96
97 inline const Toolkit::Internal::ImageUrl& GetImpl(const Dali::Toolkit::ImageUrl& imageUrl)
98 {
99   DALI_ASSERT_ALWAYS(imageUrl && "ImageUrl handle is empty");
100
101   const BaseObject& handle = imageUrl.GetBaseObject();
102
103   return static_cast<const Toolkit::Internal::ImageUrl&>(handle);
104 }
105
106 } // End of namespace Dali
107
108 #endif // DALI_TOOLKIT_INTERNAL_IMAGE_URL_H