d9ed48a8a2a10b833b139069d30a8afbaa92c994
[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) 2017 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   };
45
46   enum Location
47   {
48     LOCAL,
49     REMOTE
50   };
51
52   /**
53    * Default Constructor.
54    * Resulting URL is not valid
55    */
56   VisualUrl();
57
58   /**
59    * Constructor.
60    * Determines type of visual and whether the url is local or remote
61    * @param[in] url The URL to store and resolve
62    */
63   VisualUrl( const std::string& url );
64
65   /**
66    * Copy constructor
67    * @param[in] url The VisualUrl to copy
68    */
69   VisualUrl( const VisualUrl& url );
70
71   /**
72    * Assignment operator
73    * @param[in] url The VisualUrl to copy
74    */
75   VisualUrl& operator=( const VisualUrl& url );
76
77   /**
78    * Get the full URL
79    * @return The url
80    */
81   const std::string& GetUrl() const;
82
83   /**
84    * Get the visual type of the URL
85    * @return The visual type of the URL
86    */
87   Type GetType() const;
88
89   /**
90    * Is the URL is local to the device, or remote?
91    * @return the location of the resource
92    */
93   Location GetLocation() const;
94
95   /**
96    * Is the URL valid?
97    * @return true if the URL has length
98    */
99   bool IsValid() const;
100
101   /**
102    * @return true if the location is LOCAL
103    */
104   bool IsLocal() const;
105
106 private:
107   std::string mUrl;
108   Type mType;
109   Location mLocation;
110 };
111
112
113 } // namespace Internal
114
115 } // namespace Toolkit
116
117 } // namespace Dali
118
119 #endif /* DALI_TOOLKIT_INTERNAL_VISUAL_URL_H */