source: XIOS/dev/dev_olga/src/attribute_map.cpp @ 1269

Last change on this file since 1269 was 1158, checked in by oabramkina, 7 years ago

Two server levels: merging with trunk r1137.
There are bugs.

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