xref: /trunk/main/autodoc/source/ary/idl/i_nnfinder.hxx (revision 1c78a5d6)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef ARY_IDL_NNFINDER_HXX
25 #define ARY_IDL_NNFINDER_HXX
26 
27 // USED SERVICES
28 #include "is_ce.hxx"
29 
30 
31 
32 
33 namespace ary
34 {
35 namespace idl
36 {
37 
38 
39 /** Gives context info for tree search functions.
40 
41     @collab ->ary::Search_SubTree<>()
42     @collab ->ary::Search_SubTree_UpTillRoot<>()
43 */
44 class Find_ModuleNode
45 {
46   public:
47     typedef Ce_id                           id_type;
48     typedef StringVector::const_iterator    name_iterator;
49 
50     // LIFECYCLE
Find_ModuleNode(const Ce_Storage & i_rStorage,name_iterator it_begin,name_iterator it_end,const String & i_sName)51                         Find_ModuleNode(
52                             const Ce_Storage &  i_rStorage,
53                             name_iterator       it_begin,
54                             name_iterator       it_end,
55                             const String &      i_sName )
56                             :   rStorage(i_rStorage),
57                                 itBegin(it_begin),
58                                 itEnd(it_end),
59                                 sName2Search(i_sName) { if (itBegin != itEnd ? (*itBegin).empty() : false) ++itBegin; }
60     // OPERATIONS
operator ()(id_type i_id) const61     const Module *      operator()(
62                             id_type             i_id ) const
63                             { return i_id.IsValid()
64                                         ?   & ary_cast<Module>(rStorage[i_id])
65                                         :   0; }
66 
Begin() const67     name_iterator       Begin() const           { return itBegin; }
End() const68     name_iterator       End() const             { return itEnd; }
Name2Search() const69     const String &      Name2Search() const     { return sName2Search; }
70 
71   private:
72     // DATA
73     const Ce_Storage &  rStorage;
74     name_iterator       itBegin;
75     name_iterator       itEnd;
76     String              sName2Search;
77 };
78 
79 
80 
81 
82 class Types_forSetCe_Id
83 {
84   public:
85     typedef Ce_id                           element_type;
86     typedef Ce_Storage                      find_type;
87 
88     //  KORR_FUTURE: Check, if this sorting is right or the ary standard
89     //  sorting should be used.
90     struct sort_type
91     {
sort_typeary::idl::Types_forSetCe_Id::sort_type92                         sort_type(
93                             const find_type &   i_rFinder )
94                                                 : rFinder(i_rFinder) {}
operator ()ary::idl::Types_forSetCe_Id::sort_type95         bool            operator()(
96                             const element_type   &
97                                                 i_r1,
98                             const element_type   &
99                                                 i_r2 ) const
100         {
101             return rFinder[i_r1].LocalName()
102                    < rFinder[i_r2].LocalName();
103         }
104 
105       private:
106         const find_type &     rFinder;
107 
108     };
109 };
110 
111 
112 }   // namespace idl
113 }   // namespace ary
114 #endif
115