[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 | |
---|
[219] | 146 | //--------------------------------------------------------------- |
---|
[509] | 147 | /* |
---|
[581] | 148 | void CAttributeMap::toBinary(StdOStream& os) const |
---|
[219] | 149 | { |
---|
| 150 | typedef std::pair<StdString, CAttribute*> StdStrAttPair; |
---|
| 151 | SuperClassMap::const_iterator it = this->begin(), end = this->end(); |
---|
[509] | 152 | |
---|
[219] | 153 | const StdSize nbatt = SuperClassMap::size(); |
---|
| 154 | os.write (reinterpret_cast<const char*>(&nbatt) , sizeof(StdSize)); |
---|
[509] | 155 | |
---|
[219] | 156 | for (; it != end; it++) |
---|
| 157 | { |
---|
[581] | 158 | const StdString& key = it->first; |
---|
[509] | 159 | const CAttribute* value = it->second; |
---|
[219] | 160 | const StdSize size = key.size(); |
---|
[509] | 161 | |
---|
[219] | 162 | os.write (reinterpret_cast<const char*>(&size) , sizeof(StdSize)); |
---|
[581] | 163 | os.write (key.data(), size* sizeof(char)); |
---|
[509] | 164 | |
---|
[219] | 165 | if (!value->isEmpty()) |
---|
| 166 | { |
---|
| 167 | bool b = true; |
---|
| 168 | os.write (reinterpret_cast<const char*>(&b) , sizeof(bool)); |
---|
| 169 | value->toBinary(os); |
---|
| 170 | } |
---|
[509] | 171 | else |
---|
[219] | 172 | { |
---|
| 173 | bool b = false; |
---|
| 174 | os.write (reinterpret_cast<const char*>(&b) , sizeof(bool)); |
---|
| 175 | } |
---|
| 176 | } |
---|
| 177 | } |
---|
[509] | 178 | |
---|
[219] | 179 | //--------------------------------------------------------------- |
---|
[509] | 180 | |
---|
[581] | 181 | void CAttributeMap::fromBinary(StdIStream& is) |
---|
[219] | 182 | { |
---|
| 183 | StdSize nbatt = 0; |
---|
| 184 | is.read (reinterpret_cast<char*>(&nbatt), sizeof(StdSize)); |
---|
[509] | 185 | |
---|
[219] | 186 | for (StdSize i = 0; i < nbatt; i++) |
---|
| 187 | { |
---|
| 188 | bool hasValue = false; |
---|
| 189 | StdSize size = 0; |
---|
| 190 | is.read (reinterpret_cast<char*>(&size), sizeof(StdSize)); |
---|
| 191 | StdString key(size, ' '); |
---|
[581] | 192 | is.read (const_cast<char *>(key.data()), size* sizeof(char)); |
---|
[509] | 193 | |
---|
[219] | 194 | if (!this->hasAttribute(key)) |
---|
[581] | 195 | ERROR("CAttributeMap::fromBinary(StdIStream& is)", |
---|
[219] | 196 | << "[ key = " << key << "] key not found !"); |
---|
[509] | 197 | |
---|
[219] | 198 | is.read (reinterpret_cast<char*>(&hasValue), sizeof(bool)); |
---|
[509] | 199 | |
---|
| 200 | if (hasValue) |
---|
[219] | 201 | this->operator[](key)->fromBinary(is); |
---|
| 202 | } |
---|
| 203 | } |
---|
[509] | 204 | */ |
---|
[313] | 205 | void CAttributeMap::generateCInterface(ostream& oss, const string& className) |
---|
| 206 | { |
---|
| 207 | SuperClassMap::const_iterator it = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
| 208 | for (; it != end; it++) |
---|
| 209 | { |
---|
[581] | 210 | oss << std::endl << iendl; |
---|
| 211 | it->second->generateCInterface(oss, className); |
---|
| 212 | oss << iendl; |
---|
| 213 | it->second->generateCInterfaceIsDefined(oss, className); |
---|
[313] | 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 | { |
---|
[581] | 222 | oss << std::endl << iendl; |
---|
| 223 | it->second->generateFortran2003Interface(oss, className); |
---|
| 224 | oss << iendl; |
---|
| 225 | it->second->generateFortran2003InterfaceIsDefined(oss, className); |
---|
[313] | 226 | } |
---|
[509] | 227 | } |
---|
| 228 | |
---|
[219] | 229 | ///-------------------------------------------------------------- |
---|
| 230 | |
---|
[313] | 231 | void CAttributeMap::generateFortranInterface_hdl_(ostream& oss, const string& className) |
---|
| 232 | { |
---|
[581] | 233 | oss << "SUBROUTINE xios(set_" << className << "_attr_hdl_) &" << iendl++; |
---|
| 234 | ostringstream* oss2; |
---|
| 235 | SuperClassMap::const_iterator it; |
---|
[313] | 236 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 237 | |
---|
[581] | 238 | oss2 = new ostringstream; |
---|
[509] | 239 | |
---|
[581] | 240 | *oss2 << "( " << className << "_hdl" ; |
---|
[509] | 241 | |
---|
[581] | 242 | for (it = begin; it != end; it++) |
---|
[313] | 243 | { |
---|
[581] | 244 | *oss2 << ", " << it->second->getName() << "_"; |
---|
| 245 | if (oss2->str().size() > 90) |
---|
[313] | 246 | { |
---|
[581] | 247 | oss << oss2->str() << " &" << iendl; |
---|
| 248 | delete oss2; |
---|
| 249 | oss2 = new ostringstream; |
---|
[313] | 250 | } |
---|
| 251 | } |
---|
[581] | 252 | *oss2 << " )"; |
---|
| 253 | oss << oss2->str() << std::endl; |
---|
| 254 | oss << iendl; |
---|
| 255 | delete oss2; |
---|
[509] | 256 | |
---|
[581] | 257 | oss << "IMPLICIT NONE" << iendl++; |
---|
| 258 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
[509] | 259 | |
---|
[581] | 260 | for (it = begin; it != end; it++) |
---|
[313] | 261 | { |
---|
[581] | 262 | oss << iendl; |
---|
| 263 | it->second->generateFortranInterfaceDeclaration_(oss, className); |
---|
[313] | 264 | } |
---|
[509] | 265 | |
---|
[581] | 266 | for (it = begin; it != end; it++) |
---|
[313] | 267 | { |
---|
[581] | 268 | oss << std::endl << iendl; |
---|
| 269 | it->second->generateFortranInterfaceBody_(oss, className); |
---|
[313] | 270 | } |
---|
[509] | 271 | |
---|
[581] | 272 | oss << std::endl << (iendl -= 2); |
---|
| 273 | oss << "END SUBROUTINE xios(set_" << className << "_attr_hdl_)" << std::endl; |
---|
[509] | 274 | } |
---|
| 275 | |
---|
[313] | 276 | void CAttributeMap::generateFortranInterfaceGet_hdl_(ostream& oss, const string& className) |
---|
| 277 | { |
---|
[581] | 278 | oss << "SUBROUTINE xios(get_" << className << "_attr_hdl_) &" << iendl++; |
---|
| 279 | ostringstream* oss2; |
---|
| 280 | SuperClassMap::const_iterator it; |
---|
[313] | 281 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 282 | |
---|
[581] | 283 | oss2 = new ostringstream; |
---|
[509] | 284 | |
---|
[581] | 285 | *oss2 << "( " << className << "_hdl" ; |
---|
[509] | 286 | |
---|
[581] | 287 | for (it = begin; it != end; it++) |
---|
[313] | 288 | { |
---|
[581] | 289 | *oss2 << ", " << it->second->getName() << "_"; |
---|
| 290 | if (oss2->str().size() > 90) |
---|
[313] | 291 | { |
---|
[581] | 292 | oss << oss2->str() << " &" << iendl; |
---|
| 293 | delete oss2; |
---|
| 294 | oss2 = new ostringstream; |
---|
[313] | 295 | } |
---|
| 296 | } |
---|
[581] | 297 | *oss2 << " )"; |
---|
| 298 | oss << oss2->str() << std::endl; |
---|
| 299 | oss << iendl; |
---|
| 300 | delete oss2; |
---|
[509] | 301 | |
---|
[581] | 302 | oss << "IMPLICIT NONE" << iendl++; |
---|
| 303 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
[509] | 304 | |
---|
[581] | 305 | for (it = begin; it != end; it++) |
---|
[313] | 306 | { |
---|
[581] | 307 | oss << iendl; |
---|
| 308 | it->second->generateFortranInterfaceGetDeclaration_(oss, className); |
---|
[313] | 309 | } |
---|
[509] | 310 | |
---|
[581] | 311 | for (it = begin; it != end; it++) |
---|
[313] | 312 | { |
---|
[581] | 313 | oss << std::endl << iendl; |
---|
| 314 | it->second->generateFortranInterfaceGetBody_(oss, className); |
---|
[313] | 315 | } |
---|
[509] | 316 | |
---|
[581] | 317 | oss << std::endl << (iendl -= 2); |
---|
| 318 | oss << "END SUBROUTINE xios(get_" << className << "_attr_hdl_)" << std::endl; |
---|
[509] | 319 | } |
---|
| 320 | |
---|
[432] | 321 | void CAttributeMap::generateFortranInterfaceIsDefined_hdl_(ostream& oss, const string& className) |
---|
| 322 | { |
---|
[581] | 323 | oss << "SUBROUTINE xios(is_defined_" << className << "_attr_hdl_) &" << iendl++; |
---|
| 324 | ostringstream* oss2; |
---|
| 325 | SuperClassMap::const_iterator it; |
---|
[432] | 326 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 327 | |
---|
[581] | 328 | oss2 = new ostringstream; |
---|
[509] | 329 | |
---|
[581] | 330 | *oss2 << "( " << className << "_hdl" ; |
---|
[509] | 331 | |
---|
[581] | 332 | for (it = begin; it != end; it++) |
---|
[432] | 333 | { |
---|
[581] | 334 | *oss2 << ", " << it->second->getName() << "_"; |
---|
| 335 | if (oss2->str().size() > 90) |
---|
[432] | 336 | { |
---|
[581] | 337 | oss << oss2->str() << " &" << iendl; |
---|
| 338 | delete oss2; |
---|
| 339 | oss2 = new ostringstream; |
---|
[432] | 340 | } |
---|
| 341 | } |
---|
[581] | 342 | *oss2 << " )"; |
---|
| 343 | oss << oss2->str() << std::endl; |
---|
| 344 | oss << iendl; |
---|
| 345 | delete oss2; |
---|
[509] | 346 | |
---|
[581] | 347 | oss << "IMPLICIT NONE" << iendl++; |
---|
| 348 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
[509] | 349 | |
---|
[581] | 350 | for (it = begin; it != end; it++) |
---|
[432] | 351 | { |
---|
[581] | 352 | oss << iendl; |
---|
| 353 | it->second->generateFortranInterfaceIsDefinedDeclaration_(oss, className); |
---|
[432] | 354 | } |
---|
[509] | 355 | |
---|
[581] | 356 | for (it = begin; it != end; it++) |
---|
[432] | 357 | { |
---|
[581] | 358 | oss << std::endl << iendl; |
---|
| 359 | it->second->generateFortranInterfaceIsDefinedBody_(oss, className); |
---|
[432] | 360 | } |
---|
[509] | 361 | |
---|
[581] | 362 | oss << std::endl << (iendl -= 2); |
---|
| 363 | oss << "END SUBROUTINE xios(is_defined_" << className << "_attr_hdl_)" << std::endl; |
---|
[509] | 364 | } |
---|
| 365 | |
---|
[313] | 366 | void CAttributeMap::generateFortranInterface_hdl(ostream& oss, const string& className) |
---|
| 367 | { |
---|
[581] | 368 | oss << "SUBROUTINE xios(set_" << className << "_attr_hdl) &" << iendl++; |
---|
| 369 | ostringstream* oss2; |
---|
| 370 | SuperClassMap::const_iterator it; |
---|
[313] | 371 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 372 | |
---|
[581] | 373 | oss2 = new ostringstream; |
---|
| 374 | *oss2 << "( " << className << "_hdl" ; |
---|
| 375 | for (it = begin; it != end; it++) |
---|
[313] | 376 | { |
---|
[581] | 377 | *oss2 << ", " << it->second->getName(); |
---|
| 378 | if (oss2->str().size() > 90) |
---|
[313] | 379 | { |
---|
[581] | 380 | oss << oss2->str() << " &" << iendl; |
---|
| 381 | delete oss2; |
---|
| 382 | oss2 = new ostringstream; |
---|
[313] | 383 | } |
---|
| 384 | } |
---|
[581] | 385 | *oss2 << " )"; |
---|
| 386 | oss << oss2->str() << std::endl; |
---|
| 387 | oss << iendl; |
---|
| 388 | delete oss2; |
---|
| 389 | oss2 = new ostringstream; |
---|
[509] | 390 | |
---|
[581] | 391 | oss << "IMPLICIT NONE" << iendl++; |
---|
| 392 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
[509] | 393 | |
---|
[581] | 394 | for (it = begin; it != end; it++) |
---|
[313] | 395 | { |
---|
[581] | 396 | oss << iendl; |
---|
| 397 | it->second->generateFortranInterfaceDeclaration(oss, className); |
---|
[313] | 398 | } |
---|
[509] | 399 | |
---|
[581] | 400 | oss << std::endl << iendl; |
---|
[509] | 401 | |
---|
[581] | 402 | oss << "CALL xios(set_" << className << "_attr_hdl_) &" << iendl; |
---|
[509] | 403 | |
---|
[581] | 404 | *oss2 << "( " << className << "_hdl" ; |
---|
| 405 | for (it = begin; it != end; it++) |
---|
[313] | 406 | { |
---|
[581] | 407 | *oss2 << ", " << it->second->getName(); |
---|
| 408 | if (oss2->str().size() > 90) |
---|
[313] | 409 | { |
---|
[581] | 410 | oss << oss2->str() << " &" << iendl; |
---|
| 411 | delete oss2; |
---|
| 412 | oss2 = new ostringstream; |
---|
[313] | 413 | } |
---|
| 414 | } |
---|
[581] | 415 | *oss2 << " )"; |
---|
| 416 | oss << oss2->str(); |
---|
| 417 | delete oss2; |
---|
[509] | 418 | |
---|
[581] | 419 | oss << std::endl << (iendl -= 2); |
---|
| 420 | oss << "END SUBROUTINE xios(set_" << className << "_attr_hdl)" << std::endl; |
---|
[509] | 421 | } |
---|
| 422 | |
---|
[313] | 423 | void CAttributeMap::generateFortranInterfaceGet_hdl(ostream& oss, const string& className) |
---|
| 424 | { |
---|
[581] | 425 | oss << "SUBROUTINE xios(get_" << className << "_attr_hdl) &" << iendl++; |
---|
| 426 | ostringstream* oss2; |
---|
| 427 | SuperClassMap::const_iterator it; |
---|
[313] | 428 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 429 | |
---|
[581] | 430 | oss2 = new ostringstream; |
---|
| 431 | *oss2 << "( " << className << "_hdl" ; |
---|
| 432 | for (it = begin; it != end; it++) |
---|
[313] | 433 | { |
---|
[581] | 434 | *oss2 << ", " << it->second->getName(); |
---|
| 435 | if (oss2->str().size() > 90) |
---|
[313] | 436 | { |
---|
[581] | 437 | oss << oss2->str() << " &" << iendl; |
---|
| 438 | delete oss2; |
---|
| 439 | oss2 = new ostringstream; |
---|
[313] | 440 | } |
---|
| 441 | } |
---|
[581] | 442 | *oss2 << " )"; |
---|
| 443 | oss << oss2->str() << std::endl; |
---|
| 444 | oss << iendl; |
---|
| 445 | delete oss2; |
---|
| 446 | oss2 = new ostringstream; |
---|
[509] | 447 | |
---|
[581] | 448 | oss << "IMPLICIT NONE" << iendl++; |
---|
| 449 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
[509] | 450 | |
---|
[581] | 451 | for (it = begin; it != end; it++) |
---|
[313] | 452 | { |
---|
[581] | 453 | oss << iendl; |
---|
| 454 | it->second->generateFortranInterfaceGetDeclaration(oss, className); |
---|
[313] | 455 | } |
---|
[509] | 456 | |
---|
[581] | 457 | oss << std::endl << iendl; |
---|
[509] | 458 | |
---|
[581] | 459 | oss << "CALL xios(get_" << className << "_attr_hdl_) &" << iendl; |
---|
[509] | 460 | |
---|
[581] | 461 | *oss2 << "( " << className << "_hdl" ; |
---|
| 462 | for (it = begin; it != end; it++) |
---|
[313] | 463 | { |
---|
[581] | 464 | *oss2 << ", " << it->second->getName(); |
---|
| 465 | if (oss2->str().size() > 90) |
---|
[313] | 466 | { |
---|
[581] | 467 | oss << oss2->str() << " &" << iendl; |
---|
| 468 | delete oss2; |
---|
| 469 | oss2 = new ostringstream; |
---|
[313] | 470 | } |
---|
| 471 | } |
---|
[581] | 472 | *oss2 << " )"; |
---|
| 473 | oss << oss2->str(); |
---|
| 474 | delete oss2; |
---|
[509] | 475 | |
---|
[581] | 476 | oss << std::endl << (iendl -= 2); |
---|
| 477 | oss << "END SUBROUTINE xios(get_" << className << "_attr_hdl)" << std::endl; |
---|
[509] | 478 | } |
---|
[432] | 479 | |
---|
| 480 | void CAttributeMap::generateFortranInterfaceIsDefined_hdl(ostream& oss, const string& className) |
---|
| 481 | { |
---|
[581] | 482 | oss << "SUBROUTINE xios(is_defined_" << className << "_attr_hdl) &" << iendl++; |
---|
| 483 | ostringstream* oss2; |
---|
| 484 | SuperClassMap::const_iterator it; |
---|
[432] | 485 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 486 | |
---|
[581] | 487 | oss2 = new ostringstream; |
---|
| 488 | *oss2 << "( " << className << "_hdl" ; |
---|
| 489 | for (it = begin; it != end; it++) |
---|
[432] | 490 | { |
---|
[581] | 491 | *oss2 << ", " << it->second->getName(); |
---|
| 492 | if (oss2->str().size() > 90) |
---|
[432] | 493 | { |
---|
[581] | 494 | oss << oss2->str() << " &" << iendl; |
---|
| 495 | delete oss2; |
---|
| 496 | oss2 = new ostringstream; |
---|
[432] | 497 | } |
---|
| 498 | } |
---|
[581] | 499 | *oss2 << " )"; |
---|
| 500 | oss << oss2->str() << std::endl; |
---|
| 501 | oss << iendl; |
---|
| 502 | delete oss2; |
---|
| 503 | oss2 = new ostringstream; |
---|
[509] | 504 | |
---|
[581] | 505 | oss << "IMPLICIT NONE" << iendl++; |
---|
| 506 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
[509] | 507 | |
---|
[581] | 508 | for (it = begin; it != end; it++) |
---|
[432] | 509 | { |
---|
[581] | 510 | oss << iendl; |
---|
| 511 | it->second->generateFortranInterfaceIsDefinedDeclaration(oss, className); |
---|
[432] | 512 | } |
---|
[509] | 513 | |
---|
[581] | 514 | oss << std::endl << iendl; |
---|
[509] | 515 | |
---|
[581] | 516 | oss << "CALL xios(is_defined_" << className << "_attr_hdl_) &" << iendl; |
---|
[509] | 517 | |
---|
[581] | 518 | *oss2 << "( " << className << "_hdl" ; |
---|
| 519 | for (it = begin; it != end; it++) |
---|
[432] | 520 | { |
---|
[581] | 521 | *oss2 << ", " << it->second->getName(); |
---|
| 522 | if (oss2->str().size() > 90) |
---|
[432] | 523 | { |
---|
[581] | 524 | oss << oss2->str() << " &" << iendl; |
---|
| 525 | delete oss2; |
---|
| 526 | oss2 = new ostringstream; |
---|
[432] | 527 | } |
---|
| 528 | } |
---|
[581] | 529 | *oss2 << " )"; |
---|
| 530 | oss << oss2->str(); |
---|
| 531 | delete oss2; |
---|
[509] | 532 | |
---|
[581] | 533 | oss << std::endl << (iendl -= 2); |
---|
| 534 | oss << "END SUBROUTINE xios(is_defined_" << className << "_attr_hdl)" << std::endl; |
---|
[509] | 535 | } |
---|
[432] | 536 | |
---|
[313] | 537 | void CAttributeMap::generateFortranInterface_id(ostream& oss, const string& className) |
---|
| 538 | { |
---|
[581] | 539 | oss << "SUBROUTINE xios(set_" << className << "_attr) &" << iendl++; |
---|
| 540 | ostringstream* oss2; |
---|
| 541 | SuperClassMap::const_iterator it; |
---|
[313] | 542 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 543 | |
---|
[581] | 544 | oss2 = new ostringstream; |
---|
| 545 | *oss2 << "( " << className << "_id" ; |
---|
| 546 | for (it = begin; it != end; it++) |
---|
[313] | 547 | { |
---|
[581] | 548 | *oss2 << ", " << it->second->getName(); |
---|
| 549 | if (oss2->str().size() > 90) |
---|
[313] | 550 | { |
---|
[581] | 551 | oss << oss2->str() << " &" << iendl; |
---|
| 552 | delete oss2; |
---|
| 553 | oss2 = new ostringstream; |
---|
[313] | 554 | } |
---|
| 555 | } |
---|
[581] | 556 | *oss2 << " )"; |
---|
| 557 | oss << oss2->str() << std::endl; |
---|
| 558 | oss << iendl; |
---|
| 559 | delete oss2; |
---|
| 560 | oss2 = new ostringstream; |
---|
[509] | 561 | |
---|
[581] | 562 | oss << "IMPLICIT NONE" << iendl++; |
---|
[313] | 563 | |
---|
[581] | 564 | oss << "TYPE(txios(" << className << ")) :: " << className << "_hdl" << iendl; |
---|
| 565 | oss << "CHARACTER(LEN=*), INTENT(IN) ::" << className << "_id"; |
---|
[509] | 566 | |
---|
[581] | 567 | for (it = begin; it != end; it++) |
---|
[313] | 568 | { |
---|
[581] | 569 | oss << iendl; |
---|
| 570 | it->second->generateFortranInterfaceDeclaration(oss, className); |
---|
[313] | 571 | } |
---|
[509] | 572 | |
---|
[581] | 573 | oss << std::endl << iendl; |
---|
| 574 | oss << "CALL xios(get_" << className << "_handle)(" << className << "_id," << className << "_hdl)" << iendl; |
---|
| 575 | oss << "CALL xios(set_" << className << "_attr_hdl_) &" << iendl; |
---|
| 576 | *oss2 << "( " << className << "_hdl" ; |
---|
| 577 | for (it = begin; it != end; it++) |
---|
[313] | 578 | { |
---|
[581] | 579 | *oss2 << ", " << it->second->getName(); |
---|
| 580 | if (oss2->str().size() > 90) |
---|
[313] | 581 | { |
---|
[581] | 582 | oss << oss2->str() << " &" << iendl; |
---|
| 583 | delete oss2; |
---|
| 584 | oss2 = new ostringstream; |
---|
[313] | 585 | } |
---|
| 586 | } |
---|
[581] | 587 | *oss2 << " )"; |
---|
| 588 | oss << oss2->str(); |
---|
| 589 | delete oss2; |
---|
[509] | 590 | |
---|
[581] | 591 | oss << std::endl << (iendl -= 2); |
---|
| 592 | oss << "END SUBROUTINE xios(set_" << className << "_attr)" << std::endl; |
---|
[509] | 593 | } |
---|
| 594 | |
---|
[313] | 595 | void CAttributeMap::generateFortranInterfaceGet_id(ostream& oss, const string& className) |
---|
| 596 | { |
---|
[581] | 597 | oss << "SUBROUTINE xios(get_" << className << "_attr) &" << iendl++; |
---|
| 598 | ostringstream* oss2; |
---|
| 599 | SuperClassMap::const_iterator it; |
---|
[313] | 600 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 601 | |
---|
[581] | 602 | oss2 = new ostringstream; |
---|
| 603 | *oss2 << "( " << className << "_id" ; |
---|
| 604 | for (it = begin; it != end; it++) |
---|
[313] | 605 | { |
---|
[581] | 606 | *oss2 << ", " << it->second->getName(); |
---|
| 607 | if (oss2->str().size() > 90) |
---|
[313] | 608 | { |
---|
[581] | 609 | oss << oss2->str() << " &" << iendl; |
---|
| 610 | delete oss2; |
---|
| 611 | oss2 = new ostringstream; |
---|
[313] | 612 | } |
---|
| 613 | } |
---|
[581] | 614 | *oss2 << " )"; |
---|
| 615 | oss << oss2->str() << std::endl; |
---|
| 616 | oss << iendl; |
---|
| 617 | delete oss2; |
---|
| 618 | oss2 = new ostringstream; |
---|
[509] | 619 | |
---|
[581] | 620 | oss << "IMPLICIT NONE" << iendl++; |
---|
[313] | 621 | |
---|
[581] | 622 | oss << "TYPE(txios(" << className << ")) :: " << className << "_hdl" << iendl; |
---|
| 623 | oss << "CHARACTER(LEN=*), INTENT(IN) ::" << className << "_id"; |
---|
[509] | 624 | |
---|
[581] | 625 | for (it = begin; it != end; it++) |
---|
[313] | 626 | { |
---|
[581] | 627 | oss << iendl; |
---|
| 628 | it->second->generateFortranInterfaceGetDeclaration(oss, className); |
---|
[313] | 629 | } |
---|
[509] | 630 | |
---|
[581] | 631 | oss << std::endl << iendl; |
---|
| 632 | oss << "CALL xios(get_" << className << "_handle)(" << className << "_id," << className << "_hdl)" << iendl; |
---|
| 633 | oss << "CALL xios(get_" << className << "_attr_hdl_) &" << iendl; |
---|
| 634 | *oss2 << "( " << className << "_hdl" ; |
---|
| 635 | for (it = begin; it != end; it++) |
---|
[313] | 636 | { |
---|
[581] | 637 | *oss2 << ", " << it->second->getName(); |
---|
| 638 | if (oss2->str().size() > 90) |
---|
[313] | 639 | { |
---|
[581] | 640 | oss << oss2->str() << " &" << iendl; |
---|
| 641 | delete oss2; |
---|
| 642 | oss2 = new ostringstream; |
---|
[313] | 643 | } |
---|
| 644 | } |
---|
[581] | 645 | *oss2 << " )"; |
---|
| 646 | oss << oss2->str(); |
---|
| 647 | delete oss2; |
---|
[509] | 648 | |
---|
[581] | 649 | oss << std::endl << (iendl -= 2); |
---|
| 650 | oss << "END SUBROUTINE xios(get_" << className << "_attr)" << std::endl; |
---|
[509] | 651 | } |
---|
| 652 | |
---|
[432] | 653 | void CAttributeMap::generateFortranInterfaceIsDefined_id(ostream& oss, const string& className) |
---|
| 654 | { |
---|
[581] | 655 | oss << "SUBROUTINE xios(is_defined_" << className << "_attr) &" << iendl++; |
---|
| 656 | ostringstream* oss2; |
---|
| 657 | SuperClassMap::const_iterator it; |
---|
[432] | 658 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 659 | |
---|
[581] | 660 | oss2 = new ostringstream; |
---|
| 661 | *oss2 << "( " << className << "_id" ; |
---|
| 662 | for (it = begin; it != end; it++) |
---|
[432] | 663 | { |
---|
[581] | 664 | *oss2 << ", " << it->second->getName(); |
---|
| 665 | if (oss2->str().size() > 90) |
---|
[432] | 666 | { |
---|
[581] | 667 | oss << oss2->str() << " &" << iendl; |
---|
| 668 | delete oss2; |
---|
| 669 | oss2 = new ostringstream; |
---|
[432] | 670 | } |
---|
| 671 | } |
---|
[581] | 672 | *oss2 << " )"; |
---|
| 673 | oss << oss2->str() << std::endl; |
---|
| 674 | oss << iendl; |
---|
| 675 | delete oss2; |
---|
| 676 | oss2 = new ostringstream; |
---|
[509] | 677 | |
---|
[581] | 678 | oss << "IMPLICIT NONE" << iendl++; |
---|
[432] | 679 | |
---|
[581] | 680 | oss << "TYPE(txios(" << className << ")) :: " << className << "_hdl" << iendl; |
---|
| 681 | oss << "CHARACTER(LEN=*), INTENT(IN) ::" << className << "_id"; |
---|
[509] | 682 | |
---|
[581] | 683 | for (it = begin; it != end; it++) |
---|
[432] | 684 | { |
---|
[581] | 685 | oss << iendl; |
---|
| 686 | it->second->generateFortranInterfaceIsDefinedDeclaration(oss, className); |
---|
[432] | 687 | } |
---|
[509] | 688 | |
---|
[581] | 689 | oss << std::endl << iendl; |
---|
| 690 | oss << "CALL xios(get_" << className << "_handle)(" << className << "_id," << className << "_hdl)" << iendl; |
---|
| 691 | oss << "CALL xios(is_defined_" << className << "_attr_hdl_) &" << iendl; |
---|
| 692 | *oss2 << "( " << className << "_hdl" ; |
---|
| 693 | for (it = begin; it != end; it++) |
---|
[432] | 694 | { |
---|
[581] | 695 | *oss2 << ", " << it->second->getName(); |
---|
| 696 | if (oss2->str().size() > 90) |
---|
[432] | 697 | { |
---|
[581] | 698 | oss << oss2->str() << " &" << iendl; |
---|
| 699 | delete oss2; |
---|
| 700 | oss2 = new ostringstream; |
---|
[432] | 701 | } |
---|
| 702 | } |
---|
[581] | 703 | *oss2 << " )"; |
---|
| 704 | oss << oss2->str(); |
---|
| 705 | delete oss2; |
---|
[509] | 706 | |
---|
[581] | 707 | oss << std::endl << (iendl -= 2); |
---|
| 708 | oss << "END SUBROUTINE xios(is_defined_" << className << "_attr)" << std::endl; |
---|
[509] | 709 | } |
---|
[591] | 710 | } // namespace xios |
---|