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_IDL_NNFINDER_HXX
29 #define ARY_IDL_NNFINDER_HXX
30 
31 // USED SERVICES
32 #include "is_ce.hxx"
33 
34 
35 
36 
37 namespace ary
38 {
39 namespace idl
40 {
41 
42 
43 /** Gives context info for tree search functions.
44 
45     @collab ->ary::Search_SubTree<>()
46     @collab ->ary::Search_SubTree_UpTillRoot<>()
47 */
48 class Find_ModuleNode
49 {
50   public:
51     typedef Ce_id                           id_type;
52     typedef StringVector::const_iterator    name_iterator;
53 
54     // LIFECYCLE
55                         Find_ModuleNode(
56                             const Ce_Storage &  i_rStorage,
57                             name_iterator       it_begin,
58                             name_iterator       it_end,
59                             const String &      i_sName )
60                             :   rStorage(i_rStorage),
61                                 itBegin(it_begin),
62                                 itEnd(it_end),
63                                 sName2Search(i_sName) { if (itBegin != itEnd ? (*itBegin).empty() : false) ++itBegin; }
64     // OPERATIONS
65     const Module *      operator()(
66                             id_type             i_id ) const
67                             { return i_id.IsValid()
68                                         ?   & ary_cast<Module>(rStorage[i_id])
69                                         :   0; }
70 
71     name_iterator       Begin() const           { return itBegin; }
72     name_iterator       End() const             { return itEnd; }
73     const String &      Name2Search() const     { return sName2Search; }
74 
75   private:
76     // DATA
77     const Ce_Storage &  rStorage;
78     name_iterator       itBegin;
79     name_iterator       itEnd;
80     String              sName2Search;
81 };
82 
83 
84 
85 
86 class Types_forSetCe_Id
87 {
88   public:
89     typedef Ce_id                           element_type;
90     typedef Ce_Storage                      find_type;
91 
92     //  KORR_FUTURE: Check, if this sorting is right or the ary standard
93     //  sorting should be used.
94     struct sort_type
95     {
96                         sort_type(
97                             const find_type &   i_rFinder )
98                                                 : rFinder(i_rFinder) {}
99         bool            operator()(
100                             const element_type   &
101                                                 i_r1,
102                             const element_type   &
103                                                 i_r2 ) const
104         {
105             return rFinder[i_r1].LocalName()
106                    < rFinder[i_r2].LocalName();
107         }
108 
109       private:
110         const find_type &     rFinder;
111 
112     };
113 };
114 
115 
116 }   // namespace idl
117 }   // namespace ary
118 #endif
119