source: XIOS/trunk/src/attribute_map.cpp @ 1105

Last change on this file since 1105 was 1105, checked in by mhnguyen, 7 years ago

Adding comparison operator between objects of XIOS.
Two objects of a same type are considered equal if they have same non-empty
attributes which have same values

+) Add operator== to class CArray
+) Add comparison operator to some basic attribute classes
+) Add operator== to date and duration (It seems that they don't serve much)

Test
+) On Curie
+) No Unit tests but test with transformation work (the next commit)

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
File size: 26.6 KB
Line 
1#include "attribute_map.hpp"
2#include "indent.hpp"
3
4namespace 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         \return true if these two maps have same attributes whose value are identical
125      */
126      bool CAttributeMap::isEqual(const CAttributeMap& another)
127      {
128         SuperClassMap::const_iterator itb = another.begin(), ite = another.end(), it;
129         for (it = itb; it !=ite; ++it)
130         {
131            if ((*it).first.compare(StdString("id")) != 0 && (*it).first.compare(StdString("src")) != 0)
132            {
133              if (this->hasAttribute(it->first))
134              { 
135                if (!((*it).second->isEqual(*(*this)[it->first])))
136                return false;
137              }
138              else
139                return false;
140            }
141         }
142
143         return true;
144      }
145
146
147      //---------------------------------------------------------------
148
149      /*!
150      \brief Set attributes from a specific attributemap, considered parent.
151         The child attribute map will insert the attributes of its parent into its current attribute map.
152      The existing attributes can be filled with the values of the parent map if they are empty or
153      simply replaced by these values depending on choice of user.
154      \param [in] _parent Attribute map from which the current map gets attributes.
155      \param [in] apply Specify if current attribute map is replaced by the attributes of parent (false)
156                    or filled in in case of emptyp (true)
157      */
158      void CAttributeMap::setAttributes(const CAttributeMap* const _parent, bool apply)
159      {
160         typedef std::pair<StdString, CAttribute*> StdStrAttPair;
161
162         SuperClassMap::const_iterator it = _parent->begin(), end = _parent->end();
163         for (; it != end; it++)
164         {
165            const StdStrAttPair& el = *it;
166            if (this->hasAttribute(el.first))
167            {
168               CAttribute* currentAtt = CAttributeMap::operator[](el.first);
169               CAttribute* parentAtt = el.second;
170               if (apply)
171               {
172                 if (currentAtt->isEmpty() && !el.second->isEmpty())
173                 {
174                    this->setAttribute(el.first, el.second);
175                 }
176               }
177               else currentAtt->setInheritedValue(*parentAtt);
178            }
179         }
180      }
181
182      /*!
183        Duplicate attribute map with a specific attribute map.
184        Copy all non-empty attribute of the current attribute map
185        \param [in] srcAttr attribute map which is copied from.
186      */
187      void CAttributeMap::duplicateAttributes(const CAttributeMap* const srcAttr)
188      {
189         typedef std::pair<StdString, CAttribute*> StdStrAttPair;
190
191         SuperClassMap::const_iterator it = srcAttr->begin(), end = srcAttr->end();
192         for (; it != end; it++)
193         {
194            const StdStrAttPair& el = *it;
195            if (this->hasAttribute(el.first))
196            {
197               if (!el.second->isEmpty())
198               {
199                 this->setAttribute(el.first, el.second);
200               }
201            }
202         }
203      }
204
205      //---------------------------------------------------------------
206/*
207      void CAttributeMap::toBinary(StdOStream& os) const
208      {
209         typedef std::pair<StdString, CAttribute*> StdStrAttPair;
210         SuperClassMap::const_iterator it = this->begin(), end = this->end();
211
212         const StdSize nbatt = SuperClassMap::size();
213         os.write (reinterpret_cast<const char*>(&nbatt) , sizeof(StdSize));
214
215         for (; it != end; it++)
216         {
217            const StdString& key   = it->first;
218            const CAttribute* value = it->second;
219            const StdSize size = key.size();
220
221            os.write (reinterpret_cast<const char*>(&size) , sizeof(StdSize));
222            os.write (key.data(), size* sizeof(char));
223
224            if (!value->isEmpty())
225            {
226               bool b = true;
227               os.write (reinterpret_cast<const char*>(&b) , sizeof(bool));
228               value->toBinary(os);
229            }
230            else
231            {
232               bool b = false;
233               os.write (reinterpret_cast<const char*>(&b) , sizeof(bool));
234            }
235         }
236      }
237
238      //---------------------------------------------------------------
239
240      void CAttributeMap::fromBinary(StdIStream& is)
241      {
242         StdSize nbatt = 0;
243         is.read (reinterpret_cast<char*>(&nbatt), sizeof(StdSize));
244
245         for (StdSize i = 0; i < nbatt; i++)
246         {
247            bool hasValue = false;
248            StdSize size  = 0;
249            is.read (reinterpret_cast<char*>(&size), sizeof(StdSize));
250            StdString key(size, ' ');
251            is.read (const_cast<char *>(key.data()), size* sizeof(char));
252
253            if (!this->hasAttribute(key))
254               ERROR("CAttributeMap::fromBinary(StdIStream& is)",
255                     << "[ key = " << key << "] key not found !");
256
257            is.read (reinterpret_cast<char*>(&hasValue), sizeof(bool));
258
259            if (hasValue)
260               this->operator[](key)->fromBinary(is);
261         }
262      }
263 */
264
265     
266      void CAttributeMap::generateCInterface(ostream& oss, const string& className)
267      {
268         SuperClassMap::const_iterator it = SuperClassMap::begin(), end = SuperClassMap::end();
269         for (; it != end; it++)
270         {
271           if (it->second->isPublic())
272           {
273             oss << std::endl << iendl;
274             it->second->generateCInterface(oss, className);
275             oss << iendl;
276             it->second->generateCInterfaceIsDefined(oss, className);
277           }
278         }
279      }
280
281      void CAttributeMap::generateFortran2003Interface(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->generateFortran2003Interface(oss, className);
290             oss << iendl;
291             it->second->generateFortran2003InterfaceIsDefined(oss, className);
292           }
293         }
294      }
295
296      ///--------------------------------------------------------------
297
298      void CAttributeMap::generateFortranInterface_hdl_(ostream& oss, const string& className)
299      {
300         oss << "SUBROUTINE xios(set_" << className << "_attr_hdl_)   &" << iendl++;
301         SuperClassMap::const_iterator it;
302         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
303
304         long startPos = oss.tellp();
305
306         oss << "( " << className << "_hdl";
307         for (it = begin; it != end; it++)
308         {
309           if (it->second->isPublic())
310           {
311             oss << ", " << it->second->getName() << "_";
312             if (oss.tellp() - startPos > 90)
313             {
314               oss << "  &" << iendl;
315               startPos = oss.tellp();
316             }
317           }
318         }
319         oss << " )";
320         oss << std::endl;
321         oss << iendl;
322
323         oss << "IMPLICIT NONE" << iendl++;
324         oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl";
325
326         for (it = begin; it != end; it++)
327         {
328           if (it->second->isPublic())
329           {
330             oss << iendl;
331             it->second->generateFortranInterfaceDeclaration_(oss, className);
332           }
333         }
334
335         for (it = begin; it != end; it++)
336         {
337           if (it->second->isPublic())
338           {
339             oss << std::endl << iendl;
340             it->second->generateFortranInterfaceBody_(oss, className);
341           }
342         }
343
344         oss << std::endl << (iendl -= 2);
345         oss << "END SUBROUTINE xios(set_" << className << "_attr_hdl_)" << std::endl;
346      }
347
348      void CAttributeMap::generateFortranInterfaceGet_hdl_(ostream& oss, const string& className)
349      {
350         oss << "SUBROUTINE xios(get_" << className << "_attr_hdl_)   &" << iendl++;
351         SuperClassMap::const_iterator it;
352         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
353
354         long startPos = oss.tellp();
355
356         oss << "( " << className << "_hdl";
357         for (it = begin; it != end; it++)
358         {
359           if (it->second->isPublic())
360           {
361             oss << ", " << it->second->getName() << "_";
362             if (oss.tellp() - startPos > 90)
363             {
364               oss << "  &" << iendl;
365               startPos = oss.tellp();
366             }
367           }
368         }
369         oss << " )";
370         oss << std::endl;
371         oss << iendl;
372
373         oss << "IMPLICIT NONE" << iendl++;
374         oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl";
375
376         for (it = begin; it != end; it++)
377         {
378           if (it->second->isPublic())
379           {
380             oss << iendl;
381             it->second->generateFortranInterfaceGetDeclaration_(oss, className);
382           }
383         }
384
385         for (it = begin; it != end; it++)
386         {
387           if (it->second->isPublic())
388           {
389             oss << std::endl << iendl;
390             it->second->generateFortranInterfaceGetBody_(oss, className);
391           }
392         }
393
394         oss << std::endl << (iendl -= 2);
395         oss << "END SUBROUTINE xios(get_" << className << "_attr_hdl_)" << std::endl;
396      }
397
398      void CAttributeMap::generateFortranInterfaceIsDefined_hdl_(ostream& oss, const string& className)
399      {
400         oss << "SUBROUTINE xios(is_defined_" << className << "_attr_hdl_)   &" << iendl++;
401         SuperClassMap::const_iterator it;
402         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
403
404         long startPos = oss.tellp();
405
406         oss << "( " << className << "_hdl";
407         for (it = begin; it != end; it++)
408         {
409           if (it->second->isPublic())
410           {
411             oss << ", " << it->second->getName() << "_";
412             if (oss.tellp() - startPos > 90)
413             {
414               oss << "  &" << iendl;
415               startPos = oss.tellp();
416             }
417           }
418         }
419         oss << " )";
420         oss << std::endl;
421         oss << iendl;
422
423         oss << "IMPLICIT NONE" << iendl++;
424         oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl";
425
426         for (it = begin; it != end; it++)
427         {
428           if (it->second->isPublic())
429           {
430             oss << iendl;
431             it->second->generateFortranInterfaceIsDefinedDeclaration_(oss, className);
432           }
433         }
434
435         for (it = begin; it != end; it++)
436         {
437           if (it->second->isPublic())
438           {
439             oss << std::endl << iendl;
440             it->second->generateFortranInterfaceIsDefinedBody_(oss, className);
441           }
442         }
443
444         oss << std::endl << (iendl -= 2);
445         oss << "END SUBROUTINE xios(is_defined_" << className << "_attr_hdl_)" << std::endl;
446      }
447
448      void CAttributeMap::generateFortranInterface_hdl(ostream& oss, const string& className)
449      {
450         oss << "SUBROUTINE xios(set_" << className << "_attr_hdl)  &" << iendl++;
451         SuperClassMap::const_iterator it;
452         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
453
454         long startPos = oss.tellp();
455
456         oss << "( " << className << "_hdl";
457         for (it = begin; it != end; it++)
458         {
459           if (it->second->isPublic())
460           {
461             oss << ", " << it->second->getName();
462             if (oss.tellp() - startPos > 90)
463             {
464               oss << "  &" << iendl;
465               startPos = oss.tellp();
466             }
467           }
468         }
469         oss << " )";
470         oss << std::endl;
471         oss << iendl;
472
473         oss << "IMPLICIT NONE" << iendl++;
474         oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl";
475
476         for (it = begin; it != end; it++)
477         {
478           if (it->second->isPublic())
479           {
480             oss << iendl;
481             it->second->generateFortranInterfaceDeclaration(oss, className);
482           }
483         }
484
485         oss << std::endl << iendl;
486
487         oss << "CALL xios(set_" << className << "_attr_hdl_)  &" << iendl;
488
489         startPos = oss.tellp();
490
491         oss << "( " << className << "_hdl";
492         for (it = begin; it != end; it++)
493         {
494           if (it->second->isPublic())
495           {
496             oss << ", " << it->second->getName();
497             if (oss.tellp() - startPos > 90)
498             {
499               oss << "  &" << iendl;
500               startPos = oss.tellp();
501             }
502           }
503         }
504         oss << " )";
505
506         oss << std::endl << (iendl -= 2);
507         oss << "END SUBROUTINE xios(set_" << className << "_attr_hdl)" << std::endl;
508      }
509
510      void CAttributeMap::generateFortranInterfaceGet_hdl(ostream& oss, const string& className)
511      {
512         oss << "SUBROUTINE xios(get_" << className << "_attr_hdl)  &" << iendl++;
513         SuperClassMap::const_iterator it;
514         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
515
516         long startPos = oss.tellp();
517
518         oss << "( " << className << "_hdl";
519         for (it = begin; it != end; it++)
520         {
521           if (it->second->isPublic())
522           {
523             oss << ", " << it->second->getName();
524             if (oss.tellp() - startPos > 90)
525             {
526               oss << "  &" << iendl;
527               startPos = oss.tellp();
528             }
529           }
530         }
531         oss << " )";
532         oss << std::endl;
533         oss << iendl;
534
535         oss << "IMPLICIT NONE" << iendl++;
536         oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl";
537
538         for (it = begin; it != end; it++)
539         {
540           if (it->second->isPublic())
541           {
542             oss << iendl;
543             it->second->generateFortranInterfaceGetDeclaration(oss, className);
544           }
545         }
546
547         oss << std::endl << iendl;
548
549         oss << "CALL xios(get_" << className << "_attr_hdl_)  &" << iendl;
550
551         startPos = oss.tellp();
552
553         oss << "( " << className << "_hdl";
554         for (it = begin; it != end; it++)
555         {
556           if (it->second->isPublic())
557           {
558             oss << ", " << it->second->getName();
559             if (oss.tellp() - startPos > 90)
560             {
561               oss << "  &" << iendl;
562               startPos = oss.tellp();
563             }
564           }
565         }
566         oss << " )";
567
568         oss << std::endl << (iendl -= 2);
569         oss << "END SUBROUTINE xios(get_" << className << "_attr_hdl)" << std::endl;
570      }
571
572      void CAttributeMap::generateFortranInterfaceIsDefined_hdl(ostream& oss, const string& className)
573      {
574         oss << "SUBROUTINE xios(is_defined_" << className << "_attr_hdl)  &" << iendl++;
575         SuperClassMap::const_iterator it;
576         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
577
578         long startPos = oss.tellp();
579
580         oss << "( " << className << "_hdl";
581         for (it = begin; it != end; it++)
582         {
583           if (it->second->isPublic())
584           {
585             oss << ", " << it->second->getName();
586             if (oss.tellp() - startPos > 90)
587             {
588               oss << "  &" << iendl;
589               startPos = oss.tellp();
590             }
591           }
592         }
593         oss << " )";
594         oss << std::endl;
595         oss << iendl;
596
597         oss << "IMPLICIT NONE" << iendl++;
598         oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl";
599
600         for (it = begin; it != end; it++)
601         {
602           if (it->second->isPublic())
603           {
604             oss << iendl;
605             it->second->generateFortranInterfaceIsDefinedDeclaration(oss, className);
606           }
607         }
608
609         oss << std::endl << iendl;
610
611         oss << "CALL xios(is_defined_" << className << "_attr_hdl_)  &" << iendl;
612
613         startPos = oss.tellp();
614
615         oss << "( " << className << "_hdl";
616         for (it = begin; it != end; it++)
617         {
618           if (it->second->isPublic())
619           {
620             oss << ", " << it->second->getName();
621             if (oss.tellp() - startPos > 90)
622             {
623               oss << "  &" << iendl;
624               startPos = oss.tellp();
625             }
626           }
627         }
628         oss << " )";
629
630         oss << std::endl << (iendl -= 2);
631         oss << "END SUBROUTINE xios(is_defined_" << className << "_attr_hdl)" << std::endl;
632      }
633
634      void CAttributeMap::generateFortranInterface_id(ostream& oss, const string& className)
635      {
636         oss << "SUBROUTINE xios(set_" << className << "_attr)  &" << iendl++;
637         SuperClassMap::const_iterator it;
638         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
639
640         long startPos = oss.tellp();
641
642         oss << "( " << className << "_id";
643         for (it = begin; it != end; it++)
644         {
645           if (it->second->isPublic())
646           {
647             oss << ", " << it->second->getName();
648             if (oss.tellp() - startPos > 90)
649             {
650               oss << "  &" << iendl;
651               startPos = oss.tellp();
652             }
653           }
654         }
655         oss << " )";
656         oss << std::endl;
657         oss << iendl;
658
659         oss << "IMPLICIT NONE" << iendl++;
660
661         oss << "TYPE(txios(" << className << "))  :: " << className << "_hdl" << iendl;
662         oss << "CHARACTER(LEN=*), INTENT(IN) ::" << className << "_id";
663
664         for (it = begin; it != end; it++)
665         {
666           if (it->second->isPublic())
667           {
668             oss << iendl;
669             it->second->generateFortranInterfaceDeclaration(oss, className);
670           }
671         }
672
673         oss << std::endl << iendl;
674         oss << "CALL xios(get_" << className << "_handle) &" << iendl;
675         oss << "(" << className << "_id," << className << "_hdl)" << iendl;
676         oss << "CALL xios(set_" << className << "_attr_hdl_)   &" << iendl;
677
678         startPos = oss.tellp();
679
680         oss << "( " << className << "_hdl";
681         for (it = begin; it != end; it++)
682         {
683           if (it->second->isPublic())
684           {
685             oss << ", " << it->second->getName();
686             if (oss.tellp() - startPos > 90)
687             {
688               oss << "  &" << iendl;
689               startPos = oss.tellp();
690             }
691           }
692         }
693         oss << " )";
694
695         oss << std::endl << (iendl -= 2);
696         oss << "END SUBROUTINE xios(set_" << className << "_attr)" << std::endl;
697      }
698
699      void CAttributeMap::generateFortranInterfaceGet_id(ostream& oss, const string& className)
700      {
701         oss << "SUBROUTINE xios(get_" << className << "_attr)  &" << iendl++;
702         SuperClassMap::const_iterator it;
703         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
704
705         long startPos = oss.tellp();
706
707         oss << "( " << className << "_id";
708         for (it = begin; it != end; it++)
709         {
710           if (it->second->isPublic())
711           {
712             oss << ", " << it->second->getName();
713             if (oss.tellp() - startPos > 90)
714             {
715               oss << "  &" << iendl;
716               startPos = oss.tellp();
717             }
718           }
719         }
720         oss << " )";
721         oss << std::endl;
722         oss << iendl;
723
724         oss << "IMPLICIT NONE" << iendl++;
725
726         oss << "TYPE(txios(" << className << "))  :: " << className << "_hdl" << iendl;
727         oss << "CHARACTER(LEN=*), INTENT(IN) ::" << className << "_id";
728
729         for (it = begin; it != end; it++)
730         {
731           if (it->second->isPublic())
732           {
733             oss << iendl;
734             it->second->generateFortranInterfaceGetDeclaration(oss, className);
735           }
736         }
737
738         oss << std::endl << iendl;
739         oss << "CALL xios(get_" << className << "_handle) &" << iendl;
740         oss << "(" << className << "_id," << className << "_hdl)" << iendl;
741         oss << "CALL xios(get_" << className << "_attr_hdl_)   &" << iendl;
742
743         startPos = oss.tellp();
744
745         oss << "( " << className << "_hdl";
746         for (it = begin; it != end; it++)
747         {
748           if (it->second->isPublic())
749           {
750             oss << ", " << it->second->getName();
751             if (oss.tellp() - startPos > 90)
752             {
753               oss << "  &" << iendl;
754               startPos = oss.tellp();
755             }
756           }
757         }
758         oss << " )";
759
760         oss << std::endl << (iendl -= 2);
761         oss << "END SUBROUTINE xios(get_" << className << "_attr)" << std::endl;
762      }
763
764      void CAttributeMap::generateFortranInterfaceIsDefined_id(ostream& oss, const string& className)
765      {
766         oss << "SUBROUTINE xios(is_defined_" << className << "_attr)  &" << iendl++;
767         SuperClassMap::const_iterator it;
768         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
769
770         long startPos = oss.tellp();
771
772         oss << "( " << className << "_id";
773         for (it = begin; it != end; it++)
774         {
775           if (it->second->isPublic())
776           {
777             oss << ", " << it->second->getName();
778             if (oss.tellp() - startPos > 90)
779             {
780               oss << "  &" << iendl;
781               startPos = oss.tellp();
782             }
783           }
784         }
785         oss << " )";
786         oss << std::endl;
787         oss << iendl;
788
789         oss << "IMPLICIT NONE" << iendl++;
790
791         oss << "TYPE(txios(" << className << "))  :: " << className << "_hdl" << iendl;
792         oss << "CHARACTER(LEN=*), INTENT(IN) ::" << className << "_id";
793
794         for (it = begin; it != end; it++)
795         {
796           if (it->second->isPublic())
797           {
798             oss << iendl;
799             it->second->generateFortranInterfaceIsDefinedDeclaration(oss, className);
800           }
801         }
802
803         oss << std::endl << iendl;
804         oss << "CALL xios(get_" << className << "_handle) &" << iendl;
805         oss << "(" << className << "_id," << className << "_hdl)" << iendl;
806         oss << "CALL xios(is_defined_" << className << "_attr_hdl_)   &" << iendl;
807
808         startPos = oss.tellp();
809
810         oss << "( " << className << "_hdl";
811         for (it = begin; it != end; it++)
812         {
813           if (it->second->isPublic())
814           {
815             oss << ", " << it->second->getName();
816             if (oss.tellp() - startPos > 90)
817             {
818               oss << "  &" << iendl;
819               startPos = oss.tellp();
820             }
821           }
822         }
823         oss << " )";
824
825         oss << std::endl << (iendl -= 2);
826         oss << "END SUBROUTINE xios(is_defined_" << className << "_attr)" << std::endl;
827      }
828} // namespace xios
Note: See TracBrowser for help on using the repository browser.