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 #include <precomp.h>
23 #include <ary/idl/i_module.hxx>
24 #include <ary/idl/ik_module.hxx>
25
26 // NOT FULLY DECLARED SERVICES
27 #include <cosv/tpl/processor.hxx>
28 #include <ary/idl/i_gate.hxx>
29 #include <ary/idl/i_module.hxx>
30 #include <ary/idl/i_service.hxx>
31 #include <ary/idl/i_interface.hxx>
32 #include <ary/idl/i_struct.hxx>
33 #include <ary/idl/i_exception.hxx>
34 #include <ary/idl/i_enum.hxx>
35 #include <ary/idl/i_typedef.hxx>
36 #include <ary/idl/i_constgroup.hxx>
37 #include <ary/idl/i_singleton.hxx>
38 #include <ary/idl/i_siservice.hxx>
39 #include <ary/idl/i_sisingleton.hxx>
40 #include <ary/idl/ip_ce.hxx>
41 #include <nametreenode.hxx>
42
43
44 namespace ary
45 {
46 namespace idl
47 {
48
Module()49 Module::Module()
50 : pImpl( new NameTreeNode<Ce_id> )
51 {
52 }
53
Module(const String & i_sName,const Module & i_rParent)54 Module::Module( const String & i_sName,
55 const Module & i_rParent )
56 : pImpl( new NameTreeNode<Ce_id>( i_sName,
57 *i_rParent.pImpl,
58 i_rParent.CeId() ) )
59 {
60 }
61
~Module()62 Module::~Module()
63 {
64 }
65
66 void
Add_Name(const String & i_sName,Ce_id i_nCodeEntity)67 Module::Add_Name( const String & i_sName,
68 Ce_id i_nCodeEntity )
69 {
70 pImpl->Add_Name(i_sName, i_nCodeEntity);
71 }
72
73 Ce_id
Search_Name(const String & i_sName) const74 Module::Search_Name( const String & i_sName ) const
75 {
76 return pImpl->Search_Name(i_sName);
77 }
78
79 void
Get_Names(Dyn_StdConstIterator<Ce_id> & o_rResult) const80 Module::Get_Names( Dyn_StdConstIterator<Ce_id> & o_rResult ) const
81 {
82 pImpl->Get_Names( o_rResult );
83 }
84
85 void
do_Accept(csv::ProcessorIfc & io_processor) const86 Module::do_Accept( csv::ProcessorIfc & io_processor ) const
87 {
88 csv::CheckedCall(io_processor, *this);
89 }
90
91 ClassId
get_AryClass() const92 Module::get_AryClass() const
93 {
94 return class_id;
95 }
96
97 const String &
inq_LocalName() const98 Module::inq_LocalName() const
99 {
100 return pImpl->Name();
101 }
102
103 Ce_id
inq_NameRoom() const104 Module::inq_NameRoom() const
105 {
106 return pImpl->Parent();
107 }
108
109 Ce_id
inq_Owner() const110 Module::inq_Owner() const
111 {
112 return pImpl->Parent();
113 }
114
115 E_SightLevel
inq_SightLevel() const116 Module::inq_SightLevel() const
117 {
118 return sl_Module;
119 }
120
121
122 namespace ifc_module
123 {
124
125 inline const Module &
module_cast(const CodeEntity & i_ce)126 module_cast( const CodeEntity & i_ce )
127 {
128 csv_assert( i_ce.AryClass() == Module::class_id );
129 return static_cast< const Module& >(i_ce);
130 }
131
132 typedef NameTreeNode<Ce_id>::Map_LocalNames NameMap;
133
134 void
Get_AllChildrenSeparated(std::vector<const CodeEntity * > & o_nestedModules,std::vector<const CodeEntity * > & o_services,std::vector<const CodeEntity * > & o_interfaces,std::vector<const CodeEntity * > & o_structs,std::vector<const CodeEntity * > & o_exceptions,std::vector<const CodeEntity * > & o_enums,std::vector<const CodeEntity * > & o_typedefs,std::vector<const CodeEntity * > & o_constantGroups,std::vector<const CodeEntity * > & o_singletons,const CePilot & i_pilot,const CodeEntity & i_ce)135 attr::Get_AllChildrenSeparated( std::vector< const CodeEntity* > & o_nestedModules,
136 std::vector< const CodeEntity* > & o_services,
137 std::vector< const CodeEntity* > & o_interfaces,
138 std::vector< const CodeEntity* > & o_structs,
139 std::vector< const CodeEntity* > & o_exceptions,
140 std::vector< const CodeEntity* > & o_enums,
141 std::vector< const CodeEntity* > & o_typedefs,
142 std::vector< const CodeEntity* > & o_constantGroups,
143 std::vector< const CodeEntity* > & o_singletons,
144 const CePilot & i_pilot,
145 const CodeEntity & i_ce )
146 {
147 const CodeEntity *
148 pCe = 0;
149 NameMap::const_iterator
150 itEnd = module_cast(i_ce).pImpl->LocalNames().end();
151 for ( NameMap::const_iterator
152 it = module_cast(i_ce).pImpl->LocalNames().begin();
153 it != itEnd;
154 ++it )
155 {
156 pCe = &i_pilot.Find_Ce( (*it).second );
157 switch (pCe->AryClass())
158 {
159 case Module::class_id:
160 o_nestedModules.push_back(pCe);
161 break;
162 case SglIfcService::class_id:
163 case Service::class_id:
164 o_services.push_back(pCe);
165 break;
166 case Interface::class_id:
167 o_interfaces.push_back(pCe);
168 break;
169 case Struct::class_id:
170 o_structs.push_back(pCe);
171 break;
172 case Exception::class_id:
173 o_exceptions.push_back(pCe);
174 break;
175 case Enum::class_id:
176 o_enums.push_back(pCe);
177 break;
178 case Typedef::class_id:
179 o_typedefs.push_back(pCe);
180 break;
181 case ConstantsGroup::class_id:
182 o_constantGroups.push_back(pCe);
183 break;
184 case SglIfcSingleton::class_id:
185 case Singleton::class_id:
186 o_singletons.push_back(pCe);
187 break;
188 }
189 } // end for
190 }
191
192
193 } // namespace ifc_module
194
195
196
197 } // namespace idl
198 } // namespace ary
199