Merge "Updated patch coverage script." into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-scene-loader / public-api / customization.h
1 #ifndef DALI_SCENE_LOADER_CUSTOMIZATION_STATE_H_
2 #define DALI_SCENE_LOADER_CUSTOMIZATION_STATE_H_
3 /*
4  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20  // INTERNAL INCLUDES
21 #include "dali-scene-loader/public-api/api.h"
22
23 // EXTERNAL INCLUDES
24 #include "dali/public-api/common/vector-wrapper.h"
25 #include <string>
26 #include <memory>
27
28 namespace Dali
29 {
30 namespace SceneLoader
31 {
32
33 /**
34  * @brief Offers a description of an aspect of the scene that can be customized:
35  *     the number of options, and the name of the nodes that are registered
36  *     for the tag, whose children will be shown / hidden based on selection.
37  */
38 struct DALI_SCENE_LOADER_API Customization
39 {
40   using Tag = std::string;
41   using OptionType = uint32_t;
42
43   /**
44    * @brief A mapping of customizations to tags.
45    */
46   struct DALI_SCENE_LOADER_API Map
47   {
48     Map();
49     ~Map();
50
51     /**
52      * @brief Maps the given @a customization to the given @a tag, overwriting any previous mapping to the same tag.
53      * @return Pointer to the inserted (or pre-existing) Customization instance.
54      */
55     Customization* Set(Tag tag, Customization&& customization);
56
57     /**
58      * @brief Attempts to retrieve a const Customization based on the given @a tag.
59      */
60     const Customization* Get(Tag tag) const;
61
62     /**
63      * @brief Attempts to retrieve a Customization based on the given @a tag.
64      */
65     Customization* Get(Tag tag);
66
67     /**
68      * @brief Returns the number of elements.
69      */
70     uint32_t Size() const;
71
72     /*
73      * @brief Removes every element from the Map.
74      */
75     void Clear();
76
77   private:
78     struct Impl;
79     const std::unique_ptr<Impl> mImpl;
80   };
81
82   /**
83    * @brief A mapping of choices - indices of children of customization nodes to use - to tags.
84    */
85   struct DALI_SCENE_LOADER_API Choices
86   {
87     Choices();
88     ~Choices();
89
90     /**
91      * @brief Maps the given @a option to the given @a tag, overwriting any previous mapping to the same tag.
92      */
93     void Set(Tag tag, OptionType option);
94
95     /**
96      * @brief Attempts to retrieve a Customization based on the given @a tag. Returns NONE if @a tag is not known.
97      */
98     OptionType Get(Tag tag) const;
99
100     /**
101      * @brief Returns the number of elements.
102      */
103     uint32_t Size() const;
104
105     /*
106      * @brief Removes every element from the underlying map.
107      */
108     void Clear();
109
110   private:
111     struct Impl;
112     const std::unique_ptr<Impl> mImpl;
113   };
114
115   static const OptionType NONE = OptionType(-1);
116
117   OptionType numOptions = 0;
118   std::vector<std::string> nodes;  // to apply option to.
119 };
120
121 }
122 }
123
124 #endif //DALI_SCENE_LOADER_CUSTOMIZATION_STATE_H_