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