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