b65be394e9964040e0a1e8880a933c70110bf4c8
[platform/core/system/libdbuspolicy.git] / src / internal / own_tree.hpp
1 /*
2  * Copyright (c) 2018-2019 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15 */
16
17
18 /**
19  * \file
20  * \ingroup Implementation
21  */
22
23 #ifndef _OWN_TREE_H
24 #define _OWN_TREE_H
25
26 #include "policy.hpp"
27 #include <memory>
28 #include <map>
29 #include <deque>
30
31 namespace ldp_xml_parser
32 {
33
34         class TreeNode{
35         public:
36                 explicit TreeNode(const std::string &token);
37                 void add(std::deque<std::string>& tokens, const DecisionItem& decision, const bool is_prefix);
38                 void setDecisionItem(const DecisionItem& decision, const bool is_prefix);
39                 const std::string &getToken() const;
40                 const DecisionItem &getOwnPrefixDecisionItem() const;
41                 const DecisionItem &getOwnDecisionItem() const;
42                 const std::map<std::string, std::shared_ptr<TreeNode>> &getChildren() const;
43         private:
44                 DecisionItem prefixBasedDecision() const;
45
46                 std::string __token;    // element of dot-separated name
47                 DecisionItem __own_prefix_decision_item;
48                 DecisionItem __own_decision_item;
49                 std::map<std::string, std::shared_ptr<TreeNode>> __children;
50                 friend class OwnershipTree;
51         };
52
53
54         class OwnershipTree{
55         public:
56                 OwnershipTree();
57                 void addItem(const ItemOwn &item);
58                 const std::shared_ptr<TreeNode> getRoot() const { return __root; };
59         private:
60                 std::shared_ptr<TreeNode> __root;
61         };
62 }
63 #endif