Merge "DALi Version 1.9.30" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / visual-url.h
1 #ifndef DALI_TOOLKIT_INTERNAL_VISUAL_URL_H
2 #define DALI_TOOLKIT_INTERNAL_VISUAL_URL_H
3
4 /*
5  * Copyright (c) 2020 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 #include <string>
21
22 namespace Dali
23 {
24
25 namespace Toolkit
26 {
27
28 namespace Internal
29 {
30
31 class VisualUrl
32 {
33 public:
34
35   /**
36    * The type of the URL based on the string contents
37    */
38   enum Type
39   {
40     REGULAR_IMAGE,
41     N_PATCH,
42     SVG,
43     GIF,
44     WEBP,
45     JSON
46   };
47
48   enum ProtocolType
49   {
50     LOCAL,   ///< file in local file system
51     TEXTURE, ///< texture uploaded to texture manager
52     REMOTE   ///< remote image
53   };
54
55   /**
56    * Default Constructor.
57    * Resulting URL is not valid
58    */
59   VisualUrl();
60
61   /**
62    * Constructor.
63    * Determines type of visual and whether the url is local or remote
64    * @param[in] url The URL to store and resolve
65    */
66   VisualUrl( const std::string& url );
67
68   /**
69    * Copy constructor
70    * @param[in] url The VisualUrl to copy
71    */
72   VisualUrl( const VisualUrl& url );
73
74   /**
75    * Assignment operator
76    * @param[in] url The VisualUrl to copy
77    */
78   VisualUrl& operator=( const VisualUrl& url );
79
80   /**
81    * Get the full URL
82    * @return The url
83    */
84   const std::string& GetUrl() const;
85
86   /**
87    * Get the visual type of the URL
88    * @return The visual type of the URL
89    */
90   Type GetType() const;
91
92   /**
93    * Is the URL is local to the device, or remote?
94    * @return the location of the resource
95    */
96   ProtocolType GetProtocolType() const;
97
98   /**
99    * Is the URL valid?
100    * @return true if the URL has length
101    */
102   bool IsValid() const;
103
104   /**
105    * @return true if the location is LOCAL, i.e. is loadable from local file system
106    */
107   bool IsLocalResource() const;
108
109   /**
110    * @return the location part of the url
111    */
112   std::string GetLocation() const;
113
114   /**
115    * Helper to create a URL of type TEXTURE
116    * @param location the location of the texture
117    * @return the Url
118    */
119   static std::string CreateTextureUrl( const std::string& location );
120
121 private:
122   std::string mUrl;
123   Type mType;
124   ProtocolType mLocation;
125 };
126
127
128 } // namespace Internal
129
130 } // namespace Toolkit
131
132 } // namespace Dali
133
134 #endif /* DALI_TOOLKIT_INTERNAL_VISUAL_URL_H */