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