1 #ifndef DALI_TOOLKIT_INTERNAL_VISUAL_URL_H
2 #define DALI_TOOLKIT_INTERNAL_VISUAL_URL_H
5 * Copyright (c) 2023 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.
23 #include <string_view>
35 * The type of the URL based on the string contents
50 LOCAL, ///< file in local file system
51 TEXTURE, ///< texture uploaded to texture manager
52 REMOTE, ///< remote image
53 BUFFER ///< encoded image buffer
57 * Default Constructor.
58 * Resulting URL is not valid
64 * Delete an external texture if if protocolType is TEXTURE.
70 * Determines type of visual and whether the url is local or remote
71 * Notify that it is using an external texture if if protocolType is TEXTURE.
73 * @param[in] url The URL to store and resolve
75 VisualUrl(const std::string& url);
79 * @param[in] url The VisualUrl to copy
81 VisualUrl(const VisualUrl& url);
85 * @param[in] url The VisualUrl to copy
87 VisualUrl& operator=(const VisualUrl& url);
91 * @param[in] url The VisualUrl to move
93 VisualUrl(VisualUrl&& url) noexcept;
96 * Move assignment operator
97 * @param[in] url The VisualUrl to move
99 VisualUrl& operator=(VisualUrl&& url) noexcept;
105 const std::string& GetUrl() const;
108 * Get the hash value of full URL
109 * @return The hash value of url
111 std::uint64_t GetUrlHash() const;
114 * Get the visual type of the URL
115 * @return The visual type of the URL
117 Type GetType() const;
120 * Is the URL is local to the device, or remote?
121 * @return the location of the resource
123 ProtocolType GetProtocolType() const;
127 * @return true if the URL has length
129 bool IsValid() const;
132 * @return true if the location is LOCAL, i.e. is loadable from local file system
134 bool IsLocalResource() const;
137 * @return true if the location is BUFFER, i.e. may contain EncodedImageBuffer
139 bool IsBufferResource() const;
142 * @return the location part of the url
144 std::string GetLocation() const;
147 * @return the location part of the url without extension
149 std::string GetLocationWithoutExtension() const;
152 * Helper to create a URL of type TEXTURE
153 * @param location the location of the texture
156 static std::string CreateTextureUrl(const std::string& location);
159 * Helper to create a URL of type BUFFER
160 * @param[in] location the location of the texture
161 * @param[in] extension the extension of url
164 static std::string CreateBufferUrl(const std::string& location, const std::string_view& extension);
167 * Helper to get a ProtocolType from url
168 * @param url the url of the texture
169 * @return the protocol type
171 static VisualUrl::ProtocolType GetProtocolType(const std::string& url);
174 * Helper to get a location from url
175 * @param url the location of the texture
176 * @return the location
178 static std::string GetLocation(const std::string& url);
181 * Helper to get a location from url without extension
182 * @param[in] url the location of the texture
183 * @return the location without extension
185 static std::string GetLocationWithoutExtension(const std::string& url);
190 ProtocolType mLocation;
192 mutable std::uint64_t mUrlHash;
195 } // namespace Internal
197 } // namespace Toolkit
201 #endif /* DALI_TOOLKIT_INTERNAL_VISUAL_URL_H */