[219] | 1 | #include "attribute_map.hpp" |
---|
[313] | 2 | #include "indent.hpp" |
---|
[219] | 3 | |
---|
[335] | 4 | namespace xios |
---|
[219] | 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 */ } |
---|
[509] | 15 | |
---|
[219] | 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; |
---|
[369] | 25 | att.second->reset(); |
---|
[219] | 26 | } |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | //--------------------------------------------------------------- |
---|
| 30 | |
---|
| 31 | bool CAttributeMap::hasAttribute(const StdString & key) const |
---|
[509] | 32 | { |
---|
| 33 | return (this->find(key) != this->end()); |
---|
[219] | 34 | } |
---|
[509] | 35 | |
---|
| 36 | void CAttributeMap::clearAttribute(const StdString& key) |
---|
| 37 | { |
---|
| 38 | if (hasAttribute(key)) this->find(key)->second->reset(); |
---|
| 39 | } |
---|
| 40 | |
---|
[219] | 41 | //--------------------------------------------------------------- |
---|
[509] | 42 | |
---|
[219] | 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 !"); |
---|
[369] | 51 | this->find(key)->second->set(*attr) ; |
---|
| 52 | // this->find(key)->second->setAnyValue(attr->getAnyValue()); |
---|
[219] | 53 | } |
---|
[509] | 54 | |
---|
[219] | 55 | //--------------------------------------------------------------- |
---|
[509] | 56 | |
---|
[219] | 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 | } |
---|
[509] | 64 | |
---|
[219] | 65 | //--------------------------------------------------------------- |
---|
[509] | 66 | |
---|
[219] | 67 | StdString CAttributeMap::toString(void) const |
---|
| 68 | { |
---|
| 69 | typedef std::pair<StdString, CAttribute*> StdStrAttPair; |
---|
| 70 | StdOStringStream oss; |
---|
[509] | 71 | |
---|
[219] | 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 | } |
---|
[509] | 81 | |
---|
[219] | 82 | //--------------------------------------------------------------- |
---|
[509] | 83 | |
---|
[219] | 84 | void CAttributeMap::fromString(const StdString & str) |
---|
[509] | 85 | { |
---|
[219] | 86 | ERROR("CAttributeMap::fromString(const StdString & str)", |
---|
[509] | 87 | << "[ str = " << str << "] Not implemented yet !"); |
---|
[219] | 88 | } |
---|
[509] | 89 | |
---|
[219] | 90 | //--------------------------------------------------------------- |
---|
| 91 | |
---|
| 92 | //StdOStream & operator << (StdOStream & os, const CAttributeMap & attributmap) |
---|
| 93 | //{ os << attributmap.toString(); return (os); } |
---|
[509] | 94 | |
---|
[219] | 95 | //--------------------------------------------------------------- |
---|
[509] | 96 | |
---|
[219] | 97 | void CAttributeMap::setAttributes(const xml::THashAttributes & attributes) |
---|
| 98 | { |
---|
| 99 | for (xml::THashAttributes::const_iterator it = attributes.begin(); |
---|
| 100 | it != attributes.end(); |
---|
| 101 | it ++) |
---|
[278] | 102 | { |
---|
[219] | 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 | } |
---|
[278] | 109 | } |
---|
[219] | 110 | } |
---|
[509] | 111 | |
---|
[219] | 112 | //--------------------------------------------------------------- |
---|
[509] | 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 | */ |
---|
[445] | 123 | void CAttributeMap::setAttributes(const CAttributeMap * const _parent, bool apply) |
---|
[219] | 124 | { |
---|
| 125 | typedef std::pair<StdString, CAttribute*> StdStrAttPair; |
---|
[509] | 126 | |
---|
[219] | 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 | { |
---|
[445] | 133 | CAttribute * currentAtt = CAttributeMap::operator[](el.first); |
---|
| 134 | CAttribute * parentAtt = el.second ; |
---|
| 135 | if (apply) |
---|
[219] | 136 | { |
---|
[445] | 137 | if (currentAtt->isEmpty() && !el.second->isEmpty()) |
---|
| 138 | { |
---|
| 139 | this->setAttribute(el.first, el.second); |
---|
| 140 | } |
---|
[219] | 141 | } |
---|
[445] | 142 | else currentAtt->setInheritedValue(*parentAtt) ; |
---|
[219] | 143 | } |
---|
| 144 | } |
---|
| 145 | } |
---|
[509] | 146 | |
---|
[219] | 147 | //--------------------------------------------------------------- |
---|
[509] | 148 | /* |
---|
[219] | 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(); |
---|
[509] | 153 | |
---|
[219] | 154 | const StdSize nbatt = SuperClassMap::size(); |
---|
| 155 | os.write (reinterpret_cast<const char*>(&nbatt) , sizeof(StdSize)); |
---|
[509] | 156 | |
---|
[219] | 157 | for (; it != end; it++) |
---|
| 158 | { |
---|
| 159 | const StdString & key = it->first; |
---|
[509] | 160 | const CAttribute* value = it->second; |
---|
[219] | 161 | const StdSize size = key.size(); |
---|
[509] | 162 | |
---|
[219] | 163 | os.write (reinterpret_cast<const char*>(&size) , sizeof(StdSize)); |
---|
| 164 | os.write (key.data(), size * sizeof(char)); |
---|
[509] | 165 | |
---|
[219] | 166 | if (!value->isEmpty()) |
---|
| 167 | { |
---|
| 168 | bool b = true; |
---|
| 169 | os.write (reinterpret_cast<const char*>(&b) , sizeof(bool)); |
---|
| 170 | value->toBinary(os); |
---|
| 171 | } |
---|
[509] | 172 | else |
---|
[219] | 173 | { |
---|
| 174 | bool b = false; |
---|
| 175 | os.write (reinterpret_cast<const char*>(&b) , sizeof(bool)); |
---|
| 176 | } |
---|
| 177 | } |
---|
| 178 | } |
---|
[509] | 179 | |
---|
[219] | 180 | //--------------------------------------------------------------- |
---|
[509] | 181 | |
---|
[219] | 182 | void CAttributeMap::fromBinary(StdIStream & is) |
---|
| 183 | { |
---|
| 184 | StdSize nbatt = 0; |
---|
| 185 | is.read (reinterpret_cast<char*>(&nbatt), sizeof(StdSize)); |
---|
[509] | 186 | |
---|
[219] | 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)); |
---|
[509] | 194 | |
---|
[219] | 195 | if (!this->hasAttribute(key)) |
---|
| 196 | ERROR("CAttributeMap::fromBinary(StdIStream & is)", |
---|
| 197 | << "[ key = " << key << "] key not found !"); |
---|
[509] | 198 | |
---|
[219] | 199 | is.read (reinterpret_cast<char*>(&hasValue), sizeof(bool)); |
---|
[509] | 200 | |
---|
| 201 | if (hasValue) |
---|
[219] | 202 | this->operator[](key)->fromBinary(is); |
---|
| 203 | } |
---|
| 204 | } |
---|
[509] | 205 | */ |
---|
[313] | 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) ; |
---|
[432] | 212 | it->second->generateCInterfaceIsDefined(oss,className) ; |
---|
[313] | 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) ; |
---|
[432] | 223 | it->second->generateFortran2003InterfaceIsDefined(oss,className) ; |
---|
[509] | 224 | |
---|
[313] | 225 | oss<<iendl<<iendl ; |
---|
| 226 | } |
---|
[509] | 227 | } |
---|
| 228 | |
---|
[219] | 229 | ///-------------------------------------------------------------- |
---|
| 230 | |
---|
[313] | 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(); |
---|
[509] | 237 | |
---|
[313] | 238 | oss2=new ostringstream ; |
---|
[509] | 239 | |
---|
[313] | 240 | *oss2<<"( "<<className<<"_hdl" ; |
---|
[509] | 241 | |
---|
| 242 | for ( it=begin ; it != end; it++) |
---|
[313] | 243 | { |
---|
| 244 | *oss2<<", "<<it->second->getName()<<"_" ; |
---|
[509] | 245 | if (oss2->str().size()>90) |
---|
[313] | 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 ; |
---|
[509] | 255 | delete oss2 ; |
---|
| 256 | |
---|
[313] | 257 | oss<<"IMPLICIT NONE"<<iendl++ ; |
---|
| 258 | oss<<"TYPE(txios("<<className<<")) , INTENT(IN) :: "<<className<<"_hdl"<<iendl ; |
---|
[509] | 259 | |
---|
[313] | 260 | for (it=begin; it != end; it++) |
---|
| 261 | { |
---|
| 262 | it->second->generateFortranInterfaceDeclaration_(oss,className) ; |
---|
| 263 | } |
---|
[509] | 264 | |
---|
[313] | 265 | oss<<iendl ; |
---|
[509] | 266 | |
---|
[313] | 267 | for (it=begin; it != end; it++) |
---|
| 268 | { |
---|
| 269 | it->second->generateFortranInterfaceBody_(oss,className) ; |
---|
| 270 | oss<<iendl ; |
---|
| 271 | } |
---|
[509] | 272 | |
---|
[313] | 273 | oss<<iendl--<<iendl-- ; |
---|
| 274 | oss<<"END SUBROUTINE xios(set_"<<className<<"_attr_hdl_)"<<iendl ; |
---|
| 275 | |
---|
[509] | 276 | } |
---|
| 277 | |
---|
[313] | 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(); |
---|
[509] | 284 | |
---|
[313] | 285 | oss2=new ostringstream ; |
---|
[509] | 286 | |
---|
[313] | 287 | *oss2<<"( "<<className<<"_hdl" ; |
---|
[509] | 288 | |
---|
| 289 | for ( it=begin ; it != end; it++) |
---|
[313] | 290 | { |
---|
| 291 | *oss2<<", "<<it->second->getName()<<"_" ; |
---|
[509] | 292 | if (oss2->str().size()>90) |
---|
[313] | 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 ; |
---|
[509] | 302 | delete oss2 ; |
---|
| 303 | |
---|
[313] | 304 | oss<<"IMPLICIT NONE"<<iendl++ ; |
---|
| 305 | oss<<"TYPE(txios("<<className<<")) , INTENT(IN) :: "<<className<<"_hdl"<<iendl ; |
---|
[509] | 306 | |
---|
[313] | 307 | for (it=begin; it != end; it++) |
---|
| 308 | { |
---|
| 309 | it->second->generateFortranInterfaceGetDeclaration_(oss,className) ; |
---|
| 310 | } |
---|
[509] | 311 | |
---|
[313] | 312 | oss<<iendl ; |
---|
[509] | 313 | |
---|
[313] | 314 | for (it=begin; it != end; it++) |
---|
| 315 | { |
---|
| 316 | it->second->generateFortranInterfaceGetBody_(oss,className) ; |
---|
| 317 | oss<<iendl ; |
---|
| 318 | } |
---|
[509] | 319 | |
---|
[313] | 320 | oss<<iendl--<<iendl-- ; |
---|
| 321 | oss<<"END SUBROUTINE xios(get_"<<className<<"_attr_hdl_)"<<iendl ; |
---|
[432] | 322 | |
---|
[509] | 323 | } |
---|
| 324 | |
---|
| 325 | |
---|
[432] | 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(); |
---|
[509] | 332 | |
---|
[432] | 333 | oss2=new ostringstream ; |
---|
[509] | 334 | |
---|
[432] | 335 | *oss2<<"( "<<className<<"_hdl" ; |
---|
[509] | 336 | |
---|
| 337 | for ( it=begin ; it != end; it++) |
---|
[432] | 338 | { |
---|
| 339 | *oss2<<", "<<it->second->getName()<<"_" ; |
---|
[509] | 340 | if (oss2->str().size()>90) |
---|
[432] | 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 ; |
---|
[509] | 350 | delete oss2 ; |
---|
| 351 | |
---|
[432] | 352 | oss<<"IMPLICIT NONE"<<iendl++ ; |
---|
| 353 | oss<<"TYPE(txios("<<className<<")) , INTENT(IN) :: "<<className<<"_hdl"<<iendl ; |
---|
[509] | 354 | |
---|
[432] | 355 | for (it=begin; it != end; it++) |
---|
| 356 | { |
---|
| 357 | it->second->generateFortranInterfaceIsDefinedDeclaration_(oss,className) ; |
---|
| 358 | } |
---|
[509] | 359 | |
---|
[432] | 360 | oss<<iendl ; |
---|
[509] | 361 | |
---|
[432] | 362 | for (it=begin; it != end; it++) |
---|
| 363 | { |
---|
| 364 | it->second->generateFortranInterfaceIsDefinedBody_(oss,className) ; |
---|
| 365 | oss<<iendl ; |
---|
| 366 | } |
---|
[509] | 367 | |
---|
[432] | 368 | oss<<iendl--<<iendl-- ; |
---|
| 369 | oss<<"END SUBROUTINE xios(is_defined_"<<className<<"_attr_hdl_)"<<iendl ; |
---|
[313] | 370 | |
---|
[509] | 371 | } |
---|
| 372 | |
---|
| 373 | |
---|
[313] | 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(); |
---|
[509] | 380 | |
---|
[313] | 381 | oss2=new ostringstream ; |
---|
| 382 | *oss2<<"( "<<className<<"_hdl" ; |
---|
[509] | 383 | for ( it=begin ; it != end; it++) |
---|
[313] | 384 | { |
---|
| 385 | *oss2<<", "<<it->second->getName() ; |
---|
[509] | 386 | if (oss2->str().size()>90) |
---|
[313] | 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 ; |
---|
[509] | 396 | delete oss2 ; |
---|
[313] | 397 | oss2=new ostringstream ; |
---|
[509] | 398 | |
---|
[313] | 399 | oss<<"IMPLICIT NONE"<<iendl++ ; |
---|
| 400 | oss<<"TYPE(txios("<<className<<")) , INTENT(IN) :: "<<className<<"_hdl"<<iendl ; |
---|
[509] | 401 | |
---|
[313] | 402 | for (it=begin; it != end; it++) |
---|
| 403 | { |
---|
| 404 | it->second->generateFortranInterfaceDeclaration(oss,className) ; |
---|
| 405 | } |
---|
[509] | 406 | |
---|
[313] | 407 | oss<<iendl ; |
---|
[509] | 408 | |
---|
[313] | 409 | oss<<"CALL xios(set_"<<className<<"_attr_hdl_) &"<<iendl ; |
---|
[509] | 410 | |
---|
[313] | 411 | *oss2<<"( "<<className<<"_hdl" ; |
---|
[509] | 412 | for ( it=begin ; it != end; it++) |
---|
[313] | 413 | { |
---|
| 414 | *oss2<<", "<<it->second->getName() ; |
---|
[509] | 415 | if (oss2->str().size()>90) |
---|
[313] | 416 | { |
---|
| 417 | oss<<oss2->str()<<" &"<<iendl ; |
---|
| 418 | delete oss2 ; |
---|
| 419 | oss2=new ostringstream ; |
---|
| 420 | } |
---|
| 421 | } |
---|
| 422 | *oss2<<" )" ; |
---|
| 423 | oss<<oss2->str() ; |
---|
[509] | 424 | delete oss2 ; |
---|
| 425 | |
---|
[313] | 426 | oss<<iendl--<<iendl-- ; |
---|
| 427 | oss<<"END SUBROUTINE xios(set_"<<className<<"_attr_hdl)"<<iendl ; |
---|
[509] | 428 | } |
---|
| 429 | |
---|
| 430 | |
---|
[313] | 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(); |
---|
[509] | 437 | |
---|
[313] | 438 | oss2=new ostringstream ; |
---|
| 439 | *oss2<<"( "<<className<<"_hdl" ; |
---|
[509] | 440 | for ( it=begin ; it != end; it++) |
---|
[313] | 441 | { |
---|
| 442 | *oss2<<", "<<it->second->getName() ; |
---|
[509] | 443 | if (oss2->str().size()>90) |
---|
[313] | 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 ; |
---|
[509] | 453 | delete oss2 ; |
---|
[313] | 454 | oss2=new ostringstream ; |
---|
[509] | 455 | |
---|
[313] | 456 | oss<<"IMPLICIT NONE"<<iendl++ ; |
---|
| 457 | oss<<"TYPE(txios("<<className<<")) , INTENT(IN) :: "<<className<<"_hdl"<<iendl ; |
---|
[509] | 458 | |
---|
[313] | 459 | for (it=begin; it != end; it++) |
---|
| 460 | { |
---|
| 461 | it->second->generateFortranInterfaceGetDeclaration(oss,className) ; |
---|
| 462 | } |
---|
[509] | 463 | |
---|
[313] | 464 | oss<<iendl ; |
---|
[509] | 465 | |
---|
[313] | 466 | oss<<"CALL xios(get_"<<className<<"_attr_hdl_) &"<<iendl ; |
---|
[509] | 467 | |
---|
[313] | 468 | *oss2<<"( "<<className<<"_hdl" ; |
---|
[509] | 469 | for ( it=begin ; it != end; it++) |
---|
[313] | 470 | { |
---|
| 471 | *oss2<<", "<<it->second->getName() ; |
---|
[509] | 472 | if (oss2->str().size()>90) |
---|
[313] | 473 | { |
---|
| 474 | oss<<oss2->str()<<" &"<<iendl ; |
---|
| 475 | delete oss2 ; |
---|
| 476 | oss2=new ostringstream ; |
---|
| 477 | } |
---|
| 478 | } |
---|
| 479 | *oss2<<" )" ; |
---|
| 480 | oss<<oss2->str() ; |
---|
[509] | 481 | delete oss2 ; |
---|
| 482 | |
---|
[313] | 483 | oss<<iendl--<<iendl-- ; |
---|
| 484 | oss<<"END SUBROUTINE xios(get_"<<className<<"_attr_hdl)"<<iendl ; |
---|
[509] | 485 | } |
---|
[432] | 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(); |
---|
[509] | 494 | |
---|
[432] | 495 | oss2=new ostringstream ; |
---|
| 496 | *oss2<<"( "<<className<<"_hdl" ; |
---|
[509] | 497 | for ( it=begin ; it != end; it++) |
---|
[432] | 498 | { |
---|
| 499 | *oss2<<", "<<it->second->getName() ; |
---|
[509] | 500 | if (oss2->str().size()>90) |
---|
[432] | 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 ; |
---|
[509] | 510 | delete oss2 ; |
---|
[432] | 511 | oss2=new ostringstream ; |
---|
[509] | 512 | |
---|
[432] | 513 | oss<<"IMPLICIT NONE"<<iendl++ ; |
---|
| 514 | oss<<"TYPE(txios("<<className<<")) , INTENT(IN) :: "<<className<<"_hdl"<<iendl ; |
---|
[509] | 515 | |
---|
[432] | 516 | for (it=begin; it != end; it++) |
---|
| 517 | { |
---|
| 518 | it->second->generateFortranInterfaceIsDefinedDeclaration(oss,className) ; |
---|
| 519 | } |
---|
[509] | 520 | |
---|
[432] | 521 | oss<<iendl ; |
---|
[509] | 522 | |
---|
[432] | 523 | oss<<"CALL xios(is_defined_"<<className<<"_attr_hdl_) &"<<iendl ; |
---|
[509] | 524 | |
---|
[432] | 525 | *oss2<<"( "<<className<<"_hdl" ; |
---|
[509] | 526 | for ( it=begin ; it != end; it++) |
---|
[432] | 527 | { |
---|
| 528 | *oss2<<", "<<it->second->getName() ; |
---|
[509] | 529 | if (oss2->str().size()>90) |
---|
[432] | 530 | { |
---|
| 531 | oss<<oss2->str()<<" &"<<iendl ; |
---|
| 532 | delete oss2 ; |
---|
| 533 | oss2=new ostringstream ; |
---|
| 534 | } |
---|
| 535 | } |
---|
| 536 | *oss2<<" )" ; |
---|
| 537 | oss<<oss2->str() ; |
---|
[509] | 538 | delete oss2 ; |
---|
| 539 | |
---|
[432] | 540 | oss<<iendl--<<iendl-- ; |
---|
| 541 | oss<<"END SUBROUTINE xios(is_defined_"<<className<<"_attr_hdl)"<<iendl ; |
---|
[509] | 542 | } |
---|
[432] | 543 | |
---|
[509] | 544 | |
---|
[313] | 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(); |
---|
[509] | 551 | |
---|
[313] | 552 | oss2=new ostringstream ; |
---|
| 553 | *oss2<<"( "<<className<<"_id" ; |
---|
[509] | 554 | for ( it=begin ; it != end; it++) |
---|
[313] | 555 | { |
---|
| 556 | *oss2<<", "<<it->second->getName() ; |
---|
[509] | 557 | if (oss2->str().size()>90) |
---|
[313] | 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 ; |
---|
[509] | 567 | delete oss2 ; |
---|
[313] | 568 | oss2=new ostringstream ; |
---|
[509] | 569 | |
---|
[313] | 570 | oss<<"IMPLICIT NONE"<<iendl++ ; |
---|
| 571 | |
---|
| 572 | oss<<"TYPE(txios("<<className<<")) :: "<<className<<"_hdl"<<iendl ; |
---|
| 573 | oss<<"CHARACTER(LEN=*), INTENT(IN) ::"<<className<<"_id"<<iendl ; |
---|
[509] | 574 | |
---|
[313] | 575 | for (it=begin; it != end; it++) |
---|
| 576 | { |
---|
| 577 | it->second->generateFortranInterfaceDeclaration(oss,className) ; |
---|
| 578 | } |
---|
[509] | 579 | |
---|
[313] | 580 | oss<<iendl ; |
---|
[509] | 581 | oss<<"CALL xios(get_"<<className<<"_handle)("<<className<<"_id,"<<className<<"_hdl)"<<iendl ; |
---|
[313] | 582 | oss<<"CALL xios(set_"<<className<<"_attr_hdl_) &"<<iendl ; |
---|
| 583 | *oss2<<"( "<<className<<"_hdl" ; |
---|
[509] | 584 | for ( it=begin ; it != end; it++) |
---|
[313] | 585 | { |
---|
| 586 | *oss2<<", "<<it->second->getName() ; |
---|
[509] | 587 | if (oss2->str().size()>90) |
---|
[313] | 588 | { |
---|
| 589 | oss<<oss2->str()<<" &"<<iendl ; |
---|
| 590 | delete oss2 ; |
---|
| 591 | oss2=new ostringstream ; |
---|
| 592 | } |
---|
| 593 | } |
---|
| 594 | *oss2<<" )" ; |
---|
| 595 | oss<<oss2->str() ; |
---|
[509] | 596 | delete oss2 ; |
---|
| 597 | |
---|
[313] | 598 | oss<<iendl--<<iendl-- ; |
---|
| 599 | oss<<"END SUBROUTINE xios(set_"<<className<<"_attr)"<<iendl ; |
---|
[509] | 600 | |
---|
| 601 | } |
---|
| 602 | |
---|
[313] | 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(); |
---|
[509] | 609 | |
---|
[313] | 610 | oss2=new ostringstream ; |
---|
| 611 | *oss2<<"( "<<className<<"_id" ; |
---|
[509] | 612 | for ( it=begin ; it != end; it++) |
---|
[313] | 613 | { |
---|
| 614 | *oss2<<", "<<it->second->getName() ; |
---|
[509] | 615 | if (oss2->str().size()>90) |
---|
[313] | 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 ; |
---|
[509] | 625 | delete oss2 ; |
---|
[313] | 626 | oss2=new ostringstream ; |
---|
[509] | 627 | |
---|
[313] | 628 | oss<<"IMPLICIT NONE"<<iendl++ ; |
---|
| 629 | |
---|
| 630 | oss<<"TYPE(txios("<<className<<")) :: "<<className<<"_hdl"<<iendl ; |
---|
| 631 | oss<<"CHARACTER(LEN=*), INTENT(IN) ::"<<className<<"_id"<<iendl ; |
---|
[509] | 632 | |
---|
[313] | 633 | for (it=begin; it != end; it++) |
---|
| 634 | { |
---|
| 635 | it->second->generateFortranInterfaceGetDeclaration(oss,className) ; |
---|
| 636 | } |
---|
[509] | 637 | |
---|
[313] | 638 | oss<<iendl ; |
---|
[509] | 639 | oss<<"CALL xios(get_"<<className<<"_handle)("<<className<<"_id,"<<className<<"_hdl)"<<iendl ; |
---|
[313] | 640 | oss<<"CALL xios(get_"<<className<<"_attr_hdl_) &"<<iendl ; |
---|
| 641 | *oss2<<"( "<<className<<"_hdl" ; |
---|
[509] | 642 | for ( it=begin ; it != end; it++) |
---|
[313] | 643 | { |
---|
| 644 | *oss2<<", "<<it->second->getName() ; |
---|
[509] | 645 | if (oss2->str().size()>90) |
---|
[313] | 646 | { |
---|
| 647 | oss<<oss2->str()<<" &"<<iendl ; |
---|
| 648 | delete oss2 ; |
---|
| 649 | oss2=new ostringstream ; |
---|
| 650 | } |
---|
| 651 | } |
---|
| 652 | *oss2<<" )" ; |
---|
| 653 | oss<<oss2->str() ; |
---|
[509] | 654 | delete oss2 ; |
---|
| 655 | |
---|
[313] | 656 | oss<<iendl--<<iendl-- ; |
---|
| 657 | oss<<"END SUBROUTINE xios(get_"<<className<<"_attr)"<<iendl ; |
---|
[509] | 658 | |
---|
| 659 | } |
---|
| 660 | |
---|
[432] | 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(); |
---|
[509] | 667 | |
---|
[432] | 668 | oss2=new ostringstream ; |
---|
| 669 | *oss2<<"( "<<className<<"_id" ; |
---|
[509] | 670 | for ( it=begin ; it != end; it++) |
---|
[432] | 671 | { |
---|
| 672 | *oss2<<", "<<it->second->getName() ; |
---|
[509] | 673 | if (oss2->str().size()>90) |
---|
[432] | 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 ; |
---|
[509] | 683 | delete oss2 ; |
---|
[432] | 684 | oss2=new ostringstream ; |
---|
[509] | 685 | |
---|
[432] | 686 | oss<<"IMPLICIT NONE"<<iendl++ ; |
---|
| 687 | |
---|
| 688 | oss<<"TYPE(txios("<<className<<")) :: "<<className<<"_hdl"<<iendl ; |
---|
| 689 | oss<<"CHARACTER(LEN=*), INTENT(IN) ::"<<className<<"_id"<<iendl ; |
---|
[509] | 690 | |
---|
[432] | 691 | for (it=begin; it != end; it++) |
---|
| 692 | { |
---|
| 693 | it->second->generateFortranInterfaceIsDefinedDeclaration(oss,className) ; |
---|
| 694 | } |
---|
[509] | 695 | |
---|
[432] | 696 | oss<<iendl ; |
---|
[509] | 697 | oss<<"CALL xios(get_"<<className<<"_handle)("<<className<<"_id,"<<className<<"_hdl)"<<iendl ; |
---|
[432] | 698 | oss<<"CALL xios(is_defined_"<<className<<"_attr_hdl_) &"<<iendl ; |
---|
| 699 | *oss2<<"( "<<className<<"_hdl" ; |
---|
[509] | 700 | for ( it=begin ; it != end; it++) |
---|
[432] | 701 | { |
---|
| 702 | *oss2<<", "<<it->second->getName() ; |
---|
[509] | 703 | if (oss2->str().size()>90) |
---|
[432] | 704 | { |
---|
| 705 | oss<<oss2->str()<<" &"<<iendl ; |
---|
| 706 | delete oss2 ; |
---|
| 707 | oss2=new ostringstream ; |
---|
| 708 | } |
---|
| 709 | } |
---|
| 710 | *oss2<<" )" ; |
---|
| 711 | oss<<oss2->str() ; |
---|
[509] | 712 | delete oss2 ; |
---|
| 713 | |
---|
[432] | 714 | oss<<iendl--<<iendl-- ; |
---|
| 715 | oss<<"END SUBROUTINE xios(is_defined_"<<className<<"_attr)"<<iendl ; |
---|
[509] | 716 | |
---|
| 717 | } |
---|
[313] | 718 | ///-------------------------------------------------------------- |
---|
| 719 | |
---|
[509] | 720 | |
---|
[219] | 721 | } // namespace xmlioser |
---|