xref: /trunk/main/configmgr/source/node.hxx (revision afd9e31976a562115f55d066936663bde22b7456)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  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,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_CONFIGMGR_SOURCE_NODE_HXX
25 #define INCLUDED_CONFIGMGR_SOURCE_NODE_HXX
26 
27 #include "sal/config.h"
28 
29 #include "rtl/ref.hxx"
30 #include "salhelper/simplereferenceobject.hxx"
31 
32 #include "nodemap.hxx"
33 
34 namespace rtl { class OUString; }
35 
36 namespace configmgr {
37 
38 /**
39  * Configuration element.
40  *
41  * This class represent either a "node" or a "property" in the words of the
42  * OpenOffice.org Registry Format (OOR).
43  */
44 class Node: public salhelper::SimpleReferenceObject {
45 public:
46     /// Identifies the type of configuration element.
47     enum Kind {
48         /** Property (<prop> element)
49          *
50          * Identifies instances of PropertyNode.
51          */
52         KIND_PROPERTY,
53         /** Localized property (<prop> element)
54          *
55          * Identifies instances of LocalizedPropertyNode.
56          */
57         KIND_LOCALIZED_PROPERTY,
58         /**
59          * Value of a property (<value> element)
60          *
61          * Identifies instances of LocalizedValueNode.
62          */
63         KIND_LOCALIZED_VALUE,
64         /** Group node (<node> element)
65          *
66          * Identifies instances of GroupNode.
67          */
68         KIND_GROUP,
69         /** Set node (<node> element)
70          *
71          * Identifies instances of SetNode.
72          */
73         KIND_SET,
74         /** Node to be deleted.
75          *
76          * This type of element is not present in the OOR. It is used as a
77          * placeholder for a node that is about to disappear.
78          *
79          * Identifies instances of WipedNode.
80          */
81         KIND_WIPED };
82 
83     virtual Kind kind() const = 0;
84 
85     virtual rtl::Reference< Node > clone(bool keepTemplateName) const = 0;
86 
87     virtual NodeMap & getMembers();
88 
89     virtual rtl::OUString getTemplateName() const;
90 
91     virtual void setMandatory(int layer);
92 
93     virtual int getMandatory() const;
94 
95     void setLayer(int layer);
96 
97     int getLayer() const;
98 
99     void setFinalized(int layer);
100 
101     int getFinalized() const;
102 
103     rtl::Reference< Node > getMember(rtl::OUString const & name);
104 
105 protected:
106     explicit Node(int layer);
107 
108     Node(const Node & other);
109 
110     virtual ~Node();
111 
112     virtual void clear();
113 
114     int layer_;
115     int finalized_;
116 };
117 
118 }
119 
120 #endif
121