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