[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 | |
---|
[219] | 271 | //--------------------------------------------------------------- |
---|
[509] | 272 | /* |
---|
[581] | 273 | void CAttributeMap::toBinary(StdOStream& os) const |
---|
[219] | 274 | { |
---|
| 275 | typedef std::pair<StdString, CAttribute*> StdStrAttPair; |
---|
| 276 | SuperClassMap::const_iterator it = this->begin(), end = this->end(); |
---|
[509] | 277 | |
---|
[219] | 278 | const StdSize nbatt = SuperClassMap::size(); |
---|
| 279 | os.write (reinterpret_cast<const char*>(&nbatt) , sizeof(StdSize)); |
---|
[509] | 280 | |
---|
[219] | 281 | for (; it != end; it++) |
---|
| 282 | { |
---|
[581] | 283 | const StdString& key = it->first; |
---|
[509] | 284 | const CAttribute* value = it->second; |
---|
[219] | 285 | const StdSize size = key.size(); |
---|
[509] | 286 | |
---|
[219] | 287 | os.write (reinterpret_cast<const char*>(&size) , sizeof(StdSize)); |
---|
[581] | 288 | os.write (key.data(), size* sizeof(char)); |
---|
[509] | 289 | |
---|
[219] | 290 | if (!value->isEmpty()) |
---|
| 291 | { |
---|
| 292 | bool b = true; |
---|
| 293 | os.write (reinterpret_cast<const char*>(&b) , sizeof(bool)); |
---|
| 294 | value->toBinary(os); |
---|
| 295 | } |
---|
[509] | 296 | else |
---|
[219] | 297 | { |
---|
| 298 | bool b = false; |
---|
| 299 | os.write (reinterpret_cast<const char*>(&b) , sizeof(bool)); |
---|
| 300 | } |
---|
| 301 | } |
---|
| 302 | } |
---|
[509] | 303 | |
---|
[219] | 304 | //--------------------------------------------------------------- |
---|
[509] | 305 | |
---|
[581] | 306 | void CAttributeMap::fromBinary(StdIStream& is) |
---|
[219] | 307 | { |
---|
| 308 | StdSize nbatt = 0; |
---|
| 309 | is.read (reinterpret_cast<char*>(&nbatt), sizeof(StdSize)); |
---|
[509] | 310 | |
---|
[219] | 311 | for (StdSize i = 0; i < nbatt; i++) |
---|
| 312 | { |
---|
| 313 | bool hasValue = false; |
---|
| 314 | StdSize size = 0; |
---|
| 315 | is.read (reinterpret_cast<char*>(&size), sizeof(StdSize)); |
---|
| 316 | StdString key(size, ' '); |
---|
[581] | 317 | is.read (const_cast<char *>(key.data()), size* sizeof(char)); |
---|
[509] | 318 | |
---|
[219] | 319 | if (!this->hasAttribute(key)) |
---|
[581] | 320 | ERROR("CAttributeMap::fromBinary(StdIStream& is)", |
---|
[219] | 321 | << "[ key = " << key << "] key not found !"); |
---|
[509] | 322 | |
---|
[219] | 323 | is.read (reinterpret_cast<char*>(&hasValue), sizeof(bool)); |
---|
[509] | 324 | |
---|
| 325 | if (hasValue) |
---|
[219] | 326 | this->operator[](key)->fromBinary(is); |
---|
| 327 | } |
---|
| 328 | } |
---|
[509] | 329 | */ |
---|
[1158] | 330 | |
---|
[313] | 331 | void CAttributeMap::generateCInterface(ostream& oss, const string& className) |
---|
| 332 | { |
---|
| 333 | SuperClassMap::const_iterator it = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
| 334 | for (; it != end; it++) |
---|
| 335 | { |
---|
[778] | 336 | if (it->second->isPublic()) |
---|
| 337 | { |
---|
| 338 | oss << std::endl << iendl; |
---|
| 339 | it->second->generateCInterface(oss, className); |
---|
| 340 | oss << iendl; |
---|
| 341 | it->second->generateCInterfaceIsDefined(oss, className); |
---|
| 342 | } |
---|
[313] | 343 | } |
---|
| 344 | } |
---|
| 345 | |
---|
| 346 | void CAttributeMap::generateFortran2003Interface(ostream& oss, const string& className) |
---|
| 347 | { |
---|
| 348 | SuperClassMap::const_iterator it = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
| 349 | for (; it != end; it++) |
---|
| 350 | { |
---|
[778] | 351 | if (it->second->isPublic()) |
---|
| 352 | { |
---|
| 353 | oss << std::endl << iendl; |
---|
| 354 | it->second->generateFortran2003Interface(oss, className); |
---|
| 355 | oss << iendl; |
---|
| 356 | it->second->generateFortran2003InterfaceIsDefined(oss, className); |
---|
| 357 | } |
---|
[313] | 358 | } |
---|
[509] | 359 | } |
---|
| 360 | |
---|
[219] | 361 | ///-------------------------------------------------------------- |
---|
| 362 | |
---|
[313] | 363 | void CAttributeMap::generateFortranInterface_hdl_(ostream& oss, const string& className) |
---|
| 364 | { |
---|
[581] | 365 | oss << "SUBROUTINE xios(set_" << className << "_attr_hdl_) &" << iendl++; |
---|
| 366 | SuperClassMap::const_iterator it; |
---|
[313] | 367 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 368 | |
---|
[649] | 369 | long startPos = oss.tellp(); |
---|
[509] | 370 | |
---|
[649] | 371 | oss << "( " << className << "_hdl"; |
---|
[581] | 372 | for (it = begin; it != end; it++) |
---|
[313] | 373 | { |
---|
[778] | 374 | if (it->second->isPublic()) |
---|
[313] | 375 | { |
---|
[778] | 376 | oss << ", " << it->second->getName() << "_"; |
---|
| 377 | if (oss.tellp() - startPos > 90) |
---|
| 378 | { |
---|
| 379 | oss << " &" << iendl; |
---|
| 380 | startPos = oss.tellp(); |
---|
| 381 | } |
---|
[313] | 382 | } |
---|
| 383 | } |
---|
[649] | 384 | oss << " )"; |
---|
| 385 | oss << std::endl; |
---|
[581] | 386 | oss << iendl; |
---|
[509] | 387 | |
---|
[581] | 388 | oss << "IMPLICIT NONE" << iendl++; |
---|
| 389 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
[509] | 390 | |
---|
[581] | 391 | for (it = begin; it != end; it++) |
---|
[313] | 392 | { |
---|
[778] | 393 | if (it->second->isPublic()) |
---|
| 394 | { |
---|
| 395 | oss << iendl; |
---|
| 396 | it->second->generateFortranInterfaceDeclaration_(oss, className); |
---|
| 397 | } |
---|
[313] | 398 | } |
---|
[509] | 399 | |
---|
[581] | 400 | for (it = begin; it != end; it++) |
---|
[313] | 401 | { |
---|
[778] | 402 | if (it->second->isPublic()) |
---|
| 403 | { |
---|
| 404 | oss << std::endl << iendl; |
---|
| 405 | it->second->generateFortranInterfaceBody_(oss, className); |
---|
| 406 | } |
---|
[313] | 407 | } |
---|
[509] | 408 | |
---|
[581] | 409 | oss << std::endl << (iendl -= 2); |
---|
| 410 | oss << "END SUBROUTINE xios(set_" << className << "_attr_hdl_)" << std::endl; |
---|
[509] | 411 | } |
---|
| 412 | |
---|
[313] | 413 | void CAttributeMap::generateFortranInterfaceGet_hdl_(ostream& oss, const string& className) |
---|
| 414 | { |
---|
[581] | 415 | oss << "SUBROUTINE xios(get_" << className << "_attr_hdl_) &" << iendl++; |
---|
| 416 | SuperClassMap::const_iterator it; |
---|
[313] | 417 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 418 | |
---|
[649] | 419 | long startPos = oss.tellp(); |
---|
[509] | 420 | |
---|
[649] | 421 | oss << "( " << className << "_hdl"; |
---|
[581] | 422 | for (it = begin; it != end; it++) |
---|
[313] | 423 | { |
---|
[778] | 424 | if (it->second->isPublic()) |
---|
[313] | 425 | { |
---|
[778] | 426 | oss << ", " << it->second->getName() << "_"; |
---|
| 427 | if (oss.tellp() - startPos > 90) |
---|
| 428 | { |
---|
| 429 | oss << " &" << iendl; |
---|
| 430 | startPos = oss.tellp(); |
---|
| 431 | } |
---|
[313] | 432 | } |
---|
| 433 | } |
---|
[649] | 434 | oss << " )"; |
---|
| 435 | oss << std::endl; |
---|
[581] | 436 | oss << iendl; |
---|
[509] | 437 | |
---|
[581] | 438 | oss << "IMPLICIT NONE" << iendl++; |
---|
| 439 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
[509] | 440 | |
---|
[581] | 441 | for (it = begin; it != end; it++) |
---|
[313] | 442 | { |
---|
[778] | 443 | if (it->second->isPublic()) |
---|
| 444 | { |
---|
| 445 | oss << iendl; |
---|
| 446 | it->second->generateFortranInterfaceGetDeclaration_(oss, className); |
---|
| 447 | } |
---|
[313] | 448 | } |
---|
[509] | 449 | |
---|
[581] | 450 | for (it = begin; it != end; it++) |
---|
[313] | 451 | { |
---|
[778] | 452 | if (it->second->isPublic()) |
---|
| 453 | { |
---|
| 454 | oss << std::endl << iendl; |
---|
| 455 | it->second->generateFortranInterfaceGetBody_(oss, className); |
---|
| 456 | } |
---|
[313] | 457 | } |
---|
[509] | 458 | |
---|
[581] | 459 | oss << std::endl << (iendl -= 2); |
---|
| 460 | oss << "END SUBROUTINE xios(get_" << className << "_attr_hdl_)" << std::endl; |
---|
[509] | 461 | } |
---|
| 462 | |
---|
[432] | 463 | void CAttributeMap::generateFortranInterfaceIsDefined_hdl_(ostream& oss, const string& className) |
---|
| 464 | { |
---|
[581] | 465 | oss << "SUBROUTINE xios(is_defined_" << className << "_attr_hdl_) &" << iendl++; |
---|
| 466 | SuperClassMap::const_iterator it; |
---|
[432] | 467 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 468 | |
---|
[649] | 469 | long startPos = oss.tellp(); |
---|
[509] | 470 | |
---|
[649] | 471 | oss << "( " << className << "_hdl"; |
---|
[581] | 472 | for (it = begin; it != end; it++) |
---|
[432] | 473 | { |
---|
[778] | 474 | if (it->second->isPublic()) |
---|
[432] | 475 | { |
---|
[778] | 476 | oss << ", " << it->second->getName() << "_"; |
---|
| 477 | if (oss.tellp() - startPos > 90) |
---|
| 478 | { |
---|
| 479 | oss << " &" << iendl; |
---|
| 480 | startPos = oss.tellp(); |
---|
| 481 | } |
---|
[432] | 482 | } |
---|
| 483 | } |
---|
[649] | 484 | oss << " )"; |
---|
| 485 | oss << std::endl; |
---|
[581] | 486 | oss << iendl; |
---|
[509] | 487 | |
---|
[581] | 488 | oss << "IMPLICIT NONE" << iendl++; |
---|
| 489 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
[509] | 490 | |
---|
[581] | 491 | for (it = begin; it != end; it++) |
---|
[432] | 492 | { |
---|
[778] | 493 | if (it->second->isPublic()) |
---|
| 494 | { |
---|
| 495 | oss << iendl; |
---|
| 496 | it->second->generateFortranInterfaceIsDefinedDeclaration_(oss, className); |
---|
| 497 | } |
---|
[432] | 498 | } |
---|
[509] | 499 | |
---|
[581] | 500 | for (it = begin; it != end; it++) |
---|
[432] | 501 | { |
---|
[778] | 502 | if (it->second->isPublic()) |
---|
| 503 | { |
---|
| 504 | oss << std::endl << iendl; |
---|
| 505 | it->second->generateFortranInterfaceIsDefinedBody_(oss, className); |
---|
| 506 | } |
---|
[432] | 507 | } |
---|
[509] | 508 | |
---|
[581] | 509 | oss << std::endl << (iendl -= 2); |
---|
| 510 | oss << "END SUBROUTINE xios(is_defined_" << className << "_attr_hdl_)" << std::endl; |
---|
[509] | 511 | } |
---|
| 512 | |
---|
[313] | 513 | void CAttributeMap::generateFortranInterface_hdl(ostream& oss, const string& className) |
---|
| 514 | { |
---|
[581] | 515 | oss << "SUBROUTINE xios(set_" << className << "_attr_hdl) &" << iendl++; |
---|
| 516 | SuperClassMap::const_iterator it; |
---|
[313] | 517 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 518 | |
---|
[649] | 519 | long startPos = oss.tellp(); |
---|
| 520 | |
---|
| 521 | oss << "( " << className << "_hdl"; |
---|
[581] | 522 | for (it = begin; it != end; it++) |
---|
[313] | 523 | { |
---|
[778] | 524 | if (it->second->isPublic()) |
---|
[313] | 525 | { |
---|
[778] | 526 | oss << ", " << it->second->getName(); |
---|
| 527 | if (oss.tellp() - startPos > 90) |
---|
| 528 | { |
---|
| 529 | oss << " &" << iendl; |
---|
| 530 | startPos = oss.tellp(); |
---|
| 531 | } |
---|
[313] | 532 | } |
---|
| 533 | } |
---|
[649] | 534 | oss << " )"; |
---|
| 535 | oss << std::endl; |
---|
[581] | 536 | oss << iendl; |
---|
[509] | 537 | |
---|
[581] | 538 | oss << "IMPLICIT NONE" << iendl++; |
---|
| 539 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
[509] | 540 | |
---|
[581] | 541 | for (it = begin; it != end; it++) |
---|
[313] | 542 | { |
---|
[778] | 543 | if (it->second->isPublic()) |
---|
| 544 | { |
---|
| 545 | oss << iendl; |
---|
| 546 | it->second->generateFortranInterfaceDeclaration(oss, className); |
---|
| 547 | } |
---|
[313] | 548 | } |
---|
[509] | 549 | |
---|
[581] | 550 | oss << std::endl << iendl; |
---|
[509] | 551 | |
---|
[581] | 552 | oss << "CALL xios(set_" << className << "_attr_hdl_) &" << iendl; |
---|
[509] | 553 | |
---|
[649] | 554 | startPos = oss.tellp(); |
---|
| 555 | |
---|
| 556 | oss << "( " << className << "_hdl"; |
---|
[581] | 557 | for (it = begin; it != end; it++) |
---|
[313] | 558 | { |
---|
[778] | 559 | if (it->second->isPublic()) |
---|
[313] | 560 | { |
---|
[778] | 561 | oss << ", " << it->second->getName(); |
---|
| 562 | if (oss.tellp() - startPos > 90) |
---|
| 563 | { |
---|
| 564 | oss << " &" << iendl; |
---|
| 565 | startPos = oss.tellp(); |
---|
| 566 | } |
---|
[313] | 567 | } |
---|
| 568 | } |
---|
[649] | 569 | oss << " )"; |
---|
[509] | 570 | |
---|
[581] | 571 | oss << std::endl << (iendl -= 2); |
---|
| 572 | oss << "END SUBROUTINE xios(set_" << className << "_attr_hdl)" << std::endl; |
---|
[509] | 573 | } |
---|
| 574 | |
---|
[313] | 575 | void CAttributeMap::generateFortranInterfaceGet_hdl(ostream& oss, const string& className) |
---|
| 576 | { |
---|
[581] | 577 | oss << "SUBROUTINE xios(get_" << className << "_attr_hdl) &" << iendl++; |
---|
| 578 | SuperClassMap::const_iterator it; |
---|
[313] | 579 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 580 | |
---|
[649] | 581 | long 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(); |
---|
| 589 | if (oss.tellp() - startPos > 90) |
---|
| 590 | { |
---|
| 591 | oss << " &" << iendl; |
---|
| 592 | startPos = oss.tellp(); |
---|
| 593 | } |
---|
[313] | 594 | } |
---|
| 595 | } |
---|
[649] | 596 | oss << " )"; |
---|
| 597 | oss << std::endl; |
---|
[581] | 598 | oss << iendl; |
---|
[509] | 599 | |
---|
[581] | 600 | oss << "IMPLICIT NONE" << iendl++; |
---|
| 601 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
[509] | 602 | |
---|
[581] | 603 | for (it = begin; it != end; it++) |
---|
[313] | 604 | { |
---|
[778] | 605 | if (it->second->isPublic()) |
---|
| 606 | { |
---|
| 607 | oss << iendl; |
---|
| 608 | it->second->generateFortranInterfaceGetDeclaration(oss, className); |
---|
| 609 | } |
---|
[313] | 610 | } |
---|
[509] | 611 | |
---|
[581] | 612 | oss << std::endl << iendl; |
---|
[509] | 613 | |
---|
[581] | 614 | oss << "CALL xios(get_" << className << "_attr_hdl_) &" << iendl; |
---|
[509] | 615 | |
---|
[649] | 616 | startPos = oss.tellp(); |
---|
| 617 | |
---|
| 618 | oss << "( " << className << "_hdl"; |
---|
[581] | 619 | for (it = begin; it != end; it++) |
---|
[313] | 620 | { |
---|
[778] | 621 | if (it->second->isPublic()) |
---|
[313] | 622 | { |
---|
[778] | 623 | oss << ", " << it->second->getName(); |
---|
| 624 | if (oss.tellp() - startPos > 90) |
---|
| 625 | { |
---|
| 626 | oss << " &" << iendl; |
---|
| 627 | startPos = oss.tellp(); |
---|
| 628 | } |
---|
[313] | 629 | } |
---|
| 630 | } |
---|
[649] | 631 | oss << " )"; |
---|
[509] | 632 | |
---|
[581] | 633 | oss << std::endl << (iendl -= 2); |
---|
| 634 | oss << "END SUBROUTINE xios(get_" << className << "_attr_hdl)" << std::endl; |
---|
[509] | 635 | } |
---|
[432] | 636 | |
---|
| 637 | void CAttributeMap::generateFortranInterfaceIsDefined_hdl(ostream& oss, const string& className) |
---|
| 638 | { |
---|
[581] | 639 | oss << "SUBROUTINE xios(is_defined_" << className << "_attr_hdl) &" << iendl++; |
---|
| 640 | SuperClassMap::const_iterator it; |
---|
[432] | 641 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 642 | |
---|
[649] | 643 | long startPos = oss.tellp(); |
---|
| 644 | |
---|
| 645 | oss << "( " << className << "_hdl"; |
---|
[581] | 646 | for (it = begin; it != end; it++) |
---|
[432] | 647 | { |
---|
[778] | 648 | if (it->second->isPublic()) |
---|
[432] | 649 | { |
---|
[778] | 650 | oss << ", " << it->second->getName(); |
---|
| 651 | if (oss.tellp() - startPos > 90) |
---|
| 652 | { |
---|
| 653 | oss << " &" << iendl; |
---|
| 654 | startPos = oss.tellp(); |
---|
| 655 | } |
---|
[432] | 656 | } |
---|
| 657 | } |
---|
[649] | 658 | oss << " )"; |
---|
| 659 | oss << std::endl; |
---|
[581] | 660 | oss << iendl; |
---|
[509] | 661 | |
---|
[581] | 662 | oss << "IMPLICIT NONE" << iendl++; |
---|
| 663 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
[509] | 664 | |
---|
[581] | 665 | for (it = begin; it != end; it++) |
---|
[432] | 666 | { |
---|
[778] | 667 | if (it->second->isPublic()) |
---|
| 668 | { |
---|
| 669 | oss << iendl; |
---|
| 670 | it->second->generateFortranInterfaceIsDefinedDeclaration(oss, className); |
---|
| 671 | } |
---|
[432] | 672 | } |
---|
[509] | 673 | |
---|
[581] | 674 | oss << std::endl << iendl; |
---|
[509] | 675 | |
---|
[581] | 676 | oss << "CALL xios(is_defined_" << className << "_attr_hdl_) &" << iendl; |
---|
[509] | 677 | |
---|
[649] | 678 | startPos = oss.tellp(); |
---|
| 679 | |
---|
| 680 | oss << "( " << className << "_hdl"; |
---|
[581] | 681 | for (it = begin; it != end; it++) |
---|
[432] | 682 | { |
---|
[778] | 683 | if (it->second->isPublic()) |
---|
[432] | 684 | { |
---|
[778] | 685 | oss << ", " << it->second->getName(); |
---|
| 686 | if (oss.tellp() - startPos > 90) |
---|
| 687 | { |
---|
| 688 | oss << " &" << iendl; |
---|
| 689 | startPos = oss.tellp(); |
---|
| 690 | } |
---|
[432] | 691 | } |
---|
| 692 | } |
---|
[649] | 693 | oss << " )"; |
---|
[509] | 694 | |
---|
[581] | 695 | oss << std::endl << (iendl -= 2); |
---|
| 696 | oss << "END SUBROUTINE xios(is_defined_" << className << "_attr_hdl)" << std::endl; |
---|
[509] | 697 | } |
---|
[432] | 698 | |
---|
[313] | 699 | void CAttributeMap::generateFortranInterface_id(ostream& oss, const string& className) |
---|
| 700 | { |
---|
[581] | 701 | oss << "SUBROUTINE xios(set_" << className << "_attr) &" << iendl++; |
---|
| 702 | SuperClassMap::const_iterator it; |
---|
[313] | 703 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 704 | |
---|
[649] | 705 | long startPos = oss.tellp(); |
---|
| 706 | |
---|
| 707 | oss << "( " << className << "_id"; |
---|
[581] | 708 | for (it = begin; it != end; it++) |
---|
[313] | 709 | { |
---|
[778] | 710 | if (it->second->isPublic()) |
---|
[313] | 711 | { |
---|
[778] | 712 | oss << ", " << it->second->getName(); |
---|
| 713 | if (oss.tellp() - startPos > 90) |
---|
| 714 | { |
---|
| 715 | oss << " &" << iendl; |
---|
| 716 | startPos = oss.tellp(); |
---|
| 717 | } |
---|
[313] | 718 | } |
---|
| 719 | } |
---|
[649] | 720 | oss << " )"; |
---|
| 721 | oss << std::endl; |
---|
[581] | 722 | oss << iendl; |
---|
[509] | 723 | |
---|
[581] | 724 | oss << "IMPLICIT NONE" << iendl++; |
---|
[313] | 725 | |
---|
[581] | 726 | oss << "TYPE(txios(" << className << ")) :: " << className << "_hdl" << iendl; |
---|
| 727 | oss << "CHARACTER(LEN=*), INTENT(IN) ::" << className << "_id"; |
---|
[509] | 728 | |
---|
[581] | 729 | for (it = begin; it != end; it++) |
---|
[313] | 730 | { |
---|
[778] | 731 | if (it->second->isPublic()) |
---|
| 732 | { |
---|
| 733 | oss << iendl; |
---|
| 734 | it->second->generateFortranInterfaceDeclaration(oss, className); |
---|
| 735 | } |
---|
[313] | 736 | } |
---|
[509] | 737 | |
---|
[581] | 738 | oss << std::endl << iendl; |
---|
[966] | 739 | oss << "CALL xios(get_" << className << "_handle) &" << iendl; |
---|
| 740 | oss << "(" << className << "_id," << className << "_hdl)" << iendl; |
---|
[581] | 741 | oss << "CALL xios(set_" << className << "_attr_hdl_) &" << iendl; |
---|
[649] | 742 | |
---|
| 743 | startPos = oss.tellp(); |
---|
| 744 | |
---|
| 745 | oss << "( " << className << "_hdl"; |
---|
[581] | 746 | for (it = begin; it != end; it++) |
---|
[313] | 747 | { |
---|
[778] | 748 | if (it->second->isPublic()) |
---|
[313] | 749 | { |
---|
[778] | 750 | oss << ", " << it->second->getName(); |
---|
| 751 | if (oss.tellp() - startPos > 90) |
---|
| 752 | { |
---|
| 753 | oss << " &" << iendl; |
---|
| 754 | startPos = oss.tellp(); |
---|
| 755 | } |
---|
[313] | 756 | } |
---|
| 757 | } |
---|
[649] | 758 | oss << " )"; |
---|
[509] | 759 | |
---|
[581] | 760 | oss << std::endl << (iendl -= 2); |
---|
| 761 | oss << "END SUBROUTINE xios(set_" << className << "_attr)" << std::endl; |
---|
[509] | 762 | } |
---|
| 763 | |
---|
[313] | 764 | void CAttributeMap::generateFortranInterfaceGet_id(ostream& oss, const string& className) |
---|
| 765 | { |
---|
[581] | 766 | oss << "SUBROUTINE xios(get_" << className << "_attr) &" << iendl++; |
---|
| 767 | SuperClassMap::const_iterator it; |
---|
[313] | 768 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 769 | |
---|
[649] | 770 | long startPos = oss.tellp(); |
---|
| 771 | |
---|
| 772 | oss << "( " << className << "_id"; |
---|
[581] | 773 | for (it = begin; it != end; it++) |
---|
[313] | 774 | { |
---|
[778] | 775 | if (it->second->isPublic()) |
---|
[313] | 776 | { |
---|
[778] | 777 | oss << ", " << it->second->getName(); |
---|
| 778 | if (oss.tellp() - startPos > 90) |
---|
| 779 | { |
---|
| 780 | oss << " &" << iendl; |
---|
| 781 | startPos = oss.tellp(); |
---|
| 782 | } |
---|
[313] | 783 | } |
---|
| 784 | } |
---|
[649] | 785 | oss << " )"; |
---|
| 786 | oss << std::endl; |
---|
[581] | 787 | oss << iendl; |
---|
[509] | 788 | |
---|
[581] | 789 | oss << "IMPLICIT NONE" << iendl++; |
---|
[313] | 790 | |
---|
[581] | 791 | oss << "TYPE(txios(" << className << ")) :: " << className << "_hdl" << iendl; |
---|
| 792 | oss << "CHARACTER(LEN=*), INTENT(IN) ::" << className << "_id"; |
---|
[509] | 793 | |
---|
[581] | 794 | for (it = begin; it != end; it++) |
---|
[313] | 795 | { |
---|
[778] | 796 | if (it->second->isPublic()) |
---|
| 797 | { |
---|
| 798 | oss << iendl; |
---|
| 799 | it->second->generateFortranInterfaceGetDeclaration(oss, className); |
---|
| 800 | } |
---|
[313] | 801 | } |
---|
[509] | 802 | |
---|
[581] | 803 | oss << std::endl << iendl; |
---|
[966] | 804 | oss << "CALL xios(get_" << className << "_handle) &" << iendl; |
---|
| 805 | oss << "(" << className << "_id," << className << "_hdl)" << iendl; |
---|
[581] | 806 | oss << "CALL xios(get_" << className << "_attr_hdl_) &" << iendl; |
---|
[649] | 807 | |
---|
| 808 | startPos = oss.tellp(); |
---|
| 809 | |
---|
| 810 | oss << "( " << className << "_hdl"; |
---|
[581] | 811 | for (it = begin; it != end; it++) |
---|
[313] | 812 | { |
---|
[778] | 813 | if (it->second->isPublic()) |
---|
[313] | 814 | { |
---|
[778] | 815 | oss << ", " << it->second->getName(); |
---|
| 816 | if (oss.tellp() - startPos > 90) |
---|
| 817 | { |
---|
| 818 | oss << " &" << iendl; |
---|
| 819 | startPos = oss.tellp(); |
---|
| 820 | } |
---|
[313] | 821 | } |
---|
| 822 | } |
---|
[649] | 823 | oss << " )"; |
---|
[509] | 824 | |
---|
[581] | 825 | oss << std::endl << (iendl -= 2); |
---|
| 826 | oss << "END SUBROUTINE xios(get_" << className << "_attr)" << std::endl; |
---|
[509] | 827 | } |
---|
| 828 | |
---|
[432] | 829 | void CAttributeMap::generateFortranInterfaceIsDefined_id(ostream& oss, const string& className) |
---|
| 830 | { |
---|
[581] | 831 | oss << "SUBROUTINE xios(is_defined_" << className << "_attr) &" << iendl++; |
---|
| 832 | SuperClassMap::const_iterator it; |
---|
[432] | 833 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 834 | |
---|
[649] | 835 | long startPos = oss.tellp(); |
---|
| 836 | |
---|
| 837 | oss << "( " << className << "_id"; |
---|
[581] | 838 | for (it = begin; it != end; it++) |
---|
[432] | 839 | { |
---|
[778] | 840 | if (it->second->isPublic()) |
---|
[432] | 841 | { |
---|
[778] | 842 | oss << ", " << it->second->getName(); |
---|
| 843 | if (oss.tellp() - startPos > 90) |
---|
| 844 | { |
---|
| 845 | oss << " &" << iendl; |
---|
| 846 | startPos = oss.tellp(); |
---|
| 847 | } |
---|
[432] | 848 | } |
---|
| 849 | } |
---|
[649] | 850 | oss << " )"; |
---|
| 851 | oss << std::endl; |
---|
[581] | 852 | oss << iendl; |
---|
[509] | 853 | |
---|
[581] | 854 | oss << "IMPLICIT NONE" << iendl++; |
---|
[432] | 855 | |
---|
[581] | 856 | oss << "TYPE(txios(" << className << ")) :: " << className << "_hdl" << iendl; |
---|
| 857 | oss << "CHARACTER(LEN=*), INTENT(IN) ::" << className << "_id"; |
---|
[509] | 858 | |
---|
[581] | 859 | for (it = begin; it != end; it++) |
---|
[432] | 860 | { |
---|
[778] | 861 | if (it->second->isPublic()) |
---|
| 862 | { |
---|
| 863 | oss << iendl; |
---|
| 864 | it->second->generateFortranInterfaceIsDefinedDeclaration(oss, className); |
---|
| 865 | } |
---|
[432] | 866 | } |
---|
[509] | 867 | |
---|
[581] | 868 | oss << std::endl << iendl; |
---|
[966] | 869 | oss << "CALL xios(get_" << className << "_handle) &" << iendl; |
---|
| 870 | oss << "(" << className << "_id," << className << "_hdl)" << iendl; |
---|
[581] | 871 | oss << "CALL xios(is_defined_" << className << "_attr_hdl_) &" << iendl; |
---|
[649] | 872 | |
---|
| 873 | startPos = oss.tellp(); |
---|
| 874 | |
---|
| 875 | oss << "( " << className << "_hdl"; |
---|
[581] | 876 | for (it = begin; it != end; it++) |
---|
[432] | 877 | { |
---|
[778] | 878 | if (it->second->isPublic()) |
---|
[432] | 879 | { |
---|
[778] | 880 | oss << ", " << it->second->getName(); |
---|
| 881 | if (oss.tellp() - startPos > 90) |
---|
| 882 | { |
---|
| 883 | oss << " &" << iendl; |
---|
| 884 | startPos = oss.tellp(); |
---|
| 885 | } |
---|
[432] | 886 | } |
---|
| 887 | } |
---|
[649] | 888 | oss << " )"; |
---|
[509] | 889 | |
---|
[581] | 890 | oss << std::endl << (iendl -= 2); |
---|
| 891 | oss << "END SUBROUTINE xios(is_defined_" << className << "_attr)" << std::endl; |
---|
[509] | 892 | } |
---|
[591] | 893 | } // namespace xios |
---|