1 #ifndef DALI_TOOLKIT_INTERNAL_VISUAL_URL_H
2 #define DALI_TOOLKIT_INTERNAL_VISUAL_URL_H
5 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
32 * The type of the URL based on the string contents
47 LOCAL, ///< file in local file system
48 TEXTURE, ///< texture uploaded to texture manager
49 REMOTE, ///< remote image
50 BUFFER ///< encoded image buffer
54 * Default Constructor.
55 * Resulting URL is not valid
61 * Delete an external texture if if protocolType is TEXTURE.
67 * Determines type of visual and whether the url is local or remote
68 * Notify that it is using an external texture if if protocolType is TEXTURE.
70 * @param[in] url The URL to store and resolve
72 VisualUrl(const std::string& url);
76 * @param[in] url The VisualUrl to copy
78 VisualUrl(const VisualUrl& url);
82 * @param[in] url The VisualUrl to copy
84 VisualUrl& operator=(const VisualUrl& url);
90 const std::string& GetUrl() const;
93 * Get the hash value of full URL
94 * @return The hash value of url
96 const std::uint64_t& GetUrlHash() const;
99 * Get the visual type of the URL
100 * @return The visual type of the URL
102 Type GetType() const;
105 * Is the URL is local to the device, or remote?
106 * @return the location of the resource
108 ProtocolType GetProtocolType() const;
112 * @return true if the URL has length
114 bool IsValid() const;
117 * @return true if the location is LOCAL, i.e. is loadable from local file system
119 bool IsLocalResource() const;
122 * @return true if the location is BUFFER, i.e. may contain EncodedImageBuffer
124 bool IsBufferResource() const;
127 * @return the location part of the url
129 std::string GetLocation() const;
132 * Helper to create a URL of type TEXTURE
133 * @param location the location of the texture
136 static std::string CreateTextureUrl(const std::string& location);
139 * Helper to create a URL of type BUFFER
140 * @param location the location of the texture
143 static std::string CreateBufferUrl(const std::string& location);
146 * Helper to get a ProtocolType from url
147 * @param url the url of the texture
148 * @return the protocol type
150 static VisualUrl::ProtocolType GetProtocolType(const std::string& url);
153 * Helper to get a location from url
154 * @param url the location of the texture
155 * @return the location
157 static std::string GetLocation(const std::string& url);
162 ProtocolType mLocation;
164 mutable std::uint64_t mUrlHash;
167 } // namespace Internal
169 } // namespace Toolkit
173 #endif /* DALI_TOOLKIT_INTERNAL_VISUAL_URL_H */