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

Last change on this file since 576 was 509, checked in by mhnguyen, 9 years ago

Implementing buffer size auto-detection for mode client -server

+) Process xml tree in client side then send all the information to server
+) Only information enabled fields in enabled files are sent to server
+) Some important change in structure of code which must be refactored

Test
+) On Curie
+) Only mode client-server
+) Passed for all tests

  • 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: 23.2 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      void CAttributeMap::clearAllAttributes(void)
19      {
20         typedef std::pair<StdString, CAttribute*> StdStrAttPair;
21         SuperClassMap::const_iterator it = SuperClassMap::begin(), end = SuperClassMap::end();
22         for (; it != end; it++)
23         {
24            const StdStrAttPair & att = *it;
25            att.second->reset();
26         }
27      }
28
29      //---------------------------------------------------------------
30
31      bool CAttributeMap::hasAttribute(const StdString & key) const
32      {
33         return (this->find(key) != this->end());
34      }
35
36      void CAttributeMap::clearAttribute(const StdString& key)
37      {
38        if (hasAttribute(key)) this->find(key)->second->reset();
39      }
40
41      //---------------------------------------------------------------
42
43      void CAttributeMap::setAttribute(const StdString & key, CAttribute * const attr)
44      {
45         if (!this->hasAttribute(key))
46            ERROR("CAttributeMap::setAttribute(key, attr)",
47                   << "[ key = " << key << "] key not found !");
48         if (attr == NULL)
49            ERROR("CAttributeMap::setAttribute(key, attr)",
50                   << "[ key = " << key << "] attr is null !");
51         this->find(key)->second->set(*attr) ;
52//         this->find(key)->second->setAnyValue(attr->getAnyValue());
53      }
54
55      //---------------------------------------------------------------
56
57      CAttribute * CAttributeMap::operator[](const StdString & key)
58      {
59         if (!this->hasAttribute(key))
60            ERROR("CAttributeMap::operator[](const StdString & key)",
61                  << "[ key = " << key << "] key not found !");
62         return (SuperClassMap::operator[](key));
63      }
64
65      //---------------------------------------------------------------
66
67      StdString CAttributeMap::toString(void) const
68      {
69         typedef std::pair<StdString, CAttribute*> StdStrAttPair;
70         StdOStringStream oss;
71
72         SuperClassMap::const_iterator it = SuperClassMap::begin(), end = SuperClassMap::end();
73         for (; it != end; it++)
74         {
75            const StdStrAttPair & att = *it;
76            if (!att.second->isEmpty())
77               oss << *att.second << " ";
78         }
79         return (oss.str());
80      }
81
82      //---------------------------------------------------------------
83
84      void CAttributeMap::fromString(const StdString & str)
85      {
86         ERROR("CAttributeMap::fromString(const StdString & str)",
87               << "[ str = " << str << "] Not implemented yet !");
88      }
89
90      //---------------------------------------------------------------
91
92      //StdOStream & operator << (StdOStream & os, const CAttributeMap & attributmap)
93      //{ os << attributmap.toString(); return (os); }
94
95      //---------------------------------------------------------------
96
97      void CAttributeMap::setAttributes(const xml::THashAttributes & attributes)
98      {
99         for (xml::THashAttributes::const_iterator it  = attributes.begin();
100                                                   it != attributes.end();
101                                                   it ++)
102         {
103            if ((*it).first.compare(StdString("id")) != 0 &&
104                (*it).first.compare(StdString("src"))!= 0)
105            {
106               //if (CAttributeMap::operator[]((*it).first)->isEmpty())
107               CAttributeMap::operator[]((*it).first)->fromString((*it).second);
108            }
109         }
110      }
111
112      //---------------------------------------------------------------
113
114      /*!
115      \brief Set attributes from a specific attributemap, considered parent.
116         The child attribute map will insert the attributes of its parent into its current attribute map.
117      The existing attributes can be filled with the values of the parent map if they are empty or
118      simply replaced by these values depending on choice of user.
119      \param [in] _parent Attribute map from which the current map gets attributes.
120      \param [in] apply Specify if current attribute map is replaced by the attributes of parent (false)
121                    or filled in in case of emptyp (true)
122      */
123      void CAttributeMap::setAttributes(const CAttributeMap * const _parent, bool apply)
124      {
125         typedef std::pair<StdString, CAttribute*> StdStrAttPair;
126
127         SuperClassMap::const_iterator it = _parent->begin(), end = _parent->end();
128         for (; it != end; it++)
129         {
130            const StdStrAttPair & el = *it;
131            if (this->hasAttribute(el.first))
132            {
133               CAttribute * currentAtt = CAttributeMap::operator[](el.first);
134               CAttribute * parentAtt = el.second ;
135               if (apply)
136               {
137                 if (currentAtt->isEmpty() && !el.second->isEmpty())
138                 {
139                    this->setAttribute(el.first, el.second);
140                 }
141               }
142               else currentAtt->setInheritedValue(*parentAtt) ;
143            }
144         }
145      }
146
147      //---------------------------------------------------------------
148/*
149      void CAttributeMap::toBinary(StdOStream & os) const
150      {
151         typedef std::pair<StdString, CAttribute*> StdStrAttPair;
152         SuperClassMap::const_iterator it = this->begin(), end = this->end();
153
154         const StdSize nbatt = SuperClassMap::size();
155         os.write (reinterpret_cast<const char*>(&nbatt) , sizeof(StdSize));
156
157         for (; it != end; it++)
158         {
159            const StdString & key   = it->first;
160            const CAttribute* value = it->second;
161            const StdSize size = key.size();
162
163            os.write (reinterpret_cast<const char*>(&size) , sizeof(StdSize));
164            os.write (key.data(), size * sizeof(char));
165
166            if (!value->isEmpty())
167            {
168               bool b = true;
169               os.write (reinterpret_cast<const char*>(&b) , sizeof(bool));
170               value->toBinary(os);
171            }
172            else
173            {
174               bool b = false;
175               os.write (reinterpret_cast<const char*>(&b) , sizeof(bool));
176            }
177         }
178      }
179
180      //---------------------------------------------------------------
181
182      void CAttributeMap::fromBinary(StdIStream & is)
183      {
184         StdSize nbatt = 0;
185         is.read (reinterpret_cast<char*>(&nbatt), sizeof(StdSize));
186
187         for (StdSize i = 0; i < nbatt; i++)
188         {
189            bool hasValue = false;
190            StdSize size  = 0;
191            is.read (reinterpret_cast<char*>(&size), sizeof(StdSize));
192            StdString key(size, ' ');
193            is.read (const_cast<char *>(key.data()), size * sizeof(char));
194
195            if (!this->hasAttribute(key))
196               ERROR("CAttributeMap::fromBinary(StdIStream & is)",
197                     << "[ key = " << key << "] key not found !");
198
199            is.read (reinterpret_cast<char*>(&hasValue), sizeof(bool));
200
201            if (hasValue)
202               this->operator[](key)->fromBinary(is);
203         }
204      }
205 */
206      void CAttributeMap::generateCInterface(ostream& oss, const string& className)
207      {
208         SuperClassMap::const_iterator it = SuperClassMap::begin(), end = SuperClassMap::end();
209         for (; it != end; it++)
210         {
211           it->second->generateCInterface(oss,className) ;
212           it->second->generateCInterfaceIsDefined(oss,className) ;
213           oss<<iendl<<iendl ;
214         }
215      }
216
217      void CAttributeMap::generateFortran2003Interface(ostream& oss, const string& className)
218      {
219         SuperClassMap::const_iterator it = SuperClassMap::begin(), end = SuperClassMap::end();
220         for (; it != end; it++)
221         {
222           it->second->generateFortran2003Interface(oss,className) ;
223           it->second->generateFortran2003InterfaceIsDefined(oss,className) ;
224
225           oss<<iendl<<iendl ;
226         }
227      }
228
229      ///--------------------------------------------------------------
230
231      void CAttributeMap::generateFortranInterface_hdl_(ostream& oss, const string& className)
232      {
233         oss<<"SUBROUTINE xios(set_"<<className<<"_attr_hdl_)   &"<<iendl++ ;
234         ostringstream* oss2 ;
235         SuperClassMap::const_iterator it ;
236         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
237
238         oss2=new ostringstream ;
239
240         *oss2<<"( "<<className<<"_hdl"  ;
241
242         for ( it=begin ; it != end; it++)
243         {
244           *oss2<<", "<<it->second->getName()<<"_" ;
245           if (oss2->str().size()>90)
246           {
247             oss<<oss2->str()<<"  &"<<iendl ;
248             delete oss2 ;
249             oss2=new ostringstream ;
250           }
251         }
252         *oss2<<" )" ;
253         oss<<oss2->str()<<iendl ;
254         oss<<iendl ;
255         delete oss2 ;
256
257         oss<<"IMPLICIT NONE"<<iendl++ ;
258         oss<<"TYPE(txios("<<className<<")) , INTENT(IN) :: "<<className<<"_hdl"<<iendl ;
259
260         for (it=begin; it != end; it++)
261         {
262           it->second->generateFortranInterfaceDeclaration_(oss,className) ;
263         }
264
265         oss<<iendl ;
266
267         for (it=begin; it != end; it++)
268         {
269           it->second->generateFortranInterfaceBody_(oss,className) ;
270           oss<<iendl ;
271         }
272
273         oss<<iendl--<<iendl-- ;
274         oss<<"END SUBROUTINE xios(set_"<<className<<"_attr_hdl_)"<<iendl ;
275
276      }
277
278      void CAttributeMap::generateFortranInterfaceGet_hdl_(ostream& oss, const string& className)
279      {
280         oss<<"SUBROUTINE xios(get_"<<className<<"_attr_hdl_)   &"<<iendl++ ;
281         ostringstream* oss2 ;
282         SuperClassMap::const_iterator it ;
283         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
284
285         oss2=new ostringstream ;
286
287         *oss2<<"( "<<className<<"_hdl"  ;
288
289         for ( it=begin ; it != end; it++)
290         {
291           *oss2<<", "<<it->second->getName()<<"_" ;
292           if (oss2->str().size()>90)
293           {
294             oss<<oss2->str()<<"  &"<<iendl ;
295             delete oss2 ;
296             oss2=new ostringstream ;
297           }
298         }
299         *oss2<<" )" ;
300         oss<<oss2->str()<<iendl ;
301         oss<<iendl ;
302         delete oss2 ;
303
304         oss<<"IMPLICIT NONE"<<iendl++ ;
305         oss<<"TYPE(txios("<<className<<")) , INTENT(IN) :: "<<className<<"_hdl"<<iendl ;
306
307         for (it=begin; it != end; it++)
308         {
309           it->second->generateFortranInterfaceGetDeclaration_(oss,className) ;
310         }
311
312         oss<<iendl ;
313
314         for (it=begin; it != end; it++)
315         {
316           it->second->generateFortranInterfaceGetBody_(oss,className) ;
317           oss<<iendl ;
318         }
319
320         oss<<iendl--<<iendl-- ;
321         oss<<"END SUBROUTINE xios(get_"<<className<<"_attr_hdl_)"<<iendl ;
322
323      }
324
325
326      void CAttributeMap::generateFortranInterfaceIsDefined_hdl_(ostream& oss, const string& className)
327      {
328         oss<<"SUBROUTINE xios(is_defined_"<<className<<"_attr_hdl_)   &"<<iendl++ ;
329         ostringstream* oss2 ;
330         SuperClassMap::const_iterator it ;
331         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
332
333         oss2=new ostringstream ;
334
335         *oss2<<"( "<<className<<"_hdl"  ;
336
337         for ( it=begin ; it != end; it++)
338         {
339           *oss2<<", "<<it->second->getName()<<"_" ;
340           if (oss2->str().size()>90)
341           {
342             oss<<oss2->str()<<"  &"<<iendl ;
343             delete oss2 ;
344             oss2=new ostringstream ;
345           }
346         }
347         *oss2<<" )" ;
348         oss<<oss2->str()<<iendl ;
349         oss<<iendl ;
350         delete oss2 ;
351
352         oss<<"IMPLICIT NONE"<<iendl++ ;
353         oss<<"TYPE(txios("<<className<<")) , INTENT(IN) :: "<<className<<"_hdl"<<iendl ;
354
355         for (it=begin; it != end; it++)
356         {
357           it->second->generateFortranInterfaceIsDefinedDeclaration_(oss,className) ;
358         }
359
360         oss<<iendl ;
361
362         for (it=begin; it != end; it++)
363         {
364           it->second->generateFortranInterfaceIsDefinedBody_(oss,className) ;
365           oss<<iendl ;
366         }
367
368         oss<<iendl--<<iendl-- ;
369         oss<<"END SUBROUTINE xios(is_defined_"<<className<<"_attr_hdl_)"<<iendl ;
370
371      }
372
373
374      void CAttributeMap::generateFortranInterface_hdl(ostream& oss, const string& className)
375      {
376         oss<<"SUBROUTINE xios(set_"<<className<<"_attr_hdl)  &"<<iendl++ ;
377         ostringstream* oss2 ;
378         SuperClassMap::const_iterator it ;
379         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
380
381         oss2=new ostringstream ;
382         *oss2<<"( "<<className<<"_hdl"  ;
383         for ( it=begin ; it != end; it++)
384         {
385           *oss2<<", "<<it->second->getName() ;
386           if (oss2->str().size()>90)
387           {
388             oss<<oss2->str()<<"  &"<<iendl ;
389             delete oss2 ;
390             oss2=new ostringstream ;
391           }
392         }
393         *oss2<<" )" ;
394         oss<<oss2->str()<<iendl ;
395         oss<<iendl ;
396         delete oss2 ;
397         oss2=new ostringstream ;
398
399         oss<<"IMPLICIT NONE"<<iendl++ ;
400         oss<<"TYPE(txios("<<className<<")) , INTENT(IN) :: "<<className<<"_hdl"<<iendl ;
401
402         for (it=begin; it != end; it++)
403         {
404           it->second->generateFortranInterfaceDeclaration(oss,className) ;
405         }
406
407         oss<<iendl ;
408
409         oss<<"CALL xios(set_"<<className<<"_attr_hdl_)  &"<<iendl ;
410
411         *oss2<<"( "<<className<<"_hdl"  ;
412         for ( it=begin ; it != end; it++)
413         {
414           *oss2<<", "<<it->second->getName() ;
415           if (oss2->str().size()>90)
416           {
417             oss<<oss2->str()<<"  &"<<iendl ;
418             delete oss2 ;
419             oss2=new ostringstream ;
420           }
421         }
422         *oss2<<" )" ;
423         oss<<oss2->str() ;
424         delete oss2 ;
425
426         oss<<iendl--<<iendl-- ;
427         oss<<"END SUBROUTINE xios(set_"<<className<<"_attr_hdl)"<<iendl ;
428      }
429
430
431      void CAttributeMap::generateFortranInterfaceGet_hdl(ostream& oss, const string& className)
432      {
433         oss<<"SUBROUTINE xios(get_"<<className<<"_attr_hdl)  &"<<iendl++ ;
434         ostringstream* oss2 ;
435         SuperClassMap::const_iterator it ;
436         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
437
438         oss2=new ostringstream ;
439         *oss2<<"( "<<className<<"_hdl"  ;
440         for ( it=begin ; it != end; it++)
441         {
442           *oss2<<", "<<it->second->getName() ;
443           if (oss2->str().size()>90)
444           {
445             oss<<oss2->str()<<"  &"<<iendl ;
446             delete oss2 ;
447             oss2=new ostringstream ;
448           }
449         }
450         *oss2<<" )" ;
451         oss<<oss2->str()<<iendl ;
452         oss<<iendl ;
453         delete oss2 ;
454         oss2=new ostringstream ;
455
456         oss<<"IMPLICIT NONE"<<iendl++ ;
457         oss<<"TYPE(txios("<<className<<")) , INTENT(IN) :: "<<className<<"_hdl"<<iendl ;
458
459         for (it=begin; it != end; it++)
460         {
461           it->second->generateFortranInterfaceGetDeclaration(oss,className) ;
462         }
463
464         oss<<iendl ;
465
466         oss<<"CALL xios(get_"<<className<<"_attr_hdl_)  &"<<iendl ;
467
468         *oss2<<"( "<<className<<"_hdl"  ;
469         for ( it=begin ; it != end; it++)
470         {
471           *oss2<<", "<<it->second->getName() ;
472           if (oss2->str().size()>90)
473           {
474             oss<<oss2->str()<<"  &"<<iendl ;
475             delete oss2 ;
476             oss2=new ostringstream ;
477           }
478         }
479         *oss2<<" )" ;
480         oss<<oss2->str() ;
481         delete oss2 ;
482
483         oss<<iendl--<<iendl-- ;
484         oss<<"END SUBROUTINE xios(get_"<<className<<"_attr_hdl)"<<iendl ;
485      }
486
487
488      void CAttributeMap::generateFortranInterfaceIsDefined_hdl(ostream& oss, const string& className)
489      {
490         oss<<"SUBROUTINE xios(is_defined_"<<className<<"_attr_hdl)  &"<<iendl++ ;
491         ostringstream* oss2 ;
492         SuperClassMap::const_iterator it ;
493         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
494
495         oss2=new ostringstream ;
496         *oss2<<"( "<<className<<"_hdl"  ;
497         for ( it=begin ; it != end; it++)
498         {
499           *oss2<<", "<<it->second->getName() ;
500           if (oss2->str().size()>90)
501           {
502             oss<<oss2->str()<<"  &"<<iendl ;
503             delete oss2 ;
504             oss2=new ostringstream ;
505           }
506         }
507         *oss2<<" )" ;
508         oss<<oss2->str()<<iendl ;
509         oss<<iendl ;
510         delete oss2 ;
511         oss2=new ostringstream ;
512
513         oss<<"IMPLICIT NONE"<<iendl++ ;
514         oss<<"TYPE(txios("<<className<<")) , INTENT(IN) :: "<<className<<"_hdl"<<iendl ;
515
516         for (it=begin; it != end; it++)
517         {
518           it->second->generateFortranInterfaceIsDefinedDeclaration(oss,className) ;
519         }
520
521         oss<<iendl ;
522
523         oss<<"CALL xios(is_defined_"<<className<<"_attr_hdl_)  &"<<iendl ;
524
525         *oss2<<"( "<<className<<"_hdl"  ;
526         for ( it=begin ; it != end; it++)
527         {
528           *oss2<<", "<<it->second->getName() ;
529           if (oss2->str().size()>90)
530           {
531             oss<<oss2->str()<<"  &"<<iendl ;
532             delete oss2 ;
533             oss2=new ostringstream ;
534           }
535         }
536         *oss2<<" )" ;
537         oss<<oss2->str() ;
538         delete oss2 ;
539
540         oss<<iendl--<<iendl-- ;
541         oss<<"END SUBROUTINE xios(is_defined_"<<className<<"_attr_hdl)"<<iendl ;
542      }
543
544
545      void CAttributeMap::generateFortranInterface_id(ostream& oss, const string& className)
546      {
547         oss<<"SUBROUTINE xios(set_"<<className<<"_attr)  &"<<iendl++ ;
548         ostringstream* oss2 ;
549         SuperClassMap::const_iterator it ;
550         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
551
552         oss2=new ostringstream ;
553         *oss2<<"( "<<className<<"_id"  ;
554         for ( it=begin ; it != end; it++)
555         {
556           *oss2<<", "<<it->second->getName() ;
557           if (oss2->str().size()>90)
558           {
559             oss<<oss2->str()<<"  &"<<iendl ;
560             delete oss2 ;
561             oss2=new ostringstream ;
562           }
563         }
564         *oss2<<" )" ;
565         oss<<oss2->str()<<iendl ;
566         oss<<iendl ;
567         delete oss2 ;
568         oss2=new ostringstream ;
569
570         oss<<"IMPLICIT NONE"<<iendl++ ;
571
572         oss<<"TYPE(txios("<<className<<"))  :: "<<className<<"_hdl"<<iendl ;
573         oss<<"CHARACTER(LEN=*), INTENT(IN) ::"<<className<<"_id"<<iendl ;
574
575         for (it=begin; it != end; it++)
576         {
577           it->second->generateFortranInterfaceDeclaration(oss,className) ;
578         }
579
580         oss<<iendl ;
581         oss<<"CALL xios(get_"<<className<<"_handle)("<<className<<"_id,"<<className<<"_hdl)"<<iendl ;
582         oss<<"CALL xios(set_"<<className<<"_attr_hdl_)   &"<<iendl ;
583         *oss2<<"( "<<className<<"_hdl"  ;
584         for ( it=begin ; it != end; it++)
585         {
586           *oss2<<", "<<it->second->getName() ;
587           if (oss2->str().size()>90)
588           {
589             oss<<oss2->str()<<"  &"<<iendl ;
590             delete oss2 ;
591             oss2=new ostringstream ;
592           }
593         }
594         *oss2<<" )" ;
595         oss<<oss2->str() ;
596         delete oss2 ;
597
598         oss<<iendl--<<iendl-- ;
599         oss<<"END SUBROUTINE xios(set_"<<className<<"_attr)"<<iendl ;
600
601      }
602
603      void CAttributeMap::generateFortranInterfaceGet_id(ostream& oss, const string& className)
604      {
605         oss<<"SUBROUTINE xios(get_"<<className<<"_attr)  &"<<iendl++ ;
606         ostringstream* oss2 ;
607         SuperClassMap::const_iterator it ;
608         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
609
610         oss2=new ostringstream ;
611         *oss2<<"( "<<className<<"_id"  ;
612         for ( it=begin ; it != end; it++)
613         {
614           *oss2<<", "<<it->second->getName() ;
615           if (oss2->str().size()>90)
616           {
617             oss<<oss2->str()<<"  &"<<iendl ;
618             delete oss2 ;
619             oss2=new ostringstream ;
620           }
621         }
622         *oss2<<" )" ;
623         oss<<oss2->str()<<iendl ;
624         oss<<iendl ;
625         delete oss2 ;
626         oss2=new ostringstream ;
627
628         oss<<"IMPLICIT NONE"<<iendl++ ;
629
630         oss<<"TYPE(txios("<<className<<"))  :: "<<className<<"_hdl"<<iendl ;
631         oss<<"CHARACTER(LEN=*), INTENT(IN) ::"<<className<<"_id"<<iendl ;
632
633         for (it=begin; it != end; it++)
634         {
635           it->second->generateFortranInterfaceGetDeclaration(oss,className) ;
636         }
637
638         oss<<iendl ;
639         oss<<"CALL xios(get_"<<className<<"_handle)("<<className<<"_id,"<<className<<"_hdl)"<<iendl ;
640         oss<<"CALL xios(get_"<<className<<"_attr_hdl_)   &"<<iendl ;
641         *oss2<<"( "<<className<<"_hdl"  ;
642         for ( it=begin ; it != end; it++)
643         {
644           *oss2<<", "<<it->second->getName() ;
645           if (oss2->str().size()>90)
646           {
647             oss<<oss2->str()<<"  &"<<iendl ;
648             delete oss2 ;
649             oss2=new ostringstream ;
650           }
651         }
652         *oss2<<" )" ;
653         oss<<oss2->str() ;
654         delete oss2 ;
655
656         oss<<iendl--<<iendl-- ;
657         oss<<"END SUBROUTINE xios(get_"<<className<<"_attr)"<<iendl ;
658
659      }
660
661      void CAttributeMap::generateFortranInterfaceIsDefined_id(ostream& oss, const string& className)
662      {
663         oss<<"SUBROUTINE xios(is_defined_"<<className<<"_attr)  &"<<iendl++ ;
664         ostringstream* oss2 ;
665         SuperClassMap::const_iterator it ;
666         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
667
668         oss2=new ostringstream ;
669         *oss2<<"( "<<className<<"_id"  ;
670         for ( it=begin ; it != end; it++)
671         {
672           *oss2<<", "<<it->second->getName() ;
673           if (oss2->str().size()>90)
674           {
675             oss<<oss2->str()<<"  &"<<iendl ;
676             delete oss2 ;
677             oss2=new ostringstream ;
678           }
679         }
680         *oss2<<" )" ;
681         oss<<oss2->str()<<iendl ;
682         oss<<iendl ;
683         delete oss2 ;
684         oss2=new ostringstream ;
685
686         oss<<"IMPLICIT NONE"<<iendl++ ;
687
688         oss<<"TYPE(txios("<<className<<"))  :: "<<className<<"_hdl"<<iendl ;
689         oss<<"CHARACTER(LEN=*), INTENT(IN) ::"<<className<<"_id"<<iendl ;
690
691         for (it=begin; it != end; it++)
692         {
693           it->second->generateFortranInterfaceIsDefinedDeclaration(oss,className) ;
694         }
695
696         oss<<iendl ;
697         oss<<"CALL xios(get_"<<className<<"_handle)("<<className<<"_id,"<<className<<"_hdl)"<<iendl ;
698         oss<<"CALL xios(is_defined_"<<className<<"_attr_hdl_)   &"<<iendl ;
699         *oss2<<"( "<<className<<"_hdl"  ;
700         for ( it=begin ; it != end; it++)
701         {
702           *oss2<<", "<<it->second->getName() ;
703           if (oss2->str().size()>90)
704           {
705             oss<<oss2->str()<<"  &"<<iendl ;
706             delete oss2 ;
707             oss2=new ostringstream ;
708           }
709         }
710         *oss2<<" )" ;
711         oss<<oss2->str() ;
712         delete oss2 ;
713
714         oss<<iendl--<<iendl-- ;
715         oss<<"END SUBROUTINE xios(is_defined_"<<className<<"_attr)"<<iendl ;
716
717      }
718      ///--------------------------------------------------------------
719
720
721} // namespace xmlioser
Note: See TracBrowser for help on using the repository browser.