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