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