xref: /AOO41X/main/autodoc/inc/ary/cpp/c_traits.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef ARY_CPP_C_TRAITS_HXX
29*cdf0e10cSrcweir #define ARY_CPP_C_TRAITS_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir // USED SERVICES
34*cdf0e10cSrcweir 	// BASE CLASSES
35*cdf0e10cSrcweir 	// OTHER
36*cdf0e10cSrcweir #include <ary/cpp/c_types4cpp.hxx>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir namespace ary
41*cdf0e10cSrcweir {
42*cdf0e10cSrcweir namespace symtree
43*cdf0e10cSrcweir {
44*cdf0e10cSrcweir     template <class X> class Node;
45*cdf0e10cSrcweir }
46*cdf0e10cSrcweir }
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir namespace ary
52*cdf0e10cSrcweir {
53*cdf0e10cSrcweir namespace cpp
54*cdf0e10cSrcweir {
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir /** Basic traits for derived ones of ->CodeEntity.
58*cdf0e10cSrcweir */
59*cdf0e10cSrcweir struct Ce_Traits
60*cdf0e10cSrcweir {
61*cdf0e10cSrcweir     typedef CodeEntity          entity_base_type;
62*cdf0e10cSrcweir     typedef Ce_id               id_type;
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir     static entity_base_type &
65*cdf0e10cSrcweir                         EntityOf_(
66*cdf0e10cSrcweir                             id_type             i_id );
67*cdf0e10cSrcweir };
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir /** An instance of SYMBOL_TRAITS for ->::ary::SortedIds<>.
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir     @see ::ary::SortedIds<>
73*cdf0e10cSrcweir */
74*cdf0e10cSrcweir struct CeNode_Traits : public Ce_Traits
75*cdf0e10cSrcweir {
76*cdf0e10cSrcweir     static const symtree::Node<CeNode_Traits> *
77*cdf0e10cSrcweir                         NodeOf_(
78*cdf0e10cSrcweir                             const entity_base_type &
79*cdf0e10cSrcweir                                                 i_entity );
80*cdf0e10cSrcweir     static symtree::Node<CeNode_Traits> *
81*cdf0e10cSrcweir                         NodeOf_(
82*cdf0e10cSrcweir                             entity_base_type &  i_entity );
83*cdf0e10cSrcweir     static entity_base_type *
84*cdf0e10cSrcweir                         ParentOf_(
85*cdf0e10cSrcweir                             const entity_base_type &
86*cdf0e10cSrcweir                                                 i_entity );
87*cdf0e10cSrcweir     template <class KEY>
88*cdf0e10cSrcweir     static id_type      Search_(
89*cdf0e10cSrcweir                             const entity_base_type &
90*cdf0e10cSrcweir                                                 i_entity,
91*cdf0e10cSrcweir                             const KEY &         i_localKey );
92*cdf0e10cSrcweir };
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir /** An instance of COMPARE for ->::ary::SortedIds<>.
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir     @see ::ary::SortedIds<>
98*cdf0e10cSrcweir */
99*cdf0e10cSrcweir struct Ce_Compare : public Ce_Traits
100*cdf0e10cSrcweir {
101*cdf0e10cSrcweir     typedef  String             key_type;
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir     static const key_type &
104*cdf0e10cSrcweir                         KeyOf_(
105*cdf0e10cSrcweir                             const entity_base_type &
106*cdf0e10cSrcweir                                                 i_entity );
107*cdf0e10cSrcweir     static bool         Lesser_(
108*cdf0e10cSrcweir                             const key_type &    i_1,
109*cdf0e10cSrcweir                             const key_type &    i_2 );
110*cdf0e10cSrcweir };
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir /** An instance of COMPARE for ->::ary::SortedIds<>.
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir     @see ::ary::SortedIds<>
115*cdf0e10cSrcweir */
116*cdf0e10cSrcweir struct Ce_GlobalCompare : public Ce_Traits
117*cdf0e10cSrcweir {
118*cdf0e10cSrcweir     typedef  entity_base_type   key_type;
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir     static const key_type &
121*cdf0e10cSrcweir                         KeyOf_(
122*cdf0e10cSrcweir                             const entity_base_type &
123*cdf0e10cSrcweir                                                 i_entity )
124*cdf0e10cSrcweir                             { return i_entity; }
125*cdf0e10cSrcweir     static bool         Lesser_(
126*cdf0e10cSrcweir                             const key_type &    i_1,
127*cdf0e10cSrcweir                             const key_type &    i_2 );
128*cdf0e10cSrcweir };
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir /** Basic traits for derivd ones of ->DefineEntity.
132*cdf0e10cSrcweir */
133*cdf0e10cSrcweir struct Def_Traits
134*cdf0e10cSrcweir {
135*cdf0e10cSrcweir     typedef DefineEntity        entity_base_type;
136*cdf0e10cSrcweir     typedef De_id               id_type;
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir     static entity_base_type &
139*cdf0e10cSrcweir                         EntityOf_(
140*cdf0e10cSrcweir                             id_type             i_id );
141*cdf0e10cSrcweir };
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir /** An instance of COMPARE for ->::ary::SortedIds<>.
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir     @see ::ary::SortedIds<>
147*cdf0e10cSrcweir */
148*cdf0e10cSrcweir struct Def_Compare : public Def_Traits
149*cdf0e10cSrcweir {
150*cdf0e10cSrcweir     typedef  String             key_type;
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir     static const key_type &
153*cdf0e10cSrcweir                         KeyOf_(
154*cdf0e10cSrcweir                             const entity_base_type &
155*cdf0e10cSrcweir                                                 i_entity );
156*cdf0e10cSrcweir     static bool         Lesser_(
157*cdf0e10cSrcweir                             const key_type &    i_1,
158*cdf0e10cSrcweir                             const key_type &    i_2 );
159*cdf0e10cSrcweir };
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir /** Basic traits for derivd ones of ->Type.
162*cdf0e10cSrcweir */
163*cdf0e10cSrcweir struct Type_Traits
164*cdf0e10cSrcweir {
165*cdf0e10cSrcweir     typedef Type                entity_base_type;
166*cdf0e10cSrcweir     typedef Type_id             id_type;
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir     static entity_base_type &
169*cdf0e10cSrcweir                         EntityOf_(
170*cdf0e10cSrcweir                             id_type             i_id );
171*cdf0e10cSrcweir };
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir /** An instance of COMPARE for ->::ary::SortedIds<>.
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir     @see ::ary::SortedIds<>
176*cdf0e10cSrcweir */
177*cdf0e10cSrcweir struct UsedType_Compare : public Type_Traits
178*cdf0e10cSrcweir {
179*cdf0e10cSrcweir     typedef  UsedType           key_type;
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir     static const key_type &
182*cdf0e10cSrcweir                         KeyOf_(
183*cdf0e10cSrcweir                             const entity_base_type &
184*cdf0e10cSrcweir                                                 i_entity );
185*cdf0e10cSrcweir     static bool         Lesser_(
186*cdf0e10cSrcweir                             const key_type &    i_1,
187*cdf0e10cSrcweir                             const key_type &    i_2 );
188*cdf0e10cSrcweir };
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir // IMPLEMENTATION
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir /// Implementation helper for ->CeNode_Traits::Search_ .
198*cdf0e10cSrcweir Ce_id                   CeNode_Search(
199*cdf0e10cSrcweir                             const CodeEntity &  i_entity,
200*cdf0e10cSrcweir                             const String &      i_localKey );
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir template <class KEY>
204*cdf0e10cSrcweir Ce_Traits::id_type
205*cdf0e10cSrcweir CeNode_Traits::Search_( const entity_base_type & i_entity,
206*cdf0e10cSrcweir                         const KEY &              i_localKey )
207*cdf0e10cSrcweir {
208*cdf0e10cSrcweir     return CeNode_Search(i_entity, i_localKey);
209*cdf0e10cSrcweir }
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir }   //  namespace cpp
215*cdf0e10cSrcweir }   //  namespace ary
216*cdf0e10cSrcweir #endif
217