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