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 | |
---|
282 | void CAttributeMap::generateCInterface(ostream& oss, const string& className) |
---|
283 | { |
---|
284 | SuperClassMap::const_iterator it = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
285 | for (; it != end; it++) |
---|
286 | { |
---|
287 | if (it->second->isPublic()) |
---|
288 | { |
---|
289 | oss << std::endl << iendl; |
---|
290 | it->second->generateCInterface(oss, className); |
---|
291 | oss << iendl; |
---|
292 | it->second->generateCInterfaceIsDefined(oss, className); |
---|
293 | } |
---|
294 | } |
---|
295 | } |
---|
296 | |
---|
297 | void CAttributeMap::generateFortran2003Interface(ostream& oss, const string& className) |
---|
298 | { |
---|
299 | SuperClassMap::const_iterator it = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
300 | for (; it != end; it++) |
---|
301 | { |
---|
302 | if (it->second->isPublic()) |
---|
303 | { |
---|
304 | oss << std::endl << iendl; |
---|
305 | it->second->generateFortran2003Interface(oss, className); |
---|
306 | oss << iendl; |
---|
307 | it->second->generateFortran2003InterfaceIsDefined(oss, className); |
---|
308 | } |
---|
309 | } |
---|
310 | } |
---|
311 | |
---|
312 | ///-------------------------------------------------------------- |
---|
313 | |
---|
314 | void CAttributeMap::generateFortranInterface_hdl_(ostream& oss, const string& className) |
---|
315 | { |
---|
316 | oss << "SUBROUTINE xios(set_" << className << "_attr_hdl_) &" << iendl++; |
---|
317 | SuperClassMap::const_iterator it; |
---|
318 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
319 | |
---|
320 | long startPos = oss.tellp(); |
---|
321 | |
---|
322 | oss << "( " << className << "_hdl"; |
---|
323 | for (it = begin; it != end; it++) |
---|
324 | { |
---|
325 | if (it->second->isPublic()) |
---|
326 | { |
---|
327 | oss << ", " << it->second->getName() << "_"; |
---|
328 | if (oss.tellp() - startPos > 90) |
---|
329 | { |
---|
330 | oss << " &" << iendl; |
---|
331 | startPos = oss.tellp(); |
---|
332 | } |
---|
333 | } |
---|
334 | } |
---|
335 | oss << " )"; |
---|
336 | oss << std::endl; |
---|
337 | oss << iendl; |
---|
338 | |
---|
339 | oss << "IMPLICIT NONE" << iendl++; |
---|
340 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
341 | |
---|
342 | for (it = begin; it != end; it++) |
---|
343 | { |
---|
344 | if (it->second->isPublic()) |
---|
345 | { |
---|
346 | oss << iendl; |
---|
347 | it->second->generateFortranInterfaceDeclaration_(oss, className); |
---|
348 | } |
---|
349 | } |
---|
350 | |
---|
351 | for (it = begin; it != end; it++) |
---|
352 | { |
---|
353 | if (it->second->isPublic()) |
---|
354 | { |
---|
355 | oss << std::endl << iendl; |
---|
356 | it->second->generateFortranInterfaceBody_(oss, className); |
---|
357 | } |
---|
358 | } |
---|
359 | |
---|
360 | oss << std::endl << (iendl -= 2); |
---|
361 | oss << "END SUBROUTINE xios(set_" << className << "_attr_hdl_)" << std::endl; |
---|
362 | } |
---|
363 | |
---|
364 | void CAttributeMap::generateFortranInterfaceGet_hdl_(ostream& oss, const string& className) |
---|
365 | { |
---|
366 | oss << "SUBROUTINE xios(get_" << className << "_attr_hdl_) &" << iendl++; |
---|
367 | SuperClassMap::const_iterator it; |
---|
368 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
369 | |
---|
370 | long startPos = oss.tellp(); |
---|
371 | |
---|
372 | oss << "( " << className << "_hdl"; |
---|
373 | for (it = begin; it != end; it++) |
---|
374 | { |
---|
375 | if (it->second->isPublic()) |
---|
376 | { |
---|
377 | oss << ", " << it->second->getName() << "_"; |
---|
378 | if (oss.tellp() - startPos > 90) |
---|
379 | { |
---|
380 | oss << " &" << iendl; |
---|
381 | startPos = oss.tellp(); |
---|
382 | } |
---|
383 | } |
---|
384 | } |
---|
385 | oss << " )"; |
---|
386 | oss << std::endl; |
---|
387 | oss << iendl; |
---|
388 | |
---|
389 | oss << "IMPLICIT NONE" << iendl++; |
---|
390 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
391 | |
---|
392 | for (it = begin; it != end; it++) |
---|
393 | { |
---|
394 | if (it->second->isPublic()) |
---|
395 | { |
---|
396 | oss << iendl; |
---|
397 | it->second->generateFortranInterfaceGetDeclaration_(oss, className); |
---|
398 | } |
---|
399 | } |
---|
400 | |
---|
401 | for (it = begin; it != end; it++) |
---|
402 | { |
---|
403 | if (it->second->isPublic()) |
---|
404 | { |
---|
405 | oss << std::endl << iendl; |
---|
406 | it->second->generateFortranInterfaceGetBody_(oss, className); |
---|
407 | } |
---|
408 | } |
---|
409 | |
---|
410 | oss << std::endl << (iendl -= 2); |
---|
411 | oss << "END SUBROUTINE xios(get_" << className << "_attr_hdl_)" << std::endl; |
---|
412 | } |
---|
413 | |
---|
414 | void CAttributeMap::generateFortranInterfaceIsDefined_hdl_(ostream& oss, const string& className) |
---|
415 | { |
---|
416 | oss << "SUBROUTINE xios(is_defined_" << className << "_attr_hdl_) &" << iendl++; |
---|
417 | SuperClassMap::const_iterator it; |
---|
418 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
419 | |
---|
420 | long startPos = oss.tellp(); |
---|
421 | |
---|
422 | oss << "( " << className << "_hdl"; |
---|
423 | for (it = begin; it != end; it++) |
---|
424 | { |
---|
425 | if (it->second->isPublic()) |
---|
426 | { |
---|
427 | oss << ", " << it->second->getName() << "_"; |
---|
428 | if (oss.tellp() - startPos > 90) |
---|
429 | { |
---|
430 | oss << " &" << iendl; |
---|
431 | startPos = oss.tellp(); |
---|
432 | } |
---|
433 | } |
---|
434 | } |
---|
435 | oss << " )"; |
---|
436 | oss << std::endl; |
---|
437 | oss << iendl; |
---|
438 | |
---|
439 | oss << "IMPLICIT NONE" << iendl++; |
---|
440 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
441 | |
---|
442 | for (it = begin; it != end; it++) |
---|
443 | { |
---|
444 | if (it->second->isPublic()) |
---|
445 | { |
---|
446 | oss << iendl; |
---|
447 | it->second->generateFortranInterfaceIsDefinedDeclaration_(oss, className); |
---|
448 | } |
---|
449 | } |
---|
450 | |
---|
451 | for (it = begin; it != end; it++) |
---|
452 | { |
---|
453 | if (it->second->isPublic()) |
---|
454 | { |
---|
455 | oss << std::endl << iendl; |
---|
456 | it->second->generateFortranInterfaceIsDefinedBody_(oss, className); |
---|
457 | } |
---|
458 | } |
---|
459 | |
---|
460 | oss << std::endl << (iendl -= 2); |
---|
461 | oss << "END SUBROUTINE xios(is_defined_" << className << "_attr_hdl_)" << std::endl; |
---|
462 | } |
---|
463 | |
---|
464 | void CAttributeMap::generateFortranInterface_hdl(ostream& oss, const string& className) |
---|
465 | { |
---|
466 | oss << "SUBROUTINE xios(set_" << className << "_attr_hdl) &" << iendl++; |
---|
467 | SuperClassMap::const_iterator it; |
---|
468 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
469 | |
---|
470 | long startPos = oss.tellp(); |
---|
471 | |
---|
472 | oss << "( " << className << "_hdl"; |
---|
473 | for (it = begin; it != end; it++) |
---|
474 | { |
---|
475 | if (it->second->isPublic()) |
---|
476 | { |
---|
477 | oss << ", " << it->second->getName(); |
---|
478 | if (oss.tellp() - startPos > 90) |
---|
479 | { |
---|
480 | oss << " &" << iendl; |
---|
481 | startPos = oss.tellp(); |
---|
482 | } |
---|
483 | } |
---|
484 | } |
---|
485 | oss << " )"; |
---|
486 | oss << std::endl; |
---|
487 | oss << iendl; |
---|
488 | |
---|
489 | oss << "IMPLICIT NONE" << iendl++; |
---|
490 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
491 | |
---|
492 | for (it = begin; it != end; it++) |
---|
493 | { |
---|
494 | if (it->second->isPublic()) |
---|
495 | { |
---|
496 | oss << iendl; |
---|
497 | it->second->generateFortranInterfaceDeclaration(oss, className); |
---|
498 | } |
---|
499 | } |
---|
500 | |
---|
501 | oss << std::endl << iendl; |
---|
502 | |
---|
503 | oss << "CALL xios(set_" << className << "_attr_hdl_) &" << iendl; |
---|
504 | |
---|
505 | startPos = oss.tellp(); |
---|
506 | |
---|
507 | oss << "( " << className << "_hdl"; |
---|
508 | for (it = begin; it != end; it++) |
---|
509 | { |
---|
510 | if (it->second->isPublic()) |
---|
511 | { |
---|
512 | oss << ", " << it->second->getName(); |
---|
513 | if (oss.tellp() - startPos > 90) |
---|
514 | { |
---|
515 | oss << " &" << iendl; |
---|
516 | startPos = oss.tellp(); |
---|
517 | } |
---|
518 | } |
---|
519 | } |
---|
520 | oss << " )"; |
---|
521 | |
---|
522 | oss << std::endl << (iendl -= 2); |
---|
523 | oss << "END SUBROUTINE xios(set_" << className << "_attr_hdl)" << std::endl; |
---|
524 | } |
---|
525 | |
---|
526 | void CAttributeMap::generateFortranInterfaceGet_hdl(ostream& oss, const string& className) |
---|
527 | { |
---|
528 | oss << "SUBROUTINE xios(get_" << className << "_attr_hdl) &" << iendl++; |
---|
529 | SuperClassMap::const_iterator it; |
---|
530 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
531 | |
---|
532 | long startPos = oss.tellp(); |
---|
533 | |
---|
534 | oss << "( " << className << "_hdl"; |
---|
535 | for (it = begin; it != end; it++) |
---|
536 | { |
---|
537 | if (it->second->isPublic()) |
---|
538 | { |
---|
539 | oss << ", " << it->second->getName(); |
---|
540 | if (oss.tellp() - startPos > 90) |
---|
541 | { |
---|
542 | oss << " &" << iendl; |
---|
543 | startPos = oss.tellp(); |
---|
544 | } |
---|
545 | } |
---|
546 | } |
---|
547 | oss << " )"; |
---|
548 | oss << std::endl; |
---|
549 | oss << iendl; |
---|
550 | |
---|
551 | oss << "IMPLICIT NONE" << iendl++; |
---|
552 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
553 | |
---|
554 | for (it = begin; it != end; it++) |
---|
555 | { |
---|
556 | if (it->second->isPublic()) |
---|
557 | { |
---|
558 | oss << iendl; |
---|
559 | it->second->generateFortranInterfaceGetDeclaration(oss, className); |
---|
560 | } |
---|
561 | } |
---|
562 | |
---|
563 | oss << std::endl << iendl; |
---|
564 | |
---|
565 | oss << "CALL xios(get_" << className << "_attr_hdl_) &" << iendl; |
---|
566 | |
---|
567 | startPos = oss.tellp(); |
---|
568 | |
---|
569 | oss << "( " << className << "_hdl"; |
---|
570 | for (it = begin; it != end; it++) |
---|
571 | { |
---|
572 | if (it->second->isPublic()) |
---|
573 | { |
---|
574 | oss << ", " << it->second->getName(); |
---|
575 | if (oss.tellp() - startPos > 90) |
---|
576 | { |
---|
577 | oss << " &" << iendl; |
---|
578 | startPos = oss.tellp(); |
---|
579 | } |
---|
580 | } |
---|
581 | } |
---|
582 | oss << " )"; |
---|
583 | |
---|
584 | oss << std::endl << (iendl -= 2); |
---|
585 | oss << "END SUBROUTINE xios(get_" << className << "_attr_hdl)" << std::endl; |
---|
586 | } |
---|
587 | |
---|
588 | void CAttributeMap::generateFortranInterfaceIsDefined_hdl(ostream& oss, const string& className) |
---|
589 | { |
---|
590 | oss << "SUBROUTINE xios(is_defined_" << className << "_attr_hdl) &" << iendl++; |
---|
591 | SuperClassMap::const_iterator it; |
---|
592 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
593 | |
---|
594 | long startPos = oss.tellp(); |
---|
595 | |
---|
596 | oss << "( " << className << "_hdl"; |
---|
597 | for (it = begin; it != end; it++) |
---|
598 | { |
---|
599 | if (it->second->isPublic()) |
---|
600 | { |
---|
601 | oss << ", " << it->second->getName(); |
---|
602 | if (oss.tellp() - startPos > 90) |
---|
603 | { |
---|
604 | oss << " &" << iendl; |
---|
605 | startPos = oss.tellp(); |
---|
606 | } |
---|
607 | } |
---|
608 | } |
---|
609 | oss << " )"; |
---|
610 | oss << std::endl; |
---|
611 | oss << iendl; |
---|
612 | |
---|
613 | oss << "IMPLICIT NONE" << iendl++; |
---|
614 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
615 | |
---|
616 | for (it = begin; it != end; it++) |
---|
617 | { |
---|
618 | if (it->second->isPublic()) |
---|
619 | { |
---|
620 | oss << iendl; |
---|
621 | it->second->generateFortranInterfaceIsDefinedDeclaration(oss, className); |
---|
622 | } |
---|
623 | } |
---|
624 | |
---|
625 | oss << std::endl << iendl; |
---|
626 | |
---|
627 | oss << "CALL xios(is_defined_" << className << "_attr_hdl_) &" << iendl; |
---|
628 | |
---|
629 | startPos = oss.tellp(); |
---|
630 | |
---|
631 | oss << "( " << className << "_hdl"; |
---|
632 | for (it = begin; it != end; it++) |
---|
633 | { |
---|
634 | if (it->second->isPublic()) |
---|
635 | { |
---|
636 | oss << ", " << it->second->getName(); |
---|
637 | if (oss.tellp() - startPos > 90) |
---|
638 | { |
---|
639 | oss << " &" << iendl; |
---|
640 | startPos = oss.tellp(); |
---|
641 | } |
---|
642 | } |
---|
643 | } |
---|
644 | oss << " )"; |
---|
645 | |
---|
646 | oss << std::endl << (iendl -= 2); |
---|
647 | oss << "END SUBROUTINE xios(is_defined_" << className << "_attr_hdl)" << std::endl; |
---|
648 | } |
---|
649 | |
---|
650 | void CAttributeMap::generateFortranInterface_id(ostream& oss, const string& className) |
---|
651 | { |
---|
652 | oss << "SUBROUTINE xios(set_" << className << "_attr) &" << iendl++; |
---|
653 | SuperClassMap::const_iterator it; |
---|
654 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
655 | |
---|
656 | long startPos = oss.tellp(); |
---|
657 | |
---|
658 | oss << "( " << className << "_id"; |
---|
659 | for (it = begin; it != end; it++) |
---|
660 | { |
---|
661 | if (it->second->isPublic()) |
---|
662 | { |
---|
663 | oss << ", " << it->second->getName(); |
---|
664 | if (oss.tellp() - startPos > 90) |
---|
665 | { |
---|
666 | oss << " &" << iendl; |
---|
667 | startPos = oss.tellp(); |
---|
668 | } |
---|
669 | } |
---|
670 | } |
---|
671 | oss << " )"; |
---|
672 | oss << std::endl; |
---|
673 | oss << iendl; |
---|
674 | |
---|
675 | oss << "IMPLICIT NONE" << iendl++; |
---|
676 | |
---|
677 | oss << "TYPE(txios(" << className << ")) :: " << className << "_hdl" << iendl; |
---|
678 | oss << "CHARACTER(LEN=*), INTENT(IN) ::" << className << "_id"; |
---|
679 | |
---|
680 | for (it = begin; it != end; it++) |
---|
681 | { |
---|
682 | if (it->second->isPublic()) |
---|
683 | { |
---|
684 | oss << iendl; |
---|
685 | it->second->generateFortranInterfaceDeclaration(oss, className); |
---|
686 | } |
---|
687 | } |
---|
688 | |
---|
689 | oss << std::endl << iendl; |
---|
690 | oss << "CALL xios(get_" << className << "_handle) &" << iendl; |
---|
691 | oss << "(" << className << "_id," << className << "_hdl)" << iendl; |
---|
692 | oss << "CALL xios(set_" << className << "_attr_hdl_) &" << iendl; |
---|
693 | |
---|
694 | startPos = oss.tellp(); |
---|
695 | |
---|
696 | oss << "( " << className << "_hdl"; |
---|
697 | for (it = begin; it != end; it++) |
---|
698 | { |
---|
699 | if (it->second->isPublic()) |
---|
700 | { |
---|
701 | oss << ", " << it->second->getName(); |
---|
702 | if (oss.tellp() - startPos > 90) |
---|
703 | { |
---|
704 | oss << " &" << iendl; |
---|
705 | startPos = oss.tellp(); |
---|
706 | } |
---|
707 | } |
---|
708 | } |
---|
709 | oss << " )"; |
---|
710 | |
---|
711 | oss << std::endl << (iendl -= 2); |
---|
712 | oss << "END SUBROUTINE xios(set_" << className << "_attr)" << std::endl; |
---|
713 | } |
---|
714 | |
---|
715 | void CAttributeMap::generateFortranInterfaceGet_id(ostream& oss, const string& className) |
---|
716 | { |
---|
717 | oss << "SUBROUTINE xios(get_" << className << "_attr) &" << iendl++; |
---|
718 | SuperClassMap::const_iterator it; |
---|
719 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
720 | |
---|
721 | long startPos = oss.tellp(); |
---|
722 | |
---|
723 | oss << "( " << className << "_id"; |
---|
724 | for (it = begin; it != end; it++) |
---|
725 | { |
---|
726 | if (it->second->isPublic()) |
---|
727 | { |
---|
728 | oss << ", " << it->second->getName(); |
---|
729 | if (oss.tellp() - startPos > 90) |
---|
730 | { |
---|
731 | oss << " &" << iendl; |
---|
732 | startPos = oss.tellp(); |
---|
733 | } |
---|
734 | } |
---|
735 | } |
---|
736 | oss << " )"; |
---|
737 | oss << std::endl; |
---|
738 | oss << iendl; |
---|
739 | |
---|
740 | oss << "IMPLICIT NONE" << iendl++; |
---|
741 | |
---|
742 | oss << "TYPE(txios(" << className << ")) :: " << className << "_hdl" << iendl; |
---|
743 | oss << "CHARACTER(LEN=*), INTENT(IN) ::" << className << "_id"; |
---|
744 | |
---|
745 | for (it = begin; it != end; it++) |
---|
746 | { |
---|
747 | if (it->second->isPublic()) |
---|
748 | { |
---|
749 | oss << iendl; |
---|
750 | it->second->generateFortranInterfaceGetDeclaration(oss, className); |
---|
751 | } |
---|
752 | } |
---|
753 | |
---|
754 | oss << std::endl << iendl; |
---|
755 | oss << "CALL xios(get_" << className << "_handle) &" << iendl; |
---|
756 | oss << "(" << className << "_id," << className << "_hdl)" << iendl; |
---|
757 | oss << "CALL xios(get_" << className << "_attr_hdl_) &" << iendl; |
---|
758 | |
---|
759 | startPos = oss.tellp(); |
---|
760 | |
---|
761 | oss << "( " << className << "_hdl"; |
---|
762 | for (it = begin; it != end; it++) |
---|
763 | { |
---|
764 | if (it->second->isPublic()) |
---|
765 | { |
---|
766 | oss << ", " << it->second->getName(); |
---|
767 | if (oss.tellp() - startPos > 90) |
---|
768 | { |
---|
769 | oss << " &" << iendl; |
---|
770 | startPos = oss.tellp(); |
---|
771 | } |
---|
772 | } |
---|
773 | } |
---|
774 | oss << " )"; |
---|
775 | |
---|
776 | oss << std::endl << (iendl -= 2); |
---|
777 | oss << "END SUBROUTINE xios(get_" << className << "_attr)" << std::endl; |
---|
778 | } |
---|
779 | |
---|
780 | void CAttributeMap::generateFortranInterfaceIsDefined_id(ostream& oss, const string& className) |
---|
781 | { |
---|
782 | oss << "SUBROUTINE xios(is_defined_" << className << "_attr) &" << iendl++; |
---|
783 | SuperClassMap::const_iterator it; |
---|
784 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
785 | |
---|
786 | long startPos = oss.tellp(); |
---|
787 | |
---|
788 | oss << "( " << className << "_id"; |
---|
789 | for (it = begin; it != end; it++) |
---|
790 | { |
---|
791 | if (it->second->isPublic()) |
---|
792 | { |
---|
793 | oss << ", " << it->second->getName(); |
---|
794 | if (oss.tellp() - startPos > 90) |
---|
795 | { |
---|
796 | oss << " &" << iendl; |
---|
797 | startPos = oss.tellp(); |
---|
798 | } |
---|
799 | } |
---|
800 | } |
---|
801 | oss << " )"; |
---|
802 | oss << std::endl; |
---|
803 | oss << iendl; |
---|
804 | |
---|
805 | oss << "IMPLICIT NONE" << iendl++; |
---|
806 | |
---|
807 | oss << "TYPE(txios(" << className << ")) :: " << className << "_hdl" << iendl; |
---|
808 | oss << "CHARACTER(LEN=*), INTENT(IN) ::" << className << "_id"; |
---|
809 | |
---|
810 | for (it = begin; it != end; it++) |
---|
811 | { |
---|
812 | if (it->second->isPublic()) |
---|
813 | { |
---|
814 | oss << iendl; |
---|
815 | it->second->generateFortranInterfaceIsDefinedDeclaration(oss, className); |
---|
816 | } |
---|
817 | } |
---|
818 | |
---|
819 | oss << std::endl << iendl; |
---|
820 | oss << "CALL xios(get_" << className << "_handle) &" << iendl; |
---|
821 | oss << "(" << className << "_id," << className << "_hdl)" << iendl; |
---|
822 | oss << "CALL xios(is_defined_" << className << "_attr_hdl_) &" << iendl; |
---|
823 | |
---|
824 | startPos = oss.tellp(); |
---|
825 | |
---|
826 | oss << "( " << className << "_hdl"; |
---|
827 | for (it = begin; it != end; it++) |
---|
828 | { |
---|
829 | if (it->second->isPublic()) |
---|
830 | { |
---|
831 | oss << ", " << it->second->getName(); |
---|
832 | if (oss.tellp() - startPos > 90) |
---|
833 | { |
---|
834 | oss << " &" << iendl; |
---|
835 | startPos = oss.tellp(); |
---|
836 | } |
---|
837 | } |
---|
838 | } |
---|
839 | oss << " )"; |
---|
840 | |
---|
841 | oss << std::endl << (iendl -= 2); |
---|
842 | oss << "END SUBROUTINE xios(is_defined_" << className << "_attr)" << std::endl; |
---|
843 | } |
---|
844 | } // namespace xios |
---|