1 | #include "attribute_map.hpp" |
---|
2 | #include "indent.hpp" |
---|
3 | |
---|
4 | namespace xios |
---|
5 | { |
---|
6 | /// ////////////////////// Définitions ////////////////////// /// |
---|
7 | CAttributeMap* CAttributeMap::Current = NULL; |
---|
8 | |
---|
9 | CAttributeMap::CAttributeMap(void) |
---|
10 | : xios_map<StdString, CAttribute*>() |
---|
11 | { CAttributeMap::Current = this; } |
---|
12 | |
---|
13 | CAttributeMap::~CAttributeMap(void) |
---|
14 | { /* Ne rien faire de plus */ } |
---|
15 | |
---|
16 | ///-------------------------------------------------------------- |
---|
17 | |
---|
18 | /*! |
---|
19 | Clear all attributes of an object and reset them to empty state |
---|
20 | */ |
---|
21 | void CAttributeMap::clearAllAttributes(void) |
---|
22 | { |
---|
23 | typedef std::pair<StdString, CAttribute*> StdStrAttPair; |
---|
24 | SuperClassMap::const_iterator it = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
25 | for (; it != end; it++) |
---|
26 | { |
---|
27 | const StdStrAttPair& att = *it; |
---|
28 | att.second->reset(); |
---|
29 | } |
---|
30 | } |
---|
31 | |
---|
32 | //--------------------------------------------------------------- |
---|
33 | |
---|
34 | /* |
---|
35 | Clear an attribute and reset its value |
---|
36 | \param[in] key id of attribute |
---|
37 | */ |
---|
38 | void CAttributeMap::clearAttribute(const StdString& key) |
---|
39 | { |
---|
40 | if (hasAttribute(key)) this->find(key)->second->reset(); |
---|
41 | } |
---|
42 | |
---|
43 | //--------------------------------------------------------------- |
---|
44 | |
---|
45 | /*! |
---|
46 | Set an attribute of certain id with a value |
---|
47 | \param[in] key id of the attribute |
---|
48 | \param[in] attr value of attribute |
---|
49 | */ |
---|
50 | void CAttributeMap::setAttribute(const StdString& key, CAttribute* const attr) |
---|
51 | { |
---|
52 | if (!this->hasAttribute(key)) |
---|
53 | ERROR("CAttributeMap::setAttribute(key, attr)", |
---|
54 | << "[ key = " << key << "] key not found !"); |
---|
55 | if (attr == NULL) |
---|
56 | ERROR("CAttributeMap::setAttribute(key, attr)", |
---|
57 | << "[ key = " << key << "] attr is null !"); |
---|
58 | this->find(key)->second->set(*attr); |
---|
59 | // this->find(key)->second->setAnyValue(attr->getAnyValue()); |
---|
60 | } |
---|
61 | |
---|
62 | //--------------------------------------------------------------- |
---|
63 | |
---|
64 | /*! |
---|
65 | Subscript operator. Return attribute with a specific id |
---|
66 | */ |
---|
67 | CAttribute* CAttributeMap::operator[](const StdString& key) |
---|
68 | { |
---|
69 | if (!this->hasAttribute(key)) |
---|
70 | ERROR("CAttributeMap::operator[](const StdString& key)", |
---|
71 | << "[ key = " << key << "] key not found !"); |
---|
72 | return SuperClassMap::operator[](key); |
---|
73 | } |
---|
74 | |
---|
75 | //--------------------------------------------------------------- |
---|
76 | |
---|
77 | StdString CAttributeMap::toString(void) const |
---|
78 | { |
---|
79 | typedef std::pair<StdString, CAttribute*> StdStrAttPair; |
---|
80 | StdOStringStream oss; |
---|
81 | |
---|
82 | SuperClassMap::const_iterator it = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
83 | for (; it != end; it++) |
---|
84 | { |
---|
85 | const StdStrAttPair& att = *it; |
---|
86 | if (!att.second->isEmpty()) |
---|
87 | oss << *att.second << " "; |
---|
88 | } |
---|
89 | return oss.str(); |
---|
90 | } |
---|
91 | |
---|
92 | //--------------------------------------------------------------- |
---|
93 | |
---|
94 | void CAttributeMap::fromString(const StdString& str) |
---|
95 | { |
---|
96 | ERROR("CAttributeMap::fromString(const StdString& str)", |
---|
97 | << "[ str = " << str << "] Not implemented yet !"); |
---|
98 | } |
---|
99 | |
---|
100 | //--------------------------------------------------------------- |
---|
101 | |
---|
102 | //StdOStream& operator << (StdOStream& os, const CAttributeMap& attributmap) |
---|
103 | //{ os << attributmap.toString(); return (os); } |
---|
104 | |
---|
105 | //--------------------------------------------------------------- |
---|
106 | |
---|
107 | void CAttributeMap::setAttributes(const xml::THashAttributes& attributes) |
---|
108 | { |
---|
109 | for (xml::THashAttributes::const_iterator it = attributes.begin(); |
---|
110 | it != attributes.end(); |
---|
111 | it++) |
---|
112 | { |
---|
113 | if ((*it).first.compare(StdString("id")) != 0 && (*it).first.compare(StdString("src")) != 0) |
---|
114 | { |
---|
115 | //if (CAttributeMap::operator[]((*it).first)->isEmpty()) |
---|
116 | CAttributeMap::operator[]((*it).first)->fromString((*it).second); |
---|
117 | } |
---|
118 | } |
---|
119 | } |
---|
120 | |
---|
121 | /*! |
---|
122 | Compare two attribute maps |
---|
123 | \param [in] another attribute map to compare |
---|
124 | \param [in] excludedAttrs attribute to be excluded from comparasion |
---|
125 | \return true if these two maps have same attributes whose value are identical |
---|
126 | */ |
---|
127 | bool CAttributeMap::isEqual(const CAttributeMap& another, const vector<StdString>& excludedAttrs) |
---|
128 | { |
---|
129 | SuperClassMap::const_iterator itb = another.begin(), ite = another.end(), it; |
---|
130 | for (it = itb; it !=ite; ++it) |
---|
131 | { |
---|
132 | bool excluded = false; |
---|
133 | for (int idx = 0; idx < excludedAttrs.size(); ++idx) |
---|
134 | { |
---|
135 | if (0 == (*it).first.compare(excludedAttrs[idx])) |
---|
136 | { |
---|
137 | excluded = true; |
---|
138 | break; |
---|
139 | } |
---|
140 | } |
---|
141 | |
---|
142 | if (!excluded) |
---|
143 | { |
---|
144 | if ((*it).first.compare(StdString("id")) != 0 && (*it).first.compare(StdString("src")) != 0) |
---|
145 | { |
---|
146 | if (this->hasAttribute(it->first)) |
---|
147 | { |
---|
148 | if (!((*it).second->isEqual(*(*this)[it->first]))) |
---|
149 | { |
---|
150 | return false; |
---|
151 | } |
---|
152 | } |
---|
153 | else |
---|
154 | return false; |
---|
155 | } |
---|
156 | } |
---|
157 | } |
---|
158 | |
---|
159 | return true; |
---|
160 | } |
---|
161 | |
---|
162 | |
---|
163 | //--------------------------------------------------------------- |
---|
164 | |
---|
165 | /*! |
---|
166 | \brief Set attributes from a specific attributemap, considered parent. |
---|
167 | The child attribute map will insert the attributes of its parent into its current attribute map. |
---|
168 | The existing attributes can be filled with the values of the parent map if they are empty or |
---|
169 | simply replaced by these values depending on choice of user. |
---|
170 | \param [in] _parent Attribute map from which the current map gets attributes. |
---|
171 | \param [in] apply Specify if current attribute map is replaced by the attributes of parent (false) |
---|
172 | or filled in in case of emptyp (true) |
---|
173 | */ |
---|
174 | void CAttributeMap::setAttributes(const CAttributeMap* const _parent, bool apply) |
---|
175 | { |
---|
176 | typedef std::pair<StdString, CAttribute*> StdStrAttPair; |
---|
177 | |
---|
178 | SuperClassMap::const_iterator it = _parent->begin(), end = _parent->end(); |
---|
179 | for (; it != end; it++) |
---|
180 | { |
---|
181 | const StdStrAttPair& el = *it; |
---|
182 | if (this->hasAttribute(el.first)) |
---|
183 | { |
---|
184 | CAttribute* currentAtt = CAttributeMap::operator[](el.first); |
---|
185 | CAttribute* parentAtt = el.second; |
---|
186 | if (apply) |
---|
187 | { |
---|
188 | if (currentAtt->isEmpty() && currentAtt->canInherite() && !el.second->isEmpty()) |
---|
189 | { |
---|
190 | this->setAttribute(el.first, el.second); |
---|
191 | } |
---|
192 | } |
---|
193 | else currentAtt->setInheritedValue(*parentAtt); |
---|
194 | } |
---|
195 | } |
---|
196 | } |
---|
197 | |
---|
198 | /*! |
---|
199 | Duplicate attribute map with a specific attribute map. |
---|
200 | Copy all non-empty attribute of the current attribute map |
---|
201 | \param [in] srcAttr attribute map which is copied from. |
---|
202 | */ |
---|
203 | void CAttributeMap::duplicateAttributes(const CAttributeMap* const srcAttr) |
---|
204 | { |
---|
205 | typedef std::pair<StdString, CAttribute*> StdStrAttPair; |
---|
206 | |
---|
207 | SuperClassMap::const_iterator it = srcAttr->begin(), end = srcAttr->end(); |
---|
208 | for (; it != end; it++) |
---|
209 | { |
---|
210 | const StdStrAttPair& el = *it; |
---|
211 | if (this->hasAttribute(el.first)) |
---|
212 | { |
---|
213 | if (!el.second->isEmpty()) |
---|
214 | { |
---|
215 | this->setAttribute(el.first, el.second); |
---|
216 | } |
---|
217 | } |
---|
218 | } |
---|
219 | } |
---|
220 | |
---|
221 | //--------------------------------------------------------------- |
---|
222 | /* |
---|
223 | void CAttributeMap::toBinary(StdOStream& os) const |
---|
224 | { |
---|
225 | typedef std::pair<StdString, CAttribute*> StdStrAttPair; |
---|
226 | SuperClassMap::const_iterator it = this->begin(), end = this->end(); |
---|
227 | |
---|
228 | const StdSize nbatt = SuperClassMap::size(); |
---|
229 | os.write (reinterpret_cast<const char*>(&nbatt) , sizeof(StdSize)); |
---|
230 | |
---|
231 | for (; it != end; it++) |
---|
232 | { |
---|
233 | const StdString& key = it->first; |
---|
234 | const CAttribute* value = it->second; |
---|
235 | const StdSize size = key.size(); |
---|
236 | |
---|
237 | os.write (reinterpret_cast<const char*>(&size) , sizeof(StdSize)); |
---|
238 | os.write (key.data(), size* sizeof(char)); |
---|
239 | |
---|
240 | if (!value->isEmpty()) |
---|
241 | { |
---|
242 | bool b = true; |
---|
243 | os.write (reinterpret_cast<const char*>(&b) , sizeof(bool)); |
---|
244 | value->toBinary(os); |
---|
245 | } |
---|
246 | else |
---|
247 | { |
---|
248 | bool b = false; |
---|
249 | os.write (reinterpret_cast<const char*>(&b) , sizeof(bool)); |
---|
250 | } |
---|
251 | } |
---|
252 | } |
---|
253 | |
---|
254 | //--------------------------------------------------------------- |
---|
255 | |
---|
256 | void CAttributeMap::fromBinary(StdIStream& is) |
---|
257 | { |
---|
258 | StdSize nbatt = 0; |
---|
259 | is.read (reinterpret_cast<char*>(&nbatt), sizeof(StdSize)); |
---|
260 | |
---|
261 | for (StdSize i = 0; i < nbatt; i++) |
---|
262 | { |
---|
263 | bool hasValue = false; |
---|
264 | StdSize size = 0; |
---|
265 | is.read (reinterpret_cast<char*>(&size), sizeof(StdSize)); |
---|
266 | StdString key(size, ' '); |
---|
267 | is.read (const_cast<char *>(key.data()), size* sizeof(char)); |
---|
268 | |
---|
269 | if (!this->hasAttribute(key)) |
---|
270 | ERROR("CAttributeMap::fromBinary(StdIStream& is)", |
---|
271 | << "[ key = " << key << "] key not found !"); |
---|
272 | |
---|
273 | is.read (reinterpret_cast<char*>(&hasValue), sizeof(bool)); |
---|
274 | |
---|
275 | if (hasValue) |
---|
276 | this->operator[](key)->fromBinary(is); |
---|
277 | } |
---|
278 | } |
---|
279 | */ |
---|
280 | |
---|
281 | void CAttributeMap::generateCInterface(ostream& oss, const string& className) |
---|
282 | { |
---|
283 | SuperClassMap::const_iterator it = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
284 | for (; it != end; it++) |
---|
285 | { |
---|
286 | if (it->second->isPublic()) |
---|
287 | { |
---|
288 | oss << std::endl << iendl; |
---|
289 | it->second->generateCInterface(oss, className); |
---|
290 | oss << iendl; |
---|
291 | it->second->generateCInterfaceIsDefined(oss, className); |
---|
292 | } |
---|
293 | } |
---|
294 | } |
---|
295 | |
---|
296 | void CAttributeMap::generateFortran2003Interface(ostream& oss, const string& className) |
---|
297 | { |
---|
298 | SuperClassMap::const_iterator it = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
299 | for (; it != end; it++) |
---|
300 | { |
---|
301 | if (it->second->isPublic()) |
---|
302 | { |
---|
303 | oss << std::endl << iendl; |
---|
304 | it->second->generateFortran2003Interface(oss, className); |
---|
305 | oss << iendl; |
---|
306 | it->second->generateFortran2003InterfaceIsDefined(oss, className); |
---|
307 | } |
---|
308 | } |
---|
309 | } |
---|
310 | |
---|
311 | ///-------------------------------------------------------------- |
---|
312 | |
---|
313 | void CAttributeMap::generateFortranInterface_hdl_(ostream& oss, const string& className) |
---|
314 | { |
---|
315 | oss << "SUBROUTINE xios(set_" << className << "_attr_hdl_) &" << iendl++; |
---|
316 | SuperClassMap::const_iterator it; |
---|
317 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
318 | |
---|
319 | long startPos = oss.tellp(); |
---|
320 | |
---|
321 | oss << "( " << className << "_hdl"; |
---|
322 | for (it = begin; it != end; it++) |
---|
323 | { |
---|
324 | if (it->second->isPublic()) |
---|
325 | { |
---|
326 | oss << ", " << it->second->getName() << "_"; |
---|
327 | if (oss.tellp() - startPos > 90) |
---|
328 | { |
---|
329 | oss << " &" << iendl; |
---|
330 | startPos = oss.tellp(); |
---|
331 | } |
---|
332 | } |
---|
333 | } |
---|
334 | oss << " )"; |
---|
335 | oss << std::endl; |
---|
336 | oss << iendl; |
---|
337 | |
---|
338 | oss << "IMPLICIT NONE" << iendl++; |
---|
339 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
340 | |
---|
341 | for (it = begin; it != end; it++) |
---|
342 | { |
---|
343 | if (it->second->isPublic()) |
---|
344 | { |
---|
345 | oss << iendl; |
---|
346 | it->second->generateFortranInterfaceDeclaration_(oss, className); |
---|
347 | } |
---|
348 | } |
---|
349 | |
---|
350 | for (it = begin; it != end; it++) |
---|
351 | { |
---|
352 | if (it->second->isPublic()) |
---|
353 | { |
---|
354 | oss << std::endl << iendl; |
---|
355 | it->second->generateFortranInterfaceBody_(oss, className); |
---|
356 | } |
---|
357 | } |
---|
358 | |
---|
359 | oss << std::endl << (iendl -= 2); |
---|
360 | oss << "END SUBROUTINE xios(set_" << className << "_attr_hdl_)" << std::endl; |
---|
361 | } |
---|
362 | |
---|
363 | void CAttributeMap::generateFortranInterfaceGet_hdl_(ostream& oss, const string& className) |
---|
364 | { |
---|
365 | oss << "SUBROUTINE xios(get_" << className << "_attr_hdl_) &" << iendl++; |
---|
366 | SuperClassMap::const_iterator it; |
---|
367 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
368 | |
---|
369 | long startPos = oss.tellp(); |
---|
370 | |
---|
371 | oss << "( " << className << "_hdl"; |
---|
372 | for (it = begin; it != end; it++) |
---|
373 | { |
---|
374 | if (it->second->isPublic()) |
---|
375 | { |
---|
376 | oss << ", " << it->second->getName() << "_"; |
---|
377 | if (oss.tellp() - startPos > 90) |
---|
378 | { |
---|
379 | oss << " &" << iendl; |
---|
380 | startPos = oss.tellp(); |
---|
381 | } |
---|
382 | } |
---|
383 | } |
---|
384 | oss << " )"; |
---|
385 | oss << std::endl; |
---|
386 | oss << iendl; |
---|
387 | |
---|
388 | oss << "IMPLICIT NONE" << iendl++; |
---|
389 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
390 | |
---|
391 | for (it = begin; it != end; it++) |
---|
392 | { |
---|
393 | if (it->second->isPublic()) |
---|
394 | { |
---|
395 | oss << iendl; |
---|
396 | it->second->generateFortranInterfaceGetDeclaration_(oss, className); |
---|
397 | } |
---|
398 | } |
---|
399 | |
---|
400 | for (it = begin; it != end; it++) |
---|
401 | { |
---|
402 | if (it->second->isPublic()) |
---|
403 | { |
---|
404 | oss << std::endl << iendl; |
---|
405 | it->second->generateFortranInterfaceGetBody_(oss, className); |
---|
406 | } |
---|
407 | } |
---|
408 | |
---|
409 | oss << std::endl << (iendl -= 2); |
---|
410 | oss << "END SUBROUTINE xios(get_" << className << "_attr_hdl_)" << std::endl; |
---|
411 | } |
---|
412 | |
---|
413 | void CAttributeMap::generateFortranInterfaceIsDefined_hdl_(ostream& oss, const string& className) |
---|
414 | { |
---|
415 | oss << "SUBROUTINE xios(is_defined_" << className << "_attr_hdl_) &" << iendl++; |
---|
416 | SuperClassMap::const_iterator it; |
---|
417 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
418 | |
---|
419 | long startPos = oss.tellp(); |
---|
420 | |
---|
421 | oss << "( " << className << "_hdl"; |
---|
422 | for (it = begin; it != end; it++) |
---|
423 | { |
---|
424 | if (it->second->isPublic()) |
---|
425 | { |
---|
426 | oss << ", " << it->second->getName() << "_"; |
---|
427 | if (oss.tellp() - startPos > 90) |
---|
428 | { |
---|
429 | oss << " &" << iendl; |
---|
430 | startPos = oss.tellp(); |
---|
431 | } |
---|
432 | } |
---|
433 | } |
---|
434 | oss << " )"; |
---|
435 | oss << std::endl; |
---|
436 | oss << iendl; |
---|
437 | |
---|
438 | oss << "IMPLICIT NONE" << iendl++; |
---|
439 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
440 | |
---|
441 | for (it = begin; it != end; it++) |
---|
442 | { |
---|
443 | if (it->second->isPublic()) |
---|
444 | { |
---|
445 | oss << iendl; |
---|
446 | it->second->generateFortranInterfaceIsDefinedDeclaration_(oss, className); |
---|
447 | } |
---|
448 | } |
---|
449 | |
---|
450 | for (it = begin; it != end; it++) |
---|
451 | { |
---|
452 | if (it->second->isPublic()) |
---|
453 | { |
---|
454 | oss << std::endl << iendl; |
---|
455 | it->second->generateFortranInterfaceIsDefinedBody_(oss, className); |
---|
456 | } |
---|
457 | } |
---|
458 | |
---|
459 | oss << std::endl << (iendl -= 2); |
---|
460 | oss << "END SUBROUTINE xios(is_defined_" << className << "_attr_hdl_)" << std::endl; |
---|
461 | } |
---|
462 | |
---|
463 | void CAttributeMap::generateFortranInterface_hdl(ostream& oss, const string& className) |
---|
464 | { |
---|
465 | oss << "SUBROUTINE xios(set_" << className << "_attr_hdl) &" << iendl++; |
---|
466 | SuperClassMap::const_iterator it; |
---|
467 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
468 | |
---|
469 | long startPos = oss.tellp(); |
---|
470 | |
---|
471 | oss << "( " << className << "_hdl"; |
---|
472 | for (it = begin; it != end; it++) |
---|
473 | { |
---|
474 | if (it->second->isPublic()) |
---|
475 | { |
---|
476 | oss << ", " << it->second->getName(); |
---|
477 | if (oss.tellp() - startPos > 90) |
---|
478 | { |
---|
479 | oss << " &" << iendl; |
---|
480 | startPos = oss.tellp(); |
---|
481 | } |
---|
482 | } |
---|
483 | } |
---|
484 | oss << " )"; |
---|
485 | oss << std::endl; |
---|
486 | oss << iendl; |
---|
487 | |
---|
488 | oss << "IMPLICIT NONE" << iendl++; |
---|
489 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
490 | |
---|
491 | for (it = begin; it != end; it++) |
---|
492 | { |
---|
493 | if (it->second->isPublic()) |
---|
494 | { |
---|
495 | oss << iendl; |
---|
496 | it->second->generateFortranInterfaceDeclaration(oss, className); |
---|
497 | } |
---|
498 | } |
---|
499 | |
---|
500 | oss << std::endl << iendl; |
---|
501 | |
---|
502 | oss << "CALL xios(set_" << className << "_attr_hdl_) &" << iendl; |
---|
503 | |
---|
504 | startPos = oss.tellp(); |
---|
505 | |
---|
506 | oss << "( " << className << "_hdl"; |
---|
507 | for (it = begin; it != end; it++) |
---|
508 | { |
---|
509 | if (it->second->isPublic()) |
---|
510 | { |
---|
511 | oss << ", " << it->second->getName(); |
---|
512 | if (oss.tellp() - startPos > 90) |
---|
513 | { |
---|
514 | oss << " &" << iendl; |
---|
515 | startPos = oss.tellp(); |
---|
516 | } |
---|
517 | } |
---|
518 | } |
---|
519 | oss << " )"; |
---|
520 | |
---|
521 | oss << std::endl << (iendl -= 2); |
---|
522 | oss << "END SUBROUTINE xios(set_" << className << "_attr_hdl)" << std::endl; |
---|
523 | } |
---|
524 | |
---|
525 | void CAttributeMap::generateFortranInterfaceGet_hdl(ostream& oss, const string& className) |
---|
526 | { |
---|
527 | oss << "SUBROUTINE xios(get_" << className << "_attr_hdl) &" << iendl++; |
---|
528 | SuperClassMap::const_iterator it; |
---|
529 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
530 | |
---|
531 | long startPos = oss.tellp(); |
---|
532 | |
---|
533 | oss << "( " << className << "_hdl"; |
---|
534 | for (it = begin; it != end; it++) |
---|
535 | { |
---|
536 | if (it->second->isPublic()) |
---|
537 | { |
---|
538 | oss << ", " << it->second->getName(); |
---|
539 | if (oss.tellp() - startPos > 90) |
---|
540 | { |
---|
541 | oss << " &" << iendl; |
---|
542 | startPos = oss.tellp(); |
---|
543 | } |
---|
544 | } |
---|
545 | } |
---|
546 | oss << " )"; |
---|
547 | oss << std::endl; |
---|
548 | oss << iendl; |
---|
549 | |
---|
550 | oss << "IMPLICIT NONE" << iendl++; |
---|
551 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
552 | |
---|
553 | for (it = begin; it != end; it++) |
---|
554 | { |
---|
555 | if (it->second->isPublic()) |
---|
556 | { |
---|
557 | oss << iendl; |
---|
558 | it->second->generateFortranInterfaceGetDeclaration(oss, className); |
---|
559 | } |
---|
560 | } |
---|
561 | |
---|
562 | oss << std::endl << iendl; |
---|
563 | |
---|
564 | oss << "CALL xios(get_" << className << "_attr_hdl_) &" << iendl; |
---|
565 | |
---|
566 | startPos = oss.tellp(); |
---|
567 | |
---|
568 | oss << "( " << className << "_hdl"; |
---|
569 | for (it = begin; it != end; it++) |
---|
570 | { |
---|
571 | if (it->second->isPublic()) |
---|
572 | { |
---|
573 | oss << ", " << it->second->getName(); |
---|
574 | if (oss.tellp() - startPos > 90) |
---|
575 | { |
---|
576 | oss << " &" << iendl; |
---|
577 | startPos = oss.tellp(); |
---|
578 | } |
---|
579 | } |
---|
580 | } |
---|
581 | oss << " )"; |
---|
582 | |
---|
583 | oss << std::endl << (iendl -= 2); |
---|
584 | oss << "END SUBROUTINE xios(get_" << className << "_attr_hdl)" << std::endl; |
---|
585 | } |
---|
586 | |
---|
587 | void CAttributeMap::generateFortranInterfaceIsDefined_hdl(ostream& oss, const string& className) |
---|
588 | { |
---|
589 | oss << "SUBROUTINE xios(is_defined_" << className << "_attr_hdl) &" << iendl++; |
---|
590 | SuperClassMap::const_iterator it; |
---|
591 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
592 | |
---|
593 | long startPos = oss.tellp(); |
---|
594 | |
---|
595 | oss << "( " << className << "_hdl"; |
---|
596 | for (it = begin; it != end; it++) |
---|
597 | { |
---|
598 | if (it->second->isPublic()) |
---|
599 | { |
---|
600 | oss << ", " << it->second->getName(); |
---|
601 | if (oss.tellp() - startPos > 90) |
---|
602 | { |
---|
603 | oss << " &" << iendl; |
---|
604 | startPos = oss.tellp(); |
---|
605 | } |
---|
606 | } |
---|
607 | } |
---|
608 | oss << " )"; |
---|
609 | oss << std::endl; |
---|
610 | oss << iendl; |
---|
611 | |
---|
612 | oss << "IMPLICIT NONE" << iendl++; |
---|
613 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
614 | |
---|
615 | for (it = begin; it != end; it++) |
---|
616 | { |
---|
617 | if (it->second->isPublic()) |
---|
618 | { |
---|
619 | oss << iendl; |
---|
620 | it->second->generateFortranInterfaceIsDefinedDeclaration(oss, className); |
---|
621 | } |
---|
622 | } |
---|
623 | |
---|
624 | oss << std::endl << iendl; |
---|
625 | |
---|
626 | oss << "CALL xios(is_defined_" << className << "_attr_hdl_) &" << iendl; |
---|
627 | |
---|
628 | startPos = oss.tellp(); |
---|
629 | |
---|
630 | oss << "( " << className << "_hdl"; |
---|
631 | for (it = begin; it != end; it++) |
---|
632 | { |
---|
633 | if (it->second->isPublic()) |
---|
634 | { |
---|
635 | oss << ", " << it->second->getName(); |
---|
636 | if (oss.tellp() - startPos > 90) |
---|
637 | { |
---|
638 | oss << " &" << iendl; |
---|
639 | startPos = oss.tellp(); |
---|
640 | } |
---|
641 | } |
---|
642 | } |
---|
643 | oss << " )"; |
---|
644 | |
---|
645 | oss << std::endl << (iendl -= 2); |
---|
646 | oss << "END SUBROUTINE xios(is_defined_" << className << "_attr_hdl)" << std::endl; |
---|
647 | } |
---|
648 | |
---|
649 | void CAttributeMap::generateFortranInterface_id(ostream& oss, const string& className) |
---|
650 | { |
---|
651 | oss << "SUBROUTINE xios(set_" << className << "_attr) &" << iendl++; |
---|
652 | SuperClassMap::const_iterator it; |
---|
653 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
654 | |
---|
655 | long startPos = oss.tellp(); |
---|
656 | |
---|
657 | oss << "( " << className << "_id"; |
---|
658 | for (it = begin; it != end; it++) |
---|
659 | { |
---|
660 | if (it->second->isPublic()) |
---|
661 | { |
---|
662 | oss << ", " << it->second->getName(); |
---|
663 | if (oss.tellp() - startPos > 90) |
---|
664 | { |
---|
665 | oss << " &" << iendl; |
---|
666 | startPos = oss.tellp(); |
---|
667 | } |
---|
668 | } |
---|
669 | } |
---|
670 | oss << " )"; |
---|
671 | oss << std::endl; |
---|
672 | oss << iendl; |
---|
673 | |
---|
674 | oss << "IMPLICIT NONE" << iendl++; |
---|
675 | |
---|
676 | oss << "TYPE(txios(" << className << ")) :: " << className << "_hdl" << iendl; |
---|
677 | oss << "CHARACTER(LEN=*), INTENT(IN) ::" << className << "_id"; |
---|
678 | |
---|
679 | for (it = begin; it != end; it++) |
---|
680 | { |
---|
681 | if (it->second->isPublic()) |
---|
682 | { |
---|
683 | oss << iendl; |
---|
684 | it->second->generateFortranInterfaceDeclaration(oss, className); |
---|
685 | } |
---|
686 | } |
---|
687 | |
---|
688 | oss << std::endl << iendl; |
---|
689 | oss << "CALL xios(get_" << className << "_handle) &" << iendl; |
---|
690 | oss << "(" << className << "_id," << className << "_hdl)" << iendl; |
---|
691 | oss << "CALL xios(set_" << className << "_attr_hdl_) &" << iendl; |
---|
692 | |
---|
693 | startPos = oss.tellp(); |
---|
694 | |
---|
695 | oss << "( " << className << "_hdl"; |
---|
696 | for (it = begin; it != end; it++) |
---|
697 | { |
---|
698 | if (it->second->isPublic()) |
---|
699 | { |
---|
700 | oss << ", " << it->second->getName(); |
---|
701 | if (oss.tellp() - startPos > 90) |
---|
702 | { |
---|
703 | oss << " &" << iendl; |
---|
704 | startPos = oss.tellp(); |
---|
705 | } |
---|
706 | } |
---|
707 | } |
---|
708 | oss << " )"; |
---|
709 | |
---|
710 | oss << std::endl << (iendl -= 2); |
---|
711 | oss << "END SUBROUTINE xios(set_" << className << "_attr)" << std::endl; |
---|
712 | } |
---|
713 | |
---|
714 | void CAttributeMap::generateFortranInterfaceGet_id(ostream& oss, const string& className) |
---|
715 | { |
---|
716 | oss << "SUBROUTINE xios(get_" << className << "_attr) &" << iendl++; |
---|
717 | SuperClassMap::const_iterator it; |
---|
718 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
719 | |
---|
720 | long startPos = oss.tellp(); |
---|
721 | |
---|
722 | oss << "( " << className << "_id"; |
---|
723 | for (it = begin; it != end; it++) |
---|
724 | { |
---|
725 | if (it->second->isPublic()) |
---|
726 | { |
---|
727 | oss << ", " << it->second->getName(); |
---|
728 | if (oss.tellp() - startPos > 90) |
---|
729 | { |
---|
730 | oss << " &" << iendl; |
---|
731 | startPos = oss.tellp(); |
---|
732 | } |
---|
733 | } |
---|
734 | } |
---|
735 | oss << " )"; |
---|
736 | oss << std::endl; |
---|
737 | oss << iendl; |
---|
738 | |
---|
739 | oss << "IMPLICIT NONE" << iendl++; |
---|
740 | |
---|
741 | oss << "TYPE(txios(" << className << ")) :: " << className << "_hdl" << iendl; |
---|
742 | oss << "CHARACTER(LEN=*), INTENT(IN) ::" << className << "_id"; |
---|
743 | |
---|
744 | for (it = begin; it != end; it++) |
---|
745 | { |
---|
746 | if (it->second->isPublic()) |
---|
747 | { |
---|
748 | oss << iendl; |
---|
749 | it->second->generateFortranInterfaceGetDeclaration(oss, className); |
---|
750 | } |
---|
751 | } |
---|
752 | |
---|
753 | oss << std::endl << iendl; |
---|
754 | oss << "CALL xios(get_" << className << "_handle) &" << iendl; |
---|
755 | oss << "(" << className << "_id," << className << "_hdl)" << iendl; |
---|
756 | oss << "CALL xios(get_" << className << "_attr_hdl_) &" << iendl; |
---|
757 | |
---|
758 | startPos = oss.tellp(); |
---|
759 | |
---|
760 | oss << "( " << className << "_hdl"; |
---|
761 | for (it = begin; it != end; it++) |
---|
762 | { |
---|
763 | if (it->second->isPublic()) |
---|
764 | { |
---|
765 | oss << ", " << it->second->getName(); |
---|
766 | if (oss.tellp() - startPos > 90) |
---|
767 | { |
---|
768 | oss << " &" << iendl; |
---|
769 | startPos = oss.tellp(); |
---|
770 | } |
---|
771 | } |
---|
772 | } |
---|
773 | oss << " )"; |
---|
774 | |
---|
775 | oss << std::endl << (iendl -= 2); |
---|
776 | oss << "END SUBROUTINE xios(get_" << className << "_attr)" << std::endl; |
---|
777 | } |
---|
778 | |
---|
779 | void CAttributeMap::generateFortranInterfaceIsDefined_id(ostream& oss, const string& className) |
---|
780 | { |
---|
781 | oss << "SUBROUTINE xios(is_defined_" << className << "_attr) &" << iendl++; |
---|
782 | SuperClassMap::const_iterator it; |
---|
783 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
784 | |
---|
785 | long startPos = oss.tellp(); |
---|
786 | |
---|
787 | oss << "( " << className << "_id"; |
---|
788 | for (it = begin; it != end; it++) |
---|
789 | { |
---|
790 | if (it->second->isPublic()) |
---|
791 | { |
---|
792 | oss << ", " << it->second->getName(); |
---|
793 | if (oss.tellp() - startPos > 90) |
---|
794 | { |
---|
795 | oss << " &" << iendl; |
---|
796 | startPos = oss.tellp(); |
---|
797 | } |
---|
798 | } |
---|
799 | } |
---|
800 | oss << " )"; |
---|
801 | oss << std::endl; |
---|
802 | oss << iendl; |
---|
803 | |
---|
804 | oss << "IMPLICIT NONE" << iendl++; |
---|
805 | |
---|
806 | oss << "TYPE(txios(" << className << ")) :: " << className << "_hdl" << iendl; |
---|
807 | oss << "CHARACTER(LEN=*), INTENT(IN) ::" << className << "_id"; |
---|
808 | |
---|
809 | for (it = begin; it != end; it++) |
---|
810 | { |
---|
811 | if (it->second->isPublic()) |
---|
812 | { |
---|
813 | oss << iendl; |
---|
814 | it->second->generateFortranInterfaceIsDefinedDeclaration(oss, className); |
---|
815 | } |
---|
816 | } |
---|
817 | |
---|
818 | oss << std::endl << iendl; |
---|
819 | oss << "CALL xios(get_" << className << "_handle) &" << iendl; |
---|
820 | oss << "(" << className << "_id," << className << "_hdl)" << iendl; |
---|
821 | oss << "CALL xios(is_defined_" << className << "_attr_hdl_) &" << iendl; |
---|
822 | |
---|
823 | startPos = oss.tellp(); |
---|
824 | |
---|
825 | oss << "( " << className << "_hdl"; |
---|
826 | for (it = begin; it != end; it++) |
---|
827 | { |
---|
828 | if (it->second->isPublic()) |
---|
829 | { |
---|
830 | oss << ", " << it->second->getName(); |
---|
831 | if (oss.tellp() - startPos > 90) |
---|
832 | { |
---|
833 | oss << " &" << iendl; |
---|
834 | startPos = oss.tellp(); |
---|
835 | } |
---|
836 | } |
---|
837 | } |
---|
838 | oss << " )"; |
---|
839 | |
---|
840 | oss << std::endl << (iendl -= 2); |
---|
841 | oss << "END SUBROUTINE xios(is_defined_" << className << "_attr)" << std::endl; |
---|
842 | } |
---|
843 | } // namespace xios |
---|