[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 | |
---|
[1158] | 18 | /*! |
---|
| 19 | Clear all attributes of an object and reset them to empty state |
---|
| 20 | */ |
---|
[219] | 21 | void CAttributeMap::clearAllAttributes(void) |
---|
| 22 | { |
---|
| 23 | typedef std::pair<StdString, CAttribute*> StdStrAttPair; |
---|
| 24 | SuperClassMap::const_iterator it = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
| 25 | for (; it != end; it++) |
---|
| 26 | { |
---|
[581] | 27 | const StdStrAttPair& att = *it; |
---|
[369] | 28 | att.second->reset(); |
---|
[219] | 29 | } |
---|
| 30 | } |
---|
| 31 | |
---|
[1612] | 32 | ///-------------------------------------------------------------- |
---|
| 33 | /*! |
---|
| 34 | Dump of all non-empty attributes of an object |
---|
| 35 | */ |
---|
| 36 | StdString CAttributeMap::dumpXiosAttributes(void) const |
---|
| 37 | { |
---|
| 38 | int maxNbChar = 250; |
---|
| 39 | StdString str; |
---|
| 40 | typedef std::pair<StdString, CAttribute*> StdStrAttPair; |
---|
| 41 | auto it = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
| 42 | for (; it != end; it++) |
---|
| 43 | { |
---|
| 44 | const StdStrAttPair& att = *it; |
---|
| 45 | if (!att.second->isEmpty()) |
---|
| 46 | { |
---|
| 47 | if (str.length() < maxNbChar) |
---|
| 48 | { |
---|
| 49 | str.append(att.second->dump()); |
---|
| 50 | str.append(" "); |
---|
| 51 | } |
---|
| 52 | else if (str.length() == maxNbChar) |
---|
| 53 | { |
---|
| 54 | str.append("..."); |
---|
| 55 | } |
---|
| 56 | } |
---|
| 57 | } |
---|
| 58 | return str; |
---|
| 59 | } |
---|
| 60 | |
---|
[2019] | 61 | ///-------------------------------------------------------------- |
---|
| 62 | /*! |
---|
| 63 | Record all non-empty attributes of an object (used only for field) for graph |
---|
| 64 | */ |
---|
| 65 | StdString CAttributeMap::recordXiosAttributes(void) const |
---|
[1686] | 66 | { |
---|
| 67 | int maxNbChar = 250; |
---|
| 68 | StdString str; |
---|
| 69 | typedef std::pair<StdString, CAttribute*> StdStrAttPair; |
---|
| 70 | auto it = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
| 71 | for (; it != end; it++) |
---|
| 72 | { |
---|
| 73 | const StdStrAttPair& att = *it; |
---|
| 74 | if (!att.second->isEmpty()) |
---|
| 75 | { |
---|
| 76 | if (str.length() < maxNbChar) |
---|
| 77 | { |
---|
[2019] | 78 | str.append(att.second->dumpGraph()); |
---|
[1686] | 79 | str.append(" "); |
---|
| 80 | } |
---|
| 81 | else if (str.length() == maxNbChar) |
---|
| 82 | { |
---|
| 83 | str.append("..."); |
---|
| 84 | } |
---|
| 85 | } |
---|
| 86 | } |
---|
| 87 | return str; |
---|
| 88 | } |
---|
| 89 | |
---|
[219] | 90 | //--------------------------------------------------------------- |
---|
| 91 | |
---|
[1158] | 92 | /* |
---|
| 93 | Clear an attribute and reset its value |
---|
| 94 | \param[in] key id of attribute |
---|
| 95 | */ |
---|
[509] | 96 | void CAttributeMap::clearAttribute(const StdString& key) |
---|
| 97 | { |
---|
| 98 | if (hasAttribute(key)) this->find(key)->second->reset(); |
---|
| 99 | } |
---|
| 100 | |
---|
[219] | 101 | //--------------------------------------------------------------- |
---|
[509] | 102 | |
---|
[1158] | 103 | /*! |
---|
| 104 | Set an attribute of certain id with a value |
---|
| 105 | \param[in] key id of the attribute |
---|
| 106 | \param[in] attr value of attribute |
---|
| 107 | */ |
---|
[581] | 108 | void CAttributeMap::setAttribute(const StdString& key, CAttribute* const attr) |
---|
[219] | 109 | { |
---|
| 110 | if (!this->hasAttribute(key)) |
---|
| 111 | ERROR("CAttributeMap::setAttribute(key, attr)", |
---|
| 112 | << "[ key = " << key << "] key not found !"); |
---|
| 113 | if (attr == NULL) |
---|
| 114 | ERROR("CAttributeMap::setAttribute(key, attr)", |
---|
| 115 | << "[ key = " << key << "] attr is null !"); |
---|
[581] | 116 | this->find(key)->second->set(*attr); |
---|
| 117 | // this->find(key)->second->setAnyValue(attr->getAnyValue()); |
---|
[219] | 118 | } |
---|
[509] | 119 | |
---|
[219] | 120 | //--------------------------------------------------------------- |
---|
[509] | 121 | |
---|
[1158] | 122 | /*! |
---|
| 123 | Subscript operator. Return attribute with a specific id |
---|
| 124 | */ |
---|
[581] | 125 | CAttribute* CAttributeMap::operator[](const StdString& key) |
---|
[219] | 126 | { |
---|
| 127 | if (!this->hasAttribute(key)) |
---|
[581] | 128 | ERROR("CAttributeMap::operator[](const StdString& key)", |
---|
[219] | 129 | << "[ key = " << key << "] key not found !"); |
---|
[581] | 130 | return SuperClassMap::operator[](key); |
---|
[219] | 131 | } |
---|
[509] | 132 | |
---|
[219] | 133 | //--------------------------------------------------------------- |
---|
[509] | 134 | |
---|
[219] | 135 | StdString CAttributeMap::toString(void) const |
---|
| 136 | { |
---|
| 137 | typedef std::pair<StdString, CAttribute*> StdStrAttPair; |
---|
| 138 | StdOStringStream oss; |
---|
[509] | 139 | |
---|
[219] | 140 | SuperClassMap::const_iterator it = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
| 141 | for (; it != end; it++) |
---|
| 142 | { |
---|
[581] | 143 | const StdStrAttPair& att = *it; |
---|
[219] | 144 | if (!att.second->isEmpty()) |
---|
| 145 | oss << *att.second << " "; |
---|
| 146 | } |
---|
[581] | 147 | return oss.str(); |
---|
[219] | 148 | } |
---|
[509] | 149 | |
---|
[219] | 150 | //--------------------------------------------------------------- |
---|
[509] | 151 | |
---|
[581] | 152 | void CAttributeMap::fromString(const StdString& str) |
---|
[509] | 153 | { |
---|
[581] | 154 | ERROR("CAttributeMap::fromString(const StdString& str)", |
---|
[509] | 155 | << "[ str = " << str << "] Not implemented yet !"); |
---|
[219] | 156 | } |
---|
[509] | 157 | |
---|
[219] | 158 | //--------------------------------------------------------------- |
---|
| 159 | |
---|
[581] | 160 | //StdOStream& operator << (StdOStream& os, const CAttributeMap& attributmap) |
---|
[219] | 161 | //{ os << attributmap.toString(); return (os); } |
---|
[509] | 162 | |
---|
[219] | 163 | //--------------------------------------------------------------- |
---|
[509] | 164 | |
---|
[581] | 165 | void CAttributeMap::setAttributes(const xml::THashAttributes& attributes) |
---|
[219] | 166 | { |
---|
| 167 | for (xml::THashAttributes::const_iterator it = attributes.begin(); |
---|
| 168 | it != attributes.end(); |
---|
[581] | 169 | it++) |
---|
[278] | 170 | { |
---|
[581] | 171 | if ((*it).first.compare(StdString("id")) != 0 && (*it).first.compare(StdString("src")) != 0) |
---|
[219] | 172 | { |
---|
| 173 | //if (CAttributeMap::operator[]((*it).first)->isEmpty()) |
---|
| 174 | CAttributeMap::operator[]((*it).first)->fromString((*it).second); |
---|
| 175 | } |
---|
[278] | 176 | } |
---|
[219] | 177 | } |
---|
[509] | 178 | |
---|
[1158] | 179 | /*! |
---|
| 180 | Compare two attribute maps |
---|
| 181 | \param [in] another attribute map to compare |
---|
| 182 | \param [in] excludedAttrs attribute to be excluded from comparasion |
---|
| 183 | \return true if these two maps have same attributes whose value are identical |
---|
| 184 | */ |
---|
| 185 | bool CAttributeMap::isEqual(const CAttributeMap& another, const vector<StdString>& excludedAttrs) |
---|
| 186 | { |
---|
| 187 | SuperClassMap::const_iterator itb = another.begin(), ite = another.end(), it; |
---|
| 188 | for (it = itb; it !=ite; ++it) |
---|
| 189 | { |
---|
| 190 | bool excluded = false; |
---|
| 191 | for (int idx = 0; idx < excludedAttrs.size(); ++idx) |
---|
| 192 | { |
---|
| 193 | if (0 == (*it).first.compare(excludedAttrs[idx])) |
---|
| 194 | { |
---|
| 195 | excluded = true; |
---|
| 196 | break; |
---|
| 197 | } |
---|
| 198 | } |
---|
| 199 | |
---|
| 200 | if (!excluded) |
---|
| 201 | { |
---|
| 202 | if ((*it).first.compare(StdString("id")) != 0 && (*it).first.compare(StdString("src")) != 0) |
---|
| 203 | { |
---|
| 204 | if (this->hasAttribute(it->first)) |
---|
| 205 | { |
---|
| 206 | if (!((*it).second->isEqual(*(*this)[it->first]))) |
---|
| 207 | { |
---|
| 208 | return false; |
---|
| 209 | } |
---|
| 210 | } |
---|
| 211 | else |
---|
| 212 | return false; |
---|
| 213 | } |
---|
| 214 | } |
---|
| 215 | } |
---|
| 216 | |
---|
| 217 | return true; |
---|
| 218 | } |
---|
| 219 | |
---|
| 220 | |
---|
[219] | 221 | //--------------------------------------------------------------- |
---|
[509] | 222 | |
---|
| 223 | /*! |
---|
| 224 | \brief Set attributes from a specific attributemap, considered parent. |
---|
| 225 | The child attribute map will insert the attributes of its parent into its current attribute map. |
---|
| 226 | The existing attributes can be filled with the values of the parent map if they are empty or |
---|
| 227 | simply replaced by these values depending on choice of user. |
---|
| 228 | \param [in] _parent Attribute map from which the current map gets attributes. |
---|
| 229 | \param [in] apply Specify if current attribute map is replaced by the attributes of parent (false) |
---|
| 230 | or filled in in case of emptyp (true) |
---|
| 231 | */ |
---|
[581] | 232 | void CAttributeMap::setAttributes(const CAttributeMap* const _parent, bool apply) |
---|
[219] | 233 | { |
---|
| 234 | typedef std::pair<StdString, CAttribute*> StdStrAttPair; |
---|
[509] | 235 | |
---|
[219] | 236 | SuperClassMap::const_iterator it = _parent->begin(), end = _parent->end(); |
---|
| 237 | for (; it != end; it++) |
---|
| 238 | { |
---|
[581] | 239 | const StdStrAttPair& el = *it; |
---|
[219] | 240 | if (this->hasAttribute(el.first)) |
---|
| 241 | { |
---|
[581] | 242 | CAttribute* currentAtt = CAttributeMap::operator[](el.first); |
---|
| 243 | CAttribute* parentAtt = el.second; |
---|
[445] | 244 | if (apply) |
---|
[219] | 245 | { |
---|
[1158] | 246 | if (currentAtt->isEmpty() && currentAtt->canInherite() && !el.second->isEmpty()) |
---|
[445] | 247 | { |
---|
| 248 | this->setAttribute(el.first, el.second); |
---|
| 249 | } |
---|
[219] | 250 | } |
---|
[581] | 251 | else currentAtt->setInheritedValue(*parentAtt); |
---|
[219] | 252 | } |
---|
| 253 | } |
---|
| 254 | } |
---|
[509] | 255 | |
---|
[1158] | 256 | /*! |
---|
| 257 | Duplicate attribute map with a specific attribute map. |
---|
| 258 | Copy all non-empty attribute of the current attribute map |
---|
| 259 | \param [in] srcAttr attribute map which is copied from. |
---|
| 260 | */ |
---|
[623] | 261 | void CAttributeMap::duplicateAttributes(const CAttributeMap* const srcAttr) |
---|
| 262 | { |
---|
| 263 | typedef std::pair<StdString, CAttribute*> StdStrAttPair; |
---|
| 264 | |
---|
| 265 | SuperClassMap::const_iterator it = srcAttr->begin(), end = srcAttr->end(); |
---|
| 266 | for (; it != end; it++) |
---|
| 267 | { |
---|
| 268 | const StdStrAttPair& el = *it; |
---|
| 269 | if (this->hasAttribute(el.first)) |
---|
| 270 | { |
---|
| 271 | if (!el.second->isEmpty()) |
---|
| 272 | { |
---|
| 273 | this->setAttribute(el.first, el.second); |
---|
| 274 | } |
---|
| 275 | } |
---|
| 276 | } |
---|
| 277 | } |
---|
| 278 | |
---|
[219] | 279 | //--------------------------------------------------------------- |
---|
[509] | 280 | /* |
---|
[581] | 281 | void CAttributeMap::toBinary(StdOStream& os) const |
---|
[219] | 282 | { |
---|
| 283 | typedef std::pair<StdString, CAttribute*> StdStrAttPair; |
---|
| 284 | SuperClassMap::const_iterator it = this->begin(), end = this->end(); |
---|
[509] | 285 | |
---|
[219] | 286 | const StdSize nbatt = SuperClassMap::size(); |
---|
| 287 | os.write (reinterpret_cast<const char*>(&nbatt) , sizeof(StdSize)); |
---|
[509] | 288 | |
---|
[219] | 289 | for (; it != end; it++) |
---|
| 290 | { |
---|
[581] | 291 | const StdString& key = it->first; |
---|
[509] | 292 | const CAttribute* value = it->second; |
---|
[219] | 293 | const StdSize size = key.size(); |
---|
[509] | 294 | |
---|
[219] | 295 | os.write (reinterpret_cast<const char*>(&size) , sizeof(StdSize)); |
---|
[581] | 296 | os.write (key.data(), size* sizeof(char)); |
---|
[509] | 297 | |
---|
[219] | 298 | if (!value->isEmpty()) |
---|
| 299 | { |
---|
| 300 | bool b = true; |
---|
| 301 | os.write (reinterpret_cast<const char*>(&b) , sizeof(bool)); |
---|
| 302 | value->toBinary(os); |
---|
| 303 | } |
---|
[509] | 304 | else |
---|
[219] | 305 | { |
---|
| 306 | bool b = false; |
---|
| 307 | os.write (reinterpret_cast<const char*>(&b) , sizeof(bool)); |
---|
| 308 | } |
---|
| 309 | } |
---|
| 310 | } |
---|
[509] | 311 | |
---|
[219] | 312 | //--------------------------------------------------------------- |
---|
[509] | 313 | |
---|
[581] | 314 | void CAttributeMap::fromBinary(StdIStream& is) |
---|
[219] | 315 | { |
---|
| 316 | StdSize nbatt = 0; |
---|
| 317 | is.read (reinterpret_cast<char*>(&nbatt), sizeof(StdSize)); |
---|
[509] | 318 | |
---|
[219] | 319 | for (StdSize i = 0; i < nbatt; i++) |
---|
| 320 | { |
---|
| 321 | bool hasValue = false; |
---|
| 322 | StdSize size = 0; |
---|
| 323 | is.read (reinterpret_cast<char*>(&size), sizeof(StdSize)); |
---|
| 324 | StdString key(size, ' '); |
---|
[581] | 325 | is.read (const_cast<char *>(key.data()), size* sizeof(char)); |
---|
[509] | 326 | |
---|
[219] | 327 | if (!this->hasAttribute(key)) |
---|
[581] | 328 | ERROR("CAttributeMap::fromBinary(StdIStream& is)", |
---|
[219] | 329 | << "[ key = " << key << "] key not found !"); |
---|
[509] | 330 | |
---|
[219] | 331 | is.read (reinterpret_cast<char*>(&hasValue), sizeof(bool)); |
---|
[509] | 332 | |
---|
| 333 | if (hasValue) |
---|
[219] | 334 | this->operator[](key)->fromBinary(is); |
---|
| 335 | } |
---|
| 336 | } |
---|
[509] | 337 | */ |
---|
[1158] | 338 | |
---|
[313] | 339 | void CAttributeMap::generateCInterface(ostream& oss, const string& className) |
---|
| 340 | { |
---|
| 341 | SuperClassMap::const_iterator it = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
| 342 | for (; it != end; it++) |
---|
| 343 | { |
---|
[778] | 344 | if (it->second->isPublic()) |
---|
| 345 | { |
---|
| 346 | oss << std::endl << iendl; |
---|
| 347 | it->second->generateCInterface(oss, className); |
---|
| 348 | oss << iendl; |
---|
| 349 | it->second->generateCInterfaceIsDefined(oss, className); |
---|
| 350 | } |
---|
[313] | 351 | } |
---|
| 352 | } |
---|
| 353 | |
---|
| 354 | void CAttributeMap::generateFortran2003Interface(ostream& oss, const string& className) |
---|
| 355 | { |
---|
| 356 | SuperClassMap::const_iterator it = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
| 357 | for (; it != end; it++) |
---|
| 358 | { |
---|
[778] | 359 | if (it->second->isPublic()) |
---|
| 360 | { |
---|
| 361 | oss << std::endl << iendl; |
---|
| 362 | it->second->generateFortran2003Interface(oss, className); |
---|
| 363 | oss << iendl; |
---|
| 364 | it->second->generateFortran2003InterfaceIsDefined(oss, className); |
---|
| 365 | } |
---|
[313] | 366 | } |
---|
[509] | 367 | } |
---|
| 368 | |
---|
[219] | 369 | ///-------------------------------------------------------------- |
---|
| 370 | |
---|
[313] | 371 | void CAttributeMap::generateFortranInterface_hdl_(ostream& oss, const string& className) |
---|
| 372 | { |
---|
[581] | 373 | oss << "SUBROUTINE xios(set_" << className << "_attr_hdl_) &" << iendl++; |
---|
| 374 | SuperClassMap::const_iterator it; |
---|
[313] | 375 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 376 | |
---|
[649] | 377 | long startPos = oss.tellp(); |
---|
[509] | 378 | |
---|
[649] | 379 | oss << "( " << className << "_hdl"; |
---|
[581] | 380 | for (it = begin; it != end; it++) |
---|
[313] | 381 | { |
---|
[778] | 382 | if (it->second->isPublic()) |
---|
[313] | 383 | { |
---|
[778] | 384 | oss << ", " << it->second->getName() << "_"; |
---|
| 385 | if (oss.tellp() - startPos > 90) |
---|
| 386 | { |
---|
| 387 | oss << " &" << iendl; |
---|
| 388 | startPos = oss.tellp(); |
---|
| 389 | } |
---|
[313] | 390 | } |
---|
| 391 | } |
---|
[649] | 392 | oss << " )"; |
---|
| 393 | oss << std::endl; |
---|
[581] | 394 | oss << iendl; |
---|
[509] | 395 | |
---|
[581] | 396 | oss << "IMPLICIT NONE" << iendl++; |
---|
| 397 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
[509] | 398 | |
---|
[581] | 399 | for (it = begin; it != end; it++) |
---|
[313] | 400 | { |
---|
[778] | 401 | if (it->second->isPublic()) |
---|
| 402 | { |
---|
| 403 | oss << iendl; |
---|
| 404 | it->second->generateFortranInterfaceDeclaration_(oss, className); |
---|
| 405 | } |
---|
[313] | 406 | } |
---|
[509] | 407 | |
---|
[581] | 408 | for (it = begin; it != end; it++) |
---|
[313] | 409 | { |
---|
[778] | 410 | if (it->second->isPublic()) |
---|
| 411 | { |
---|
| 412 | oss << std::endl << iendl; |
---|
| 413 | it->second->generateFortranInterfaceBody_(oss, className); |
---|
| 414 | } |
---|
[313] | 415 | } |
---|
[509] | 416 | |
---|
[581] | 417 | oss << std::endl << (iendl -= 2); |
---|
| 418 | oss << "END SUBROUTINE xios(set_" << className << "_attr_hdl_)" << std::endl; |
---|
[509] | 419 | } |
---|
| 420 | |
---|
[313] | 421 | void CAttributeMap::generateFortranInterfaceGet_hdl_(ostream& oss, const string& className) |
---|
| 422 | { |
---|
[581] | 423 | oss << "SUBROUTINE xios(get_" << className << "_attr_hdl_) &" << iendl++; |
---|
| 424 | SuperClassMap::const_iterator it; |
---|
[313] | 425 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 426 | |
---|
[649] | 427 | long startPos = oss.tellp(); |
---|
[509] | 428 | |
---|
[649] | 429 | oss << "( " << className << "_hdl"; |
---|
[581] | 430 | for (it = begin; it != end; it++) |
---|
[313] | 431 | { |
---|
[778] | 432 | if (it->second->isPublic()) |
---|
[313] | 433 | { |
---|
[778] | 434 | oss << ", " << it->second->getName() << "_"; |
---|
| 435 | if (oss.tellp() - startPos > 90) |
---|
| 436 | { |
---|
| 437 | oss << " &" << iendl; |
---|
| 438 | startPos = oss.tellp(); |
---|
| 439 | } |
---|
[313] | 440 | } |
---|
| 441 | } |
---|
[649] | 442 | oss << " )"; |
---|
| 443 | oss << std::endl; |
---|
[581] | 444 | oss << iendl; |
---|
[509] | 445 | |
---|
[581] | 446 | oss << "IMPLICIT NONE" << iendl++; |
---|
| 447 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
[509] | 448 | |
---|
[581] | 449 | for (it = begin; it != end; it++) |
---|
[313] | 450 | { |
---|
[778] | 451 | if (it->second->isPublic()) |
---|
| 452 | { |
---|
| 453 | oss << iendl; |
---|
| 454 | it->second->generateFortranInterfaceGetDeclaration_(oss, className); |
---|
| 455 | } |
---|
[313] | 456 | } |
---|
[509] | 457 | |
---|
[581] | 458 | for (it = begin; it != end; it++) |
---|
[313] | 459 | { |
---|
[778] | 460 | if (it->second->isPublic()) |
---|
| 461 | { |
---|
| 462 | oss << std::endl << iendl; |
---|
| 463 | it->second->generateFortranInterfaceGetBody_(oss, className); |
---|
| 464 | } |
---|
[313] | 465 | } |
---|
[509] | 466 | |
---|
[581] | 467 | oss << std::endl << (iendl -= 2); |
---|
| 468 | oss << "END SUBROUTINE xios(get_" << className << "_attr_hdl_)" << std::endl; |
---|
[509] | 469 | } |
---|
| 470 | |
---|
[432] | 471 | void CAttributeMap::generateFortranInterfaceIsDefined_hdl_(ostream& oss, const string& className) |
---|
| 472 | { |
---|
[581] | 473 | oss << "SUBROUTINE xios(is_defined_" << className << "_attr_hdl_) &" << iendl++; |
---|
| 474 | SuperClassMap::const_iterator it; |
---|
[432] | 475 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 476 | |
---|
[649] | 477 | long startPos = oss.tellp(); |
---|
[509] | 478 | |
---|
[649] | 479 | oss << "( " << className << "_hdl"; |
---|
[581] | 480 | for (it = begin; it != end; it++) |
---|
[432] | 481 | { |
---|
[778] | 482 | if (it->second->isPublic()) |
---|
[432] | 483 | { |
---|
[778] | 484 | oss << ", " << it->second->getName() << "_"; |
---|
| 485 | if (oss.tellp() - startPos > 90) |
---|
| 486 | { |
---|
| 487 | oss << " &" << iendl; |
---|
| 488 | startPos = oss.tellp(); |
---|
| 489 | } |
---|
[432] | 490 | } |
---|
| 491 | } |
---|
[649] | 492 | oss << " )"; |
---|
| 493 | oss << std::endl; |
---|
[581] | 494 | oss << iendl; |
---|
[509] | 495 | |
---|
[581] | 496 | oss << "IMPLICIT NONE" << iendl++; |
---|
| 497 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
[509] | 498 | |
---|
[581] | 499 | for (it = begin; it != end; it++) |
---|
[432] | 500 | { |
---|
[778] | 501 | if (it->second->isPublic()) |
---|
| 502 | { |
---|
| 503 | oss << iendl; |
---|
| 504 | it->second->generateFortranInterfaceIsDefinedDeclaration_(oss, className); |
---|
| 505 | } |
---|
[432] | 506 | } |
---|
[509] | 507 | |
---|
[581] | 508 | for (it = begin; it != end; it++) |
---|
[432] | 509 | { |
---|
[778] | 510 | if (it->second->isPublic()) |
---|
| 511 | { |
---|
| 512 | oss << std::endl << iendl; |
---|
| 513 | it->second->generateFortranInterfaceIsDefinedBody_(oss, className); |
---|
| 514 | } |
---|
[432] | 515 | } |
---|
[509] | 516 | |
---|
[581] | 517 | oss << std::endl << (iendl -= 2); |
---|
| 518 | oss << "END SUBROUTINE xios(is_defined_" << className << "_attr_hdl_)" << std::endl; |
---|
[509] | 519 | } |
---|
| 520 | |
---|
[313] | 521 | void CAttributeMap::generateFortranInterface_hdl(ostream& oss, const string& className) |
---|
| 522 | { |
---|
[581] | 523 | oss << "SUBROUTINE xios(set_" << className << "_attr_hdl) &" << iendl++; |
---|
| 524 | SuperClassMap::const_iterator it; |
---|
[313] | 525 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 526 | |
---|
[649] | 527 | long startPos = oss.tellp(); |
---|
| 528 | |
---|
| 529 | oss << "( " << className << "_hdl"; |
---|
[581] | 530 | for (it = begin; it != end; it++) |
---|
[313] | 531 | { |
---|
[778] | 532 | if (it->second->isPublic()) |
---|
[313] | 533 | { |
---|
[778] | 534 | oss << ", " << it->second->getName(); |
---|
| 535 | if (oss.tellp() - startPos > 90) |
---|
| 536 | { |
---|
| 537 | oss << " &" << iendl; |
---|
| 538 | startPos = oss.tellp(); |
---|
| 539 | } |
---|
[313] | 540 | } |
---|
| 541 | } |
---|
[649] | 542 | oss << " )"; |
---|
| 543 | oss << std::endl; |
---|
[581] | 544 | oss << iendl; |
---|
[509] | 545 | |
---|
[581] | 546 | oss << "IMPLICIT NONE" << iendl++; |
---|
| 547 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
[509] | 548 | |
---|
[581] | 549 | for (it = begin; it != end; it++) |
---|
[313] | 550 | { |
---|
[778] | 551 | if (it->second->isPublic()) |
---|
| 552 | { |
---|
| 553 | oss << iendl; |
---|
| 554 | it->second->generateFortranInterfaceDeclaration(oss, className); |
---|
| 555 | } |
---|
[313] | 556 | } |
---|
[509] | 557 | |
---|
[581] | 558 | oss << std::endl << iendl; |
---|
[509] | 559 | |
---|
[581] | 560 | oss << "CALL xios(set_" << className << "_attr_hdl_) &" << iendl; |
---|
[509] | 561 | |
---|
[649] | 562 | startPos = oss.tellp(); |
---|
| 563 | |
---|
| 564 | oss << "( " << className << "_hdl"; |
---|
[581] | 565 | for (it = begin; it != end; it++) |
---|
[313] | 566 | { |
---|
[778] | 567 | if (it->second->isPublic()) |
---|
[313] | 568 | { |
---|
[778] | 569 | oss << ", " << it->second->getName(); |
---|
| 570 | if (oss.tellp() - startPos > 90) |
---|
| 571 | { |
---|
| 572 | oss << " &" << iendl; |
---|
| 573 | startPos = oss.tellp(); |
---|
| 574 | } |
---|
[313] | 575 | } |
---|
| 576 | } |
---|
[649] | 577 | oss << " )"; |
---|
[509] | 578 | |
---|
[581] | 579 | oss << std::endl << (iendl -= 2); |
---|
| 580 | oss << "END SUBROUTINE xios(set_" << className << "_attr_hdl)" << std::endl; |
---|
[509] | 581 | } |
---|
| 582 | |
---|
[313] | 583 | void CAttributeMap::generateFortranInterfaceGet_hdl(ostream& oss, const string& className) |
---|
| 584 | { |
---|
[581] | 585 | oss << "SUBROUTINE xios(get_" << className << "_attr_hdl) &" << iendl++; |
---|
| 586 | SuperClassMap::const_iterator it; |
---|
[313] | 587 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 588 | |
---|
[649] | 589 | long startPos = oss.tellp(); |
---|
| 590 | |
---|
| 591 | oss << "( " << className << "_hdl"; |
---|
[581] | 592 | for (it = begin; it != end; it++) |
---|
[313] | 593 | { |
---|
[778] | 594 | if (it->second->isPublic()) |
---|
[313] | 595 | { |
---|
[778] | 596 | oss << ", " << it->second->getName(); |
---|
| 597 | if (oss.tellp() - startPos > 90) |
---|
| 598 | { |
---|
| 599 | oss << " &" << iendl; |
---|
| 600 | startPos = oss.tellp(); |
---|
| 601 | } |
---|
[313] | 602 | } |
---|
| 603 | } |
---|
[649] | 604 | oss << " )"; |
---|
| 605 | oss << std::endl; |
---|
[581] | 606 | oss << iendl; |
---|
[509] | 607 | |
---|
[581] | 608 | oss << "IMPLICIT NONE" << iendl++; |
---|
| 609 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
[509] | 610 | |
---|
[581] | 611 | for (it = begin; it != end; it++) |
---|
[313] | 612 | { |
---|
[778] | 613 | if (it->second->isPublic()) |
---|
| 614 | { |
---|
| 615 | oss << iendl; |
---|
| 616 | it->second->generateFortranInterfaceGetDeclaration(oss, className); |
---|
| 617 | } |
---|
[313] | 618 | } |
---|
[509] | 619 | |
---|
[581] | 620 | oss << std::endl << iendl; |
---|
[509] | 621 | |
---|
[581] | 622 | oss << "CALL xios(get_" << className << "_attr_hdl_) &" << iendl; |
---|
[509] | 623 | |
---|
[649] | 624 | startPos = oss.tellp(); |
---|
| 625 | |
---|
| 626 | oss << "( " << className << "_hdl"; |
---|
[581] | 627 | for (it = begin; it != end; it++) |
---|
[313] | 628 | { |
---|
[778] | 629 | if (it->second->isPublic()) |
---|
[313] | 630 | { |
---|
[778] | 631 | oss << ", " << it->second->getName(); |
---|
| 632 | if (oss.tellp() - startPos > 90) |
---|
| 633 | { |
---|
| 634 | oss << " &" << iendl; |
---|
| 635 | startPos = oss.tellp(); |
---|
| 636 | } |
---|
[313] | 637 | } |
---|
| 638 | } |
---|
[649] | 639 | oss << " )"; |
---|
[509] | 640 | |
---|
[581] | 641 | oss << std::endl << (iendl -= 2); |
---|
| 642 | oss << "END SUBROUTINE xios(get_" << className << "_attr_hdl)" << std::endl; |
---|
[509] | 643 | } |
---|
[432] | 644 | |
---|
| 645 | void CAttributeMap::generateFortranInterfaceIsDefined_hdl(ostream& oss, const string& className) |
---|
| 646 | { |
---|
[581] | 647 | oss << "SUBROUTINE xios(is_defined_" << className << "_attr_hdl) &" << iendl++; |
---|
| 648 | SuperClassMap::const_iterator it; |
---|
[432] | 649 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 650 | |
---|
[649] | 651 | long startPos = oss.tellp(); |
---|
| 652 | |
---|
| 653 | oss << "( " << className << "_hdl"; |
---|
[581] | 654 | for (it = begin; it != end; it++) |
---|
[432] | 655 | { |
---|
[778] | 656 | if (it->second->isPublic()) |
---|
[432] | 657 | { |
---|
[778] | 658 | oss << ", " << it->second->getName(); |
---|
| 659 | if (oss.tellp() - startPos > 90) |
---|
| 660 | { |
---|
| 661 | oss << " &" << iendl; |
---|
| 662 | startPos = oss.tellp(); |
---|
| 663 | } |
---|
[432] | 664 | } |
---|
| 665 | } |
---|
[649] | 666 | oss << " )"; |
---|
| 667 | oss << std::endl; |
---|
[581] | 668 | oss << iendl; |
---|
[509] | 669 | |
---|
[581] | 670 | oss << "IMPLICIT NONE" << iendl++; |
---|
| 671 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
[509] | 672 | |
---|
[581] | 673 | for (it = begin; it != end; it++) |
---|
[432] | 674 | { |
---|
[778] | 675 | if (it->second->isPublic()) |
---|
| 676 | { |
---|
| 677 | oss << iendl; |
---|
| 678 | it->second->generateFortranInterfaceIsDefinedDeclaration(oss, className); |
---|
| 679 | } |
---|
[432] | 680 | } |
---|
[509] | 681 | |
---|
[581] | 682 | oss << std::endl << iendl; |
---|
[509] | 683 | |
---|
[581] | 684 | oss << "CALL xios(is_defined_" << className << "_attr_hdl_) &" << iendl; |
---|
[509] | 685 | |
---|
[649] | 686 | startPos = oss.tellp(); |
---|
| 687 | |
---|
| 688 | oss << "( " << className << "_hdl"; |
---|
[581] | 689 | for (it = begin; it != end; it++) |
---|
[432] | 690 | { |
---|
[778] | 691 | if (it->second->isPublic()) |
---|
[432] | 692 | { |
---|
[778] | 693 | oss << ", " << it->second->getName(); |
---|
| 694 | if (oss.tellp() - startPos > 90) |
---|
| 695 | { |
---|
| 696 | oss << " &" << iendl; |
---|
| 697 | startPos = oss.tellp(); |
---|
| 698 | } |
---|
[432] | 699 | } |
---|
| 700 | } |
---|
[649] | 701 | oss << " )"; |
---|
[509] | 702 | |
---|
[581] | 703 | oss << std::endl << (iendl -= 2); |
---|
| 704 | oss << "END SUBROUTINE xios(is_defined_" << className << "_attr_hdl)" << std::endl; |
---|
[509] | 705 | } |
---|
[432] | 706 | |
---|
[313] | 707 | void CAttributeMap::generateFortranInterface_id(ostream& oss, const string& className) |
---|
| 708 | { |
---|
[581] | 709 | oss << "SUBROUTINE xios(set_" << className << "_attr) &" << iendl++; |
---|
| 710 | SuperClassMap::const_iterator it; |
---|
[313] | 711 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 712 | |
---|
[649] | 713 | long startPos = oss.tellp(); |
---|
| 714 | |
---|
| 715 | oss << "( " << className << "_id"; |
---|
[581] | 716 | for (it = begin; it != end; it++) |
---|
[313] | 717 | { |
---|
[778] | 718 | if (it->second->isPublic()) |
---|
[313] | 719 | { |
---|
[778] | 720 | oss << ", " << it->second->getName(); |
---|
| 721 | if (oss.tellp() - startPos > 90) |
---|
| 722 | { |
---|
| 723 | oss << " &" << iendl; |
---|
| 724 | startPos = oss.tellp(); |
---|
| 725 | } |
---|
[313] | 726 | } |
---|
| 727 | } |
---|
[649] | 728 | oss << " )"; |
---|
| 729 | oss << std::endl; |
---|
[581] | 730 | oss << iendl; |
---|
[509] | 731 | |
---|
[581] | 732 | oss << "IMPLICIT NONE" << iendl++; |
---|
[313] | 733 | |
---|
[581] | 734 | oss << "TYPE(txios(" << className << ")) :: " << className << "_hdl" << iendl; |
---|
| 735 | oss << "CHARACTER(LEN=*), INTENT(IN) ::" << className << "_id"; |
---|
[509] | 736 | |
---|
[581] | 737 | for (it = begin; it != end; it++) |
---|
[313] | 738 | { |
---|
[778] | 739 | if (it->second->isPublic()) |
---|
| 740 | { |
---|
| 741 | oss << iendl; |
---|
| 742 | it->second->generateFortranInterfaceDeclaration(oss, className); |
---|
| 743 | } |
---|
[313] | 744 | } |
---|
[509] | 745 | |
---|
[581] | 746 | oss << std::endl << iendl; |
---|
[966] | 747 | oss << "CALL xios(get_" << className << "_handle) &" << iendl; |
---|
| 748 | oss << "(" << className << "_id," << className << "_hdl)" << iendl; |
---|
[581] | 749 | oss << "CALL xios(set_" << className << "_attr_hdl_) &" << iendl; |
---|
[649] | 750 | |
---|
| 751 | startPos = oss.tellp(); |
---|
| 752 | |
---|
| 753 | oss << "( " << className << "_hdl"; |
---|
[581] | 754 | for (it = begin; it != end; it++) |
---|
[313] | 755 | { |
---|
[778] | 756 | if (it->second->isPublic()) |
---|
[313] | 757 | { |
---|
[778] | 758 | oss << ", " << it->second->getName(); |
---|
| 759 | if (oss.tellp() - startPos > 90) |
---|
| 760 | { |
---|
| 761 | oss << " &" << iendl; |
---|
| 762 | startPos = oss.tellp(); |
---|
| 763 | } |
---|
[313] | 764 | } |
---|
| 765 | } |
---|
[649] | 766 | oss << " )"; |
---|
[509] | 767 | |
---|
[581] | 768 | oss << std::endl << (iendl -= 2); |
---|
| 769 | oss << "END SUBROUTINE xios(set_" << className << "_attr)" << std::endl; |
---|
[509] | 770 | } |
---|
| 771 | |
---|
[313] | 772 | void CAttributeMap::generateFortranInterfaceGet_id(ostream& oss, const string& className) |
---|
| 773 | { |
---|
[581] | 774 | oss << "SUBROUTINE xios(get_" << className << "_attr) &" << iendl++; |
---|
| 775 | SuperClassMap::const_iterator it; |
---|
[313] | 776 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 777 | |
---|
[649] | 778 | long startPos = oss.tellp(); |
---|
| 779 | |
---|
| 780 | oss << "( " << className << "_id"; |
---|
[581] | 781 | for (it = begin; it != end; it++) |
---|
[313] | 782 | { |
---|
[778] | 783 | if (it->second->isPublic()) |
---|
[313] | 784 | { |
---|
[778] | 785 | oss << ", " << it->second->getName(); |
---|
| 786 | if (oss.tellp() - startPos > 90) |
---|
| 787 | { |
---|
| 788 | oss << " &" << iendl; |
---|
| 789 | startPos = oss.tellp(); |
---|
| 790 | } |
---|
[313] | 791 | } |
---|
| 792 | } |
---|
[649] | 793 | oss << " )"; |
---|
| 794 | oss << std::endl; |
---|
[581] | 795 | oss << iendl; |
---|
[509] | 796 | |
---|
[581] | 797 | oss << "IMPLICIT NONE" << iendl++; |
---|
[313] | 798 | |
---|
[581] | 799 | oss << "TYPE(txios(" << className << ")) :: " << className << "_hdl" << iendl; |
---|
| 800 | oss << "CHARACTER(LEN=*), INTENT(IN) ::" << className << "_id"; |
---|
[509] | 801 | |
---|
[581] | 802 | for (it = begin; it != end; it++) |
---|
[313] | 803 | { |
---|
[778] | 804 | if (it->second->isPublic()) |
---|
| 805 | { |
---|
| 806 | oss << iendl; |
---|
| 807 | it->second->generateFortranInterfaceGetDeclaration(oss, className); |
---|
| 808 | } |
---|
[313] | 809 | } |
---|
[509] | 810 | |
---|
[581] | 811 | oss << std::endl << iendl; |
---|
[966] | 812 | oss << "CALL xios(get_" << className << "_handle) &" << iendl; |
---|
| 813 | oss << "(" << className << "_id," << className << "_hdl)" << iendl; |
---|
[581] | 814 | oss << "CALL xios(get_" << className << "_attr_hdl_) &" << iendl; |
---|
[649] | 815 | |
---|
| 816 | startPos = oss.tellp(); |
---|
| 817 | |
---|
| 818 | oss << "( " << className << "_hdl"; |
---|
[581] | 819 | for (it = begin; it != end; it++) |
---|
[313] | 820 | { |
---|
[778] | 821 | if (it->second->isPublic()) |
---|
[313] | 822 | { |
---|
[778] | 823 | oss << ", " << it->second->getName(); |
---|
| 824 | if (oss.tellp() - startPos > 90) |
---|
| 825 | { |
---|
| 826 | oss << " &" << iendl; |
---|
| 827 | startPos = oss.tellp(); |
---|
| 828 | } |
---|
[313] | 829 | } |
---|
| 830 | } |
---|
[649] | 831 | oss << " )"; |
---|
[509] | 832 | |
---|
[581] | 833 | oss << std::endl << (iendl -= 2); |
---|
| 834 | oss << "END SUBROUTINE xios(get_" << className << "_attr)" << std::endl; |
---|
[509] | 835 | } |
---|
| 836 | |
---|
[432] | 837 | void CAttributeMap::generateFortranInterfaceIsDefined_id(ostream& oss, const string& className) |
---|
| 838 | { |
---|
[581] | 839 | oss << "SUBROUTINE xios(is_defined_" << className << "_attr) &" << iendl++; |
---|
| 840 | SuperClassMap::const_iterator it; |
---|
[432] | 841 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 842 | |
---|
[649] | 843 | long startPos = oss.tellp(); |
---|
| 844 | |
---|
| 845 | oss << "( " << className << "_id"; |
---|
[581] | 846 | for (it = begin; it != end; it++) |
---|
[432] | 847 | { |
---|
[778] | 848 | if (it->second->isPublic()) |
---|
[432] | 849 | { |
---|
[778] | 850 | oss << ", " << it->second->getName(); |
---|
| 851 | if (oss.tellp() - startPos > 90) |
---|
| 852 | { |
---|
| 853 | oss << " &" << iendl; |
---|
| 854 | startPos = oss.tellp(); |
---|
| 855 | } |
---|
[432] | 856 | } |
---|
| 857 | } |
---|
[649] | 858 | oss << " )"; |
---|
| 859 | oss << std::endl; |
---|
[581] | 860 | oss << iendl; |
---|
[509] | 861 | |
---|
[581] | 862 | oss << "IMPLICIT NONE" << iendl++; |
---|
[432] | 863 | |
---|
[581] | 864 | oss << "TYPE(txios(" << className << ")) :: " << className << "_hdl" << iendl; |
---|
| 865 | oss << "CHARACTER(LEN=*), INTENT(IN) ::" << className << "_id"; |
---|
[509] | 866 | |
---|
[581] | 867 | for (it = begin; it != end; it++) |
---|
[432] | 868 | { |
---|
[778] | 869 | if (it->second->isPublic()) |
---|
| 870 | { |
---|
| 871 | oss << iendl; |
---|
| 872 | it->second->generateFortranInterfaceIsDefinedDeclaration(oss, className); |
---|
| 873 | } |
---|
[432] | 874 | } |
---|
[509] | 875 | |
---|
[581] | 876 | oss << std::endl << iendl; |
---|
[966] | 877 | oss << "CALL xios(get_" << className << "_handle) &" << iendl; |
---|
| 878 | oss << "(" << className << "_id," << className << "_hdl)" << iendl; |
---|
[581] | 879 | oss << "CALL xios(is_defined_" << className << "_attr_hdl_) &" << iendl; |
---|
[649] | 880 | |
---|
| 881 | startPos = oss.tellp(); |
---|
| 882 | |
---|
| 883 | oss << "( " << className << "_hdl"; |
---|
[581] | 884 | for (it = begin; it != end; it++) |
---|
[432] | 885 | { |
---|
[778] | 886 | if (it->second->isPublic()) |
---|
[432] | 887 | { |
---|
[778] | 888 | oss << ", " << it->second->getName(); |
---|
| 889 | if (oss.tellp() - startPos > 90) |
---|
| 890 | { |
---|
| 891 | oss << " &" << iendl; |
---|
| 892 | startPos = oss.tellp(); |
---|
| 893 | } |
---|
[432] | 894 | } |
---|
| 895 | } |
---|
[649] | 896 | oss << " )"; |
---|
[509] | 897 | |
---|
[581] | 898 | oss << std::endl << (iendl -= 2); |
---|
| 899 | oss << "END SUBROUTINE xios(is_defined_" << className << "_attr)" << std::endl; |
---|
[509] | 900 | } |
---|
[591] | 901 | } // namespace xios |
---|