xref: /AOO41X/main/autodoc/inc/ary/cpp/c_traits.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 ARY_CPP_C_TRAITS_HXX
25cdf0e10cSrcweir #define ARY_CPP_C_TRAITS_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir // USED SERVICES
30cdf0e10cSrcweir 	// BASE CLASSES
31cdf0e10cSrcweir 	// OTHER
32cdf0e10cSrcweir #include <ary/cpp/c_types4cpp.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir 
35cdf0e10cSrcweir 
36cdf0e10cSrcweir namespace ary
37cdf0e10cSrcweir {
38cdf0e10cSrcweir namespace symtree
39cdf0e10cSrcweir {
40cdf0e10cSrcweir     template <class X> class Node;
41cdf0e10cSrcweir }
42cdf0e10cSrcweir }
43cdf0e10cSrcweir 
44cdf0e10cSrcweir 
45cdf0e10cSrcweir 
46cdf0e10cSrcweir 
47cdf0e10cSrcweir namespace ary
48cdf0e10cSrcweir {
49cdf0e10cSrcweir namespace cpp
50cdf0e10cSrcweir {
51cdf0e10cSrcweir 
52cdf0e10cSrcweir 
53cdf0e10cSrcweir /** Basic traits for derived ones of ->CodeEntity.
54cdf0e10cSrcweir */
55cdf0e10cSrcweir struct Ce_Traits
56cdf0e10cSrcweir {
57cdf0e10cSrcweir     typedef CodeEntity          entity_base_type;
58cdf0e10cSrcweir     typedef Ce_id               id_type;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir     static entity_base_type &
61cdf0e10cSrcweir                         EntityOf_(
62cdf0e10cSrcweir                             id_type             i_id );
63cdf0e10cSrcweir };
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 
66cdf0e10cSrcweir /** An instance of SYMBOL_TRAITS for ->::ary::SortedIds<>.
67cdf0e10cSrcweir 
68cdf0e10cSrcweir     @see ::ary::SortedIds<>
69cdf0e10cSrcweir */
70cdf0e10cSrcweir struct CeNode_Traits : public Ce_Traits
71cdf0e10cSrcweir {
72cdf0e10cSrcweir     static const symtree::Node<CeNode_Traits> *
73cdf0e10cSrcweir                         NodeOf_(
74cdf0e10cSrcweir                             const entity_base_type &
75cdf0e10cSrcweir                                                 i_entity );
76cdf0e10cSrcweir     static symtree::Node<CeNode_Traits> *
77cdf0e10cSrcweir                         NodeOf_(
78cdf0e10cSrcweir                             entity_base_type &  i_entity );
79cdf0e10cSrcweir     static entity_base_type *
80cdf0e10cSrcweir                         ParentOf_(
81cdf0e10cSrcweir                             const entity_base_type &
82cdf0e10cSrcweir                                                 i_entity );
83cdf0e10cSrcweir     template <class KEY>
84cdf0e10cSrcweir     static id_type      Search_(
85cdf0e10cSrcweir                             const entity_base_type &
86cdf0e10cSrcweir                                                 i_entity,
87cdf0e10cSrcweir                             const KEY &         i_localKey );
88cdf0e10cSrcweir };
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 
91cdf0e10cSrcweir /** An instance of COMPARE for ->::ary::SortedIds<>.
92cdf0e10cSrcweir 
93cdf0e10cSrcweir     @see ::ary::SortedIds<>
94cdf0e10cSrcweir */
95cdf0e10cSrcweir struct Ce_Compare : public Ce_Traits
96cdf0e10cSrcweir {
97cdf0e10cSrcweir     typedef  String             key_type;
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     static const key_type &
100cdf0e10cSrcweir                         KeyOf_(
101cdf0e10cSrcweir                             const entity_base_type &
102cdf0e10cSrcweir                                                 i_entity );
103cdf0e10cSrcweir     static bool         Lesser_(
104cdf0e10cSrcweir                             const key_type &    i_1,
105cdf0e10cSrcweir                             const key_type &    i_2 );
106cdf0e10cSrcweir };
107cdf0e10cSrcweir 
108cdf0e10cSrcweir /** An instance of COMPARE for ->::ary::SortedIds<>.
109cdf0e10cSrcweir 
110cdf0e10cSrcweir     @see ::ary::SortedIds<>
111cdf0e10cSrcweir */
112cdf0e10cSrcweir struct Ce_GlobalCompare : public Ce_Traits
113cdf0e10cSrcweir {
114cdf0e10cSrcweir     typedef  entity_base_type   key_type;
115cdf0e10cSrcweir 
116cdf0e10cSrcweir     static const key_type &
KeyOf_ary::cpp::Ce_GlobalCompare117cdf0e10cSrcweir                         KeyOf_(
118cdf0e10cSrcweir                             const entity_base_type &
119cdf0e10cSrcweir                                                 i_entity )
120cdf0e10cSrcweir                             { return i_entity; }
121cdf0e10cSrcweir     static bool         Lesser_(
122cdf0e10cSrcweir                             const key_type &    i_1,
123cdf0e10cSrcweir                             const key_type &    i_2 );
124cdf0e10cSrcweir };
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 
127cdf0e10cSrcweir /** Basic traits for derivd ones of ->DefineEntity.
128cdf0e10cSrcweir */
129cdf0e10cSrcweir struct Def_Traits
130cdf0e10cSrcweir {
131cdf0e10cSrcweir     typedef DefineEntity        entity_base_type;
132cdf0e10cSrcweir     typedef De_id               id_type;
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     static entity_base_type &
135cdf0e10cSrcweir                         EntityOf_(
136cdf0e10cSrcweir                             id_type             i_id );
137cdf0e10cSrcweir };
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 
140cdf0e10cSrcweir /** An instance of COMPARE for ->::ary::SortedIds<>.
141cdf0e10cSrcweir 
142cdf0e10cSrcweir     @see ::ary::SortedIds<>
143cdf0e10cSrcweir */
144cdf0e10cSrcweir struct Def_Compare : public Def_Traits
145cdf0e10cSrcweir {
146cdf0e10cSrcweir     typedef  String             key_type;
147cdf0e10cSrcweir 
148cdf0e10cSrcweir     static const key_type &
149cdf0e10cSrcweir                         KeyOf_(
150cdf0e10cSrcweir                             const entity_base_type &
151cdf0e10cSrcweir                                                 i_entity );
152cdf0e10cSrcweir     static bool         Lesser_(
153cdf0e10cSrcweir                             const key_type &    i_1,
154cdf0e10cSrcweir                             const key_type &    i_2 );
155cdf0e10cSrcweir };
156cdf0e10cSrcweir 
157cdf0e10cSrcweir /** Basic traits for derivd ones of ->Type.
158cdf0e10cSrcweir */
159cdf0e10cSrcweir struct Type_Traits
160cdf0e10cSrcweir {
161cdf0e10cSrcweir     typedef Type                entity_base_type;
162cdf0e10cSrcweir     typedef Type_id             id_type;
163cdf0e10cSrcweir 
164cdf0e10cSrcweir     static entity_base_type &
165cdf0e10cSrcweir                         EntityOf_(
166cdf0e10cSrcweir                             id_type             i_id );
167cdf0e10cSrcweir };
168cdf0e10cSrcweir 
169cdf0e10cSrcweir /** An instance of COMPARE for ->::ary::SortedIds<>.
170cdf0e10cSrcweir 
171cdf0e10cSrcweir     @see ::ary::SortedIds<>
172cdf0e10cSrcweir */
173cdf0e10cSrcweir struct UsedType_Compare : public Type_Traits
174cdf0e10cSrcweir {
175cdf0e10cSrcweir     typedef  UsedType           key_type;
176cdf0e10cSrcweir 
177cdf0e10cSrcweir     static const key_type &
178cdf0e10cSrcweir                         KeyOf_(
179cdf0e10cSrcweir                             const entity_base_type &
180cdf0e10cSrcweir                                                 i_entity );
181cdf0e10cSrcweir     static bool         Lesser_(
182cdf0e10cSrcweir                             const key_type &    i_1,
183cdf0e10cSrcweir                             const key_type &    i_2 );
184cdf0e10cSrcweir };
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 
191cdf0e10cSrcweir // IMPLEMENTATION
192cdf0e10cSrcweir 
193cdf0e10cSrcweir /// Implementation helper for ->CeNode_Traits::Search_ .
194cdf0e10cSrcweir Ce_id                   CeNode_Search(
195cdf0e10cSrcweir                             const CodeEntity &  i_entity,
196cdf0e10cSrcweir                             const String &      i_localKey );
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 
199cdf0e10cSrcweir template <class KEY>
200cdf0e10cSrcweir Ce_Traits::id_type
Search_(const entity_base_type & i_entity,const KEY & i_localKey)201cdf0e10cSrcweir CeNode_Traits::Search_( const entity_base_type & i_entity,
202cdf0e10cSrcweir                         const KEY &              i_localKey )
203cdf0e10cSrcweir {
204cdf0e10cSrcweir     return CeNode_Search(i_entity, i_localKey);
205cdf0e10cSrcweir }
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 
210cdf0e10cSrcweir }   //  namespace cpp
211cdf0e10cSrcweir }   //  namespace ary
212cdf0e10cSrcweir #endif
213