[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / public-api / loader / customization.h
1 #ifndef DALI_SCENE3D_LOADER_CUSTOMIZATION_STATE_H_
2 #define DALI_SCENE3D_LOADER_CUSTOMIZATION_STATE_H_
3 /*
4  * Copyright (c) 2023 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 // EXTERNAL INCLUDES
21 #include <dali/public-api/common/vector-wrapper.h>
22 #include <memory>
23 #include <string>
24
25 // INTERNAL INCLUDES
26 #include <dali-scene3d/public-api/api.h>
27
28 namespace Dali::Scene3D::Loader
29 {
30 /**
31  * @brief Offers a description of an aspect of the scene that can be customized:
32  *     the number of options, and the name of the nodes that are registered
33  *     for the tag, whose children will be shown / hidden based on selection.
34  * @SINCE_2_0.7
35  */
36 struct DALI_SCENE3D_API Customization
37 {
38   using Tag        = std::string;
39   using OptionType = uint32_t;
40
41   /**
42    * @brief A mapping of customizations to tags.
43    * @SINCE_2_0.7
44    */
45   struct DALI_SCENE3D_API Map
46   {
47     Map();
48     ~Map();
49
50     /**
51      * @brief Maps the given @a customization to the given @a tag, overwriting any previous mapping to the same tag.
52      * @SINCE_2_0.7
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      * @SINCE_2_0.7
60      */
61     const Customization* Get(Tag tag) const;
62
63     /**
64      * @brief Attempts to retrieve a Customization based on the given @a tag.
65      * @SINCE_2_0.7
66      */
67     Customization* Get(Tag tag);
68
69     /**
70      * @brief Returns the number of elements.
71      * @SINCE_2_0.7
72      */
73     uint32_t Size() const;
74
75     /**
76      * @brief Removes every element from the Map.
77      * @SINCE_2_0.7
78      */
79     void Clear();
80
81   private:
82     struct Impl;
83     const std::unique_ptr<Impl> mImpl;
84   };
85
86   /**
87    * @brief A mapping of choices - indices of children of customization nodes to use - to tags.
88    * @SINCE_2_0.7
89    */
90   struct DALI_SCENE3D_API Choices
91   {
92     Choices();
93     ~Choices();
94
95     /**
96      * @brief Maps the given @a option to the given @a tag, overwriting any previous mapping to the same tag.
97      * @SINCE_2_0.7
98      */
99     void Set(Tag tag, OptionType option);
100
101     /**
102      * @brief Attempts to retrieve a Customization based on the given @a tag.
103      * @SINCE_2_0.7
104      * @return A Customization based on the given @a tag.
105      * @note Returns NONE if @a tag is not known.
106      */
107     OptionType Get(Tag tag) const;
108
109     /**
110      * @brief Returns the number of elements.
111      * @SINCE_2_0.7
112      * @return The number of elements.
113      */
114     uint32_t Size() const;
115
116     /**
117      * @brief Removes every element from the underlying map.
118      * @SINCE_2_0.7
119      */
120     void Clear();
121
122   private:
123     struct Impl;
124     const std::unique_ptr<Impl> mImpl;
125   };
126
127   static const OptionType NONE = OptionType(-1);
128
129   OptionType               numOptions = 0;
130   std::vector<std::string> nodes; // to apply option to.
131 };
132
133 } // namespace Dali::Scene3D::Loader
134
135 #endif //DALI_SCENE3D_LOADER_CUSTOMIZATION_STATE_H_