xref: /AOO41X/main/autodoc/source/display/inc/toolkit/out_node.hxx (revision 1c78a5d6c0093dece4c096ba53051800fbad6e33)
1*1c78a5d6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*1c78a5d6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1c78a5d6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1c78a5d6SAndrew Rist  * distributed with this work for additional information
6*1c78a5d6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1c78a5d6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1c78a5d6SAndrew Rist  * "License"); you may not use this file except in compliance
9*1c78a5d6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*1c78a5d6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*1c78a5d6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1c78a5d6SAndrew Rist  * software distributed under the License is distributed on an
15*1c78a5d6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1c78a5d6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*1c78a5d6SAndrew Rist  * specific language governing permissions and limitations
18*1c78a5d6SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*1c78a5d6SAndrew Rist  *************************************************************/
21*1c78a5d6SAndrew Rist 
22*1c78a5d6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef ADC_DISPLAY_OUT_NODE_HXX
25cdf0e10cSrcweir #define ADC_DISPLAY_OUT_NODE_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir 
30cdf0e10cSrcweir namespace output
31cdf0e10cSrcweir {
32cdf0e10cSrcweir 
33cdf0e10cSrcweir 
34cdf0e10cSrcweir /**	@resp
35cdf0e10cSrcweir     Represents a tree of names where each node can have only one parent,
36cdf0e10cSrcweir     but a list of children.
37cdf0e10cSrcweir 
38cdf0e10cSrcweir 	@see    Position
39cdf0e10cSrcweir 	@see    Tree
40cdf0e10cSrcweir */
41cdf0e10cSrcweir class Node
42cdf0e10cSrcweir {
43cdf0e10cSrcweir   public:
44cdf0e10cSrcweir     typedef std::vector< Node* >    List;
45cdf0e10cSrcweir     typedef UINT32                  relative_id;
46cdf0e10cSrcweir 
47cdf0e10cSrcweir   	// LIFECYCLE
48cdf0e10cSrcweir   	enum E_NullObject { null_object };
49cdf0e10cSrcweir 
50cdf0e10cSrcweir   	                    Node();
51cdf0e10cSrcweir   	explicit            Node(
52cdf0e10cSrcweir   	                        E_NullObject        );
53cdf0e10cSrcweir   						~Node();
54cdf0e10cSrcweir 
55cdf0e10cSrcweir   	// OPERATORS
operator ==(const Node & i_node) const56cdf0e10cSrcweir   	bool                operator==(
57cdf0e10cSrcweir   	                        const Node &        i_node ) const
58cdf0e10cSrcweir   	                                            { return pParent == i_node.pParent AND sName == i_node.sName; }
operator !=(const Node & i_node) const59cdf0e10cSrcweir   	bool                operator!=(
60cdf0e10cSrcweir   	                        const Node &        i_node ) const
61cdf0e10cSrcweir   	                                            { return NOT operator==(i_node); }
62cdf0e10cSrcweir 
63cdf0e10cSrcweir   	// OPERATIONS
64cdf0e10cSrcweir   	/// Seek, and if not existent, create.
65cdf0e10cSrcweir   	Node &              Provide_Child(
66cdf0e10cSrcweir   	                        const String &      i_name );
67cdf0e10cSrcweir   	/// Seek, and if not existent, create.
Provide_Child(const StringVector & i_path)68cdf0e10cSrcweir   	Node &              Provide_Child(
69cdf0e10cSrcweir   	                        const StringVector &
70cdf0e10cSrcweir   	                                            i_path )
71cdf0e10cSrcweir   	                                            { return provide_Child(i_path.begin(), i_path.end()); }
72cdf0e10cSrcweir   	// INQUIRY
Depth() const73cdf0e10cSrcweir   	intt                Depth() const           { return nDepth; }
74cdf0e10cSrcweir 
Name() const75cdf0e10cSrcweir     const String &      Name() const            { return sName; }
76cdf0e10cSrcweir     /// @return Id of a namespace or class etc. this directory represents.
RelatedNameRoom() const77cdf0e10cSrcweir     relative_id         RelatedNameRoom() const { return nNameRoomId; }
78cdf0e10cSrcweir     /// @return No delimiter at start, with delimiter at end.
79cdf0e10cSrcweir     void                Get_Path(
80cdf0e10cSrcweir                             StreamStr &         o_result,
81cdf0e10cSrcweir                             intt                i_maxDepth = -1 ) const;
82cdf0e10cSrcweir     void                Get_Chain(
83cdf0e10cSrcweir                             StringVector &      o_result,
84cdf0e10cSrcweir                             intt                i_maxDepth = -1 ) const;
85cdf0e10cSrcweir     // ACCESS
Set_RelatedNameRoom(relative_id i_nNameRoomId)86cdf0e10cSrcweir     void                Set_RelatedNameRoom(
87cdf0e10cSrcweir                             relative_id         i_nNameRoomId )
88cdf0e10cSrcweir                                                 { nNameRoomId = i_nNameRoomId; }
Parent()89cdf0e10cSrcweir   	Node *              Parent()                { return pParent; }
Child(const String & i_name)90cdf0e10cSrcweir   	Node *              Child(
91cdf0e10cSrcweir   	                        const String &      i_name )
92cdf0e10cSrcweir   	                                            { return find_Child(i_name); }
Children()93cdf0e10cSrcweir     List &              Children()              { return aChildren; }
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     /// @return a reference to a Node with Depth() == -1.
96cdf0e10cSrcweir     static Node &       Null_();
97cdf0e10cSrcweir 
98cdf0e10cSrcweir   private:
99cdf0e10cSrcweir   	// Local
100cdf0e10cSrcweir   						Node(
101cdf0e10cSrcweir   						    const String &      i_name,
102cdf0e10cSrcweir   						    Node &              i_parent );
103cdf0e10cSrcweir 
104cdf0e10cSrcweir   	Node *              find_Child(
105cdf0e10cSrcweir   	                        const String &      i_name );
106cdf0e10cSrcweir   	Node &              add_Child(
107cdf0e10cSrcweir   	                        const String &      i_name );
108cdf0e10cSrcweir   	Node &              provide_Child(
109cdf0e10cSrcweir   	                        StringVector::const_iterator
110cdf0e10cSrcweir   	                                            i_next,
111cdf0e10cSrcweir   	                        StringVector::const_iterator
112cdf0e10cSrcweir   	                                            i_end );
113cdf0e10cSrcweir   	// Data
114cdf0e10cSrcweir   	String              sName;
115cdf0e10cSrcweir   	Node *              pParent;
116cdf0e10cSrcweir   	List                aChildren;
117cdf0e10cSrcweir   	intt                nDepth;
118cdf0e10cSrcweir     relative_id         nNameRoomId;
119cdf0e10cSrcweir };
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 
124cdf0e10cSrcweir }   // namespace output
125cdf0e10cSrcweir #endif
126