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