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