1*38268e38SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*38268e38SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*38268e38SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*38268e38SAndrew Rist * distributed with this work for additional information
6*38268e38SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*38268e38SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*38268e38SAndrew Rist * "License"); you may not use this file except in compliance
9*38268e38SAndrew Rist * with the License. You may obtain a copy of the License at
10*38268e38SAndrew Rist *
11*38268e38SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*38268e38SAndrew Rist *
13*38268e38SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*38268e38SAndrew Rist * software distributed under the License is distributed on an
15*38268e38SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*38268e38SAndrew Rist * KIND, either express or implied. See the License for the
17*38268e38SAndrew Rist * specific language governing permissions and limitations
18*38268e38SAndrew Rist * under the License.
19*38268e38SAndrew Rist *
20*38268e38SAndrew Rist *************************************************************/
21*38268e38SAndrew Rist
22*38268e38SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #ifndef SOLTOOLS_GI_LIST_HXX
25cdf0e10cSrcweir #define SOLTOOLS_GI_LIST_HXX
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include "st_list.hxx"
29cdf0e10cSrcweir
30cdf0e10cSrcweir
31cdf0e10cSrcweir class GenericInfo;
32cdf0e10cSrcweir
33cdf0e10cSrcweir /** Holds set of generic informations in a sorted list.
34cdf0e10cSrcweir
35cdf0e10cSrcweir At different places, methods of this class have a parameter,
36cdf0e10cSrcweir whose name includes "path". Those are paths like this:
37cdf0e10cSrcweir
38cdf0e10cSrcweir src370/drives/o:
39cdf0e10cSrcweir
40cdf0e10cSrcweir which are used to access GenericInfo keys in deep search through
41cdf0e10cSrcweir the lists and their sublists.
42cdf0e10cSrcweir */
43cdf0e10cSrcweir class List_GenericInfo
44cdf0e10cSrcweir {
45cdf0e10cSrcweir public:
46cdf0e10cSrcweir // TYPES
47cdf0e10cSrcweir class const_iterator
48cdf0e10cSrcweir {
49cdf0e10cSrcweir public:
50cdf0e10cSrcweir const GenericInfo & operator*() const;
51cdf0e10cSrcweir const_iterator & operator++();
52cdf0e10cSrcweir bool operator==( const const_iterator & ) const;
53cdf0e10cSrcweir bool operator!=( const const_iterator & ) const;
54cdf0e10cSrcweir
55cdf0e10cSrcweir const_iterator();
56cdf0e10cSrcweir const_iterator( const DynamicList< GenericInfo >::const_iterator & );
57cdf0e10cSrcweir private: DynamicList< GenericInfo >::const_iterator it;
58cdf0e10cSrcweir };
59cdf0e10cSrcweir class iterator
60cdf0e10cSrcweir { public:
61cdf0e10cSrcweir GenericInfo & operator*() const;
62cdf0e10cSrcweir iterator & operator++();
63cdf0e10cSrcweir bool operator==( const iterator & ) const;
64cdf0e10cSrcweir bool operator!=( const iterator & ) const;
65cdf0e10cSrcweir
66cdf0e10cSrcweir iterator();
67cdf0e10cSrcweir iterator( const DynamicList< GenericInfo >::iterator & );
68cdf0e10cSrcweir private: DynamicList< GenericInfo >::iterator it;
69cdf0e10cSrcweir };
70cdf0e10cSrcweir
71cdf0e10cSrcweir typedef const char * KeyPath;
72cdf0e10cSrcweir
73cdf0e10cSrcweir // LIFECYCLE
74cdf0e10cSrcweir List_GenericInfo();
75cdf0e10cSrcweir List_GenericInfo(
76cdf0e10cSrcweir const List_GenericInfo &
77cdf0e10cSrcweir i_rList );
78cdf0e10cSrcweir ~List_GenericInfo();
79cdf0e10cSrcweir
80cdf0e10cSrcweir // OPERATORS
81cdf0e10cSrcweir List_GenericInfo & operator=(
82cdf0e10cSrcweir const List_GenericInfo &
83cdf0e10cSrcweir i_rList );
84cdf0e10cSrcweir const GenericInfo * operator[](
85cdf0e10cSrcweir KeyPath i_sKeyPath ) const;
86cdf0e10cSrcweir GenericInfo * operator[](
87cdf0e10cSrcweir KeyPath i_sKeyPath );
88cdf0e10cSrcweir
89cdf0e10cSrcweir // OPERATIONS
90cdf0e10cSrcweir bool InsertInfo(
91cdf0e10cSrcweir GenericInfo * let_dpInfo, /// Will be owned by this object.
92cdf0e10cSrcweir bool i_bOverwrite = true );
93cdf0e10cSrcweir bool InsertInfoByPath(
94cdf0e10cSrcweir GenericInfo * let_dpInfo, /// Will be owned by this object.
95cdf0e10cSrcweir KeyPath i_sKeyPath,
96cdf0e10cSrcweir bool i_bCreatePath,
97cdf0e10cSrcweir bool i_bOverwrite = true );
98cdf0e10cSrcweir
99cdf0e10cSrcweir GenericInfo * ReleaseInfo( /// Removes the GenericInfo from its parent.
100cdf0e10cSrcweir KeyPath i_sKeyPath );
101cdf0e10cSrcweir
102cdf0e10cSrcweir void DeleteInfo(
103cdf0e10cSrcweir KeyPath i_sKeyPath );
104cdf0e10cSrcweir
105cdf0e10cSrcweir // INFO
106cdf0e10cSrcweir unsigned Size() const;
107cdf0e10cSrcweir
108cdf0e10cSrcweir const_iterator Begin() const;
109cdf0e10cSrcweir const_iterator End() const;
110cdf0e10cSrcweir
111cdf0e10cSrcweir // ACCESS
112cdf0e10cSrcweir iterator Begin();
113cdf0e10cSrcweir iterator End();
114cdf0e10cSrcweir
115cdf0e10cSrcweir private:
116cdf0e10cSrcweir typedef DynamicList< GenericInfo >::iterator sub_iterator;
117cdf0e10cSrcweir
118cdf0e10cSrcweir sub_iterator lower_bound(
119cdf0e10cSrcweir bool & o_bExists,
120cdf0e10cSrcweir const char * & o_sNextPathSegment,
121cdf0e10cSrcweir KeyPath i_sKeyPath );
122cdf0e10cSrcweir
123cdf0e10cSrcweir DynamicList< GenericInfo >
124cdf0e10cSrcweir aChildren;
125cdf0e10cSrcweir };
126cdf0e10cSrcweir
127cdf0e10cSrcweir
128cdf0e10cSrcweir // IMPLEMENTATION
129cdf0e10cSrcweir
130cdf0e10cSrcweir
131cdf0e10cSrcweir inline const GenericInfo &
132cdf0e10cSrcweir List_GenericInfo::
operator *() const133cdf0e10cSrcweir const_iterator::operator*() const
134cdf0e10cSrcweir { return *(*it); }
135cdf0e10cSrcweir
136cdf0e10cSrcweir inline List_GenericInfo::const_iterator &
137cdf0e10cSrcweir List_GenericInfo::
operator ++()138cdf0e10cSrcweir const_iterator::operator++()
139cdf0e10cSrcweir { ++it; return *this; }
140cdf0e10cSrcweir
141cdf0e10cSrcweir inline bool
142cdf0e10cSrcweir List_GenericInfo::
operator ==(const const_iterator & i_rIter) const143cdf0e10cSrcweir const_iterator::operator==( const const_iterator & i_rIter ) const
144cdf0e10cSrcweir { return it == i_rIter.it; }
145cdf0e10cSrcweir
146cdf0e10cSrcweir inline bool
147cdf0e10cSrcweir List_GenericInfo::
operator !=(const const_iterator & i_rIter) const148cdf0e10cSrcweir const_iterator::operator!=( const const_iterator & i_rIter ) const
149cdf0e10cSrcweir { return it != i_rIter.it; }
150cdf0e10cSrcweir
151cdf0e10cSrcweir inline List_GenericInfo::
const_iterator()152cdf0e10cSrcweir const_iterator::const_iterator()
153cdf0e10cSrcweir : it(0) { }
154cdf0e10cSrcweir
155cdf0e10cSrcweir inline List_GenericInfo::
const_iterator(const DynamicList<GenericInfo>::const_iterator & i_rDynListIter)156cdf0e10cSrcweir const_iterator::const_iterator( const DynamicList< GenericInfo >::const_iterator & i_rDynListIter )
157cdf0e10cSrcweir : it(i_rDynListIter) { }
158cdf0e10cSrcweir
159cdf0e10cSrcweir
160cdf0e10cSrcweir inline GenericInfo &
161cdf0e10cSrcweir List_GenericInfo::
operator *() const162cdf0e10cSrcweir iterator::operator*() const
163cdf0e10cSrcweir { return *(*it); }
164cdf0e10cSrcweir
165cdf0e10cSrcweir inline List_GenericInfo::iterator &
166cdf0e10cSrcweir List_GenericInfo::
operator ++()167cdf0e10cSrcweir iterator::operator++()
168cdf0e10cSrcweir { ++it; return *this; }
169cdf0e10cSrcweir
170cdf0e10cSrcweir inline bool
171cdf0e10cSrcweir List_GenericInfo::
operator ==(const iterator & i_rIter) const172cdf0e10cSrcweir iterator::operator==( const iterator & i_rIter ) const
173cdf0e10cSrcweir { return it == i_rIter.it; }
174cdf0e10cSrcweir
175cdf0e10cSrcweir inline bool
176cdf0e10cSrcweir List_GenericInfo::
operator !=(const iterator & i_rIter) const177cdf0e10cSrcweir iterator::operator!=( const iterator & i_rIter ) const
178cdf0e10cSrcweir { return it != i_rIter.it; }
179cdf0e10cSrcweir
180cdf0e10cSrcweir inline List_GenericInfo::
iterator()181cdf0e10cSrcweir iterator::iterator()
182cdf0e10cSrcweir : it(0) { }
183cdf0e10cSrcweir
184cdf0e10cSrcweir inline List_GenericInfo::
iterator(const DynamicList<GenericInfo>::iterator & i_rDynListIter)185cdf0e10cSrcweir iterator::iterator( const DynamicList< GenericInfo >::iterator & i_rDynListIter )
186cdf0e10cSrcweir : it(i_rDynListIter) { }
187cdf0e10cSrcweir
188cdf0e10cSrcweir inline unsigned
Size() const189cdf0e10cSrcweir List_GenericInfo::Size() const
190cdf0e10cSrcweir { return aChildren.size(); }
191cdf0e10cSrcweir
192cdf0e10cSrcweir inline List_GenericInfo::const_iterator
Begin() const193cdf0e10cSrcweir List_GenericInfo::Begin() const
194cdf0e10cSrcweir { return aChildren.begin(); }
195cdf0e10cSrcweir
196cdf0e10cSrcweir inline List_GenericInfo::const_iterator
End() const197cdf0e10cSrcweir List_GenericInfo::End() const
198cdf0e10cSrcweir { return aChildren.end(); }
199cdf0e10cSrcweir
200cdf0e10cSrcweir inline List_GenericInfo::iterator
Begin()201cdf0e10cSrcweir List_GenericInfo::Begin()
202cdf0e10cSrcweir { return aChildren.begin(); }
203cdf0e10cSrcweir
204cdf0e10cSrcweir inline List_GenericInfo::iterator
End()205cdf0e10cSrcweir List_GenericInfo::End()
206cdf0e10cSrcweir { return aChildren.end(); }
207cdf0e10cSrcweir
208cdf0e10cSrcweir
209cdf0e10cSrcweir
210cdf0e10cSrcweir #endif
211cdf0e10cSrcweir
212