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

Last change on this file since 1704 was 1704, checked in by yushan, 5 years ago

Introducing the new graph functionality. Attribute build_workflow_graph=.TRUE. is used in the field definition section in the xml file to enable the workflow graph of the field and other fields referecing to it. A more detailed document will be available soon on the graph fuctionality.

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