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