[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 | { |
---|
[581] | 228 | oss << std::endl << iendl; |
---|
| 229 | it->second->generateCInterface(oss, className); |
---|
| 230 | oss << iendl; |
---|
| 231 | it->second->generateCInterfaceIsDefined(oss, className); |
---|
[313] | 232 | } |
---|
| 233 | } |
---|
| 234 | |
---|
| 235 | void CAttributeMap::generateFortran2003Interface(ostream& oss, const string& className) |
---|
| 236 | { |
---|
| 237 | SuperClassMap::const_iterator it = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
| 238 | for (; it != end; it++) |
---|
| 239 | { |
---|
[581] | 240 | oss << std::endl << iendl; |
---|
| 241 | it->second->generateFortran2003Interface(oss, className); |
---|
| 242 | oss << iendl; |
---|
| 243 | it->second->generateFortran2003InterfaceIsDefined(oss, className); |
---|
[313] | 244 | } |
---|
[509] | 245 | } |
---|
| 246 | |
---|
[219] | 247 | ///-------------------------------------------------------------- |
---|
| 248 | |
---|
[313] | 249 | void CAttributeMap::generateFortranInterface_hdl_(ostream& oss, const string& className) |
---|
| 250 | { |
---|
[581] | 251 | oss << "SUBROUTINE xios(set_" << className << "_attr_hdl_) &" << iendl++; |
---|
| 252 | SuperClassMap::const_iterator it; |
---|
[313] | 253 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 254 | |
---|
[649] | 255 | long startPos = oss.tellp(); |
---|
[509] | 256 | |
---|
[649] | 257 | oss << "( " << className << "_hdl"; |
---|
[581] | 258 | for (it = begin; it != end; it++) |
---|
[313] | 259 | { |
---|
[649] | 260 | oss << ", " << it->second->getName() << "_"; |
---|
| 261 | if (oss.tellp() - startPos > 90) |
---|
[313] | 262 | { |
---|
[649] | 263 | oss << " &" << iendl; |
---|
| 264 | startPos = oss.tellp(); |
---|
[313] | 265 | } |
---|
| 266 | } |
---|
[649] | 267 | oss << " )"; |
---|
| 268 | oss << std::endl; |
---|
[581] | 269 | oss << iendl; |
---|
[509] | 270 | |
---|
[581] | 271 | oss << "IMPLICIT NONE" << iendl++; |
---|
| 272 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
[509] | 273 | |
---|
[581] | 274 | for (it = begin; it != end; it++) |
---|
[313] | 275 | { |
---|
[581] | 276 | oss << iendl; |
---|
| 277 | it->second->generateFortranInterfaceDeclaration_(oss, className); |
---|
[313] | 278 | } |
---|
[509] | 279 | |
---|
[581] | 280 | for (it = begin; it != end; it++) |
---|
[313] | 281 | { |
---|
[581] | 282 | oss << std::endl << iendl; |
---|
| 283 | it->second->generateFortranInterfaceBody_(oss, className); |
---|
[313] | 284 | } |
---|
[509] | 285 | |
---|
[581] | 286 | oss << std::endl << (iendl -= 2); |
---|
| 287 | oss << "END SUBROUTINE xios(set_" << className << "_attr_hdl_)" << std::endl; |
---|
[509] | 288 | } |
---|
| 289 | |
---|
[313] | 290 | void CAttributeMap::generateFortranInterfaceGet_hdl_(ostream& oss, const string& className) |
---|
| 291 | { |
---|
[581] | 292 | oss << "SUBROUTINE xios(get_" << className << "_attr_hdl_) &" << iendl++; |
---|
| 293 | SuperClassMap::const_iterator it; |
---|
[313] | 294 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 295 | |
---|
[649] | 296 | long startPos = oss.tellp(); |
---|
[509] | 297 | |
---|
[649] | 298 | oss << "( " << className << "_hdl"; |
---|
[581] | 299 | for (it = begin; it != end; it++) |
---|
[313] | 300 | { |
---|
[649] | 301 | oss << ", " << it->second->getName() << "_"; |
---|
| 302 | if (oss.tellp() - startPos > 90) |
---|
[313] | 303 | { |
---|
[649] | 304 | oss << " &" << iendl; |
---|
| 305 | startPos = oss.tellp(); |
---|
[313] | 306 | } |
---|
| 307 | } |
---|
[649] | 308 | oss << " )"; |
---|
| 309 | oss << std::endl; |
---|
[581] | 310 | oss << iendl; |
---|
[509] | 311 | |
---|
[581] | 312 | oss << "IMPLICIT NONE" << iendl++; |
---|
| 313 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
[509] | 314 | |
---|
[581] | 315 | for (it = begin; it != end; it++) |
---|
[313] | 316 | { |
---|
[581] | 317 | oss << iendl; |
---|
| 318 | it->second->generateFortranInterfaceGetDeclaration_(oss, className); |
---|
[313] | 319 | } |
---|
[509] | 320 | |
---|
[581] | 321 | for (it = begin; it != end; it++) |
---|
[313] | 322 | { |
---|
[581] | 323 | oss << std::endl << iendl; |
---|
| 324 | it->second->generateFortranInterfaceGetBody_(oss, className); |
---|
[313] | 325 | } |
---|
[509] | 326 | |
---|
[581] | 327 | oss << std::endl << (iendl -= 2); |
---|
| 328 | oss << "END SUBROUTINE xios(get_" << className << "_attr_hdl_)" << std::endl; |
---|
[509] | 329 | } |
---|
| 330 | |
---|
[432] | 331 | void CAttributeMap::generateFortranInterfaceIsDefined_hdl_(ostream& oss, const string& className) |
---|
| 332 | { |
---|
[581] | 333 | oss << "SUBROUTINE xios(is_defined_" << className << "_attr_hdl_) &" << iendl++; |
---|
| 334 | SuperClassMap::const_iterator it; |
---|
[432] | 335 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 336 | |
---|
[649] | 337 | long startPos = oss.tellp(); |
---|
[509] | 338 | |
---|
[649] | 339 | oss << "( " << className << "_hdl"; |
---|
[581] | 340 | for (it = begin; it != end; it++) |
---|
[432] | 341 | { |
---|
[649] | 342 | oss << ", " << it->second->getName() << "_"; |
---|
| 343 | if (oss.tellp() - startPos > 90) |
---|
[432] | 344 | { |
---|
[649] | 345 | oss << " &" << iendl; |
---|
| 346 | startPos = oss.tellp(); |
---|
[432] | 347 | } |
---|
| 348 | } |
---|
[649] | 349 | oss << " )"; |
---|
| 350 | oss << std::endl; |
---|
[581] | 351 | oss << iendl; |
---|
[509] | 352 | |
---|
[581] | 353 | oss << "IMPLICIT NONE" << iendl++; |
---|
| 354 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
[509] | 355 | |
---|
[581] | 356 | for (it = begin; it != end; it++) |
---|
[432] | 357 | { |
---|
[581] | 358 | oss << iendl; |
---|
| 359 | it->second->generateFortranInterfaceIsDefinedDeclaration_(oss, className); |
---|
[432] | 360 | } |
---|
[509] | 361 | |
---|
[581] | 362 | for (it = begin; it != end; it++) |
---|
[432] | 363 | { |
---|
[581] | 364 | oss << std::endl << iendl; |
---|
| 365 | it->second->generateFortranInterfaceIsDefinedBody_(oss, className); |
---|
[432] | 366 | } |
---|
[509] | 367 | |
---|
[581] | 368 | oss << std::endl << (iendl -= 2); |
---|
| 369 | oss << "END SUBROUTINE xios(is_defined_" << className << "_attr_hdl_)" << std::endl; |
---|
[509] | 370 | } |
---|
| 371 | |
---|
[313] | 372 | void CAttributeMap::generateFortranInterface_hdl(ostream& oss, const string& className) |
---|
| 373 | { |
---|
[581] | 374 | oss << "SUBROUTINE xios(set_" << className << "_attr_hdl) &" << iendl++; |
---|
| 375 | SuperClassMap::const_iterator it; |
---|
[313] | 376 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 377 | |
---|
[649] | 378 | long startPos = oss.tellp(); |
---|
| 379 | |
---|
| 380 | oss << "( " << className << "_hdl"; |
---|
[581] | 381 | for (it = begin; it != end; it++) |
---|
[313] | 382 | { |
---|
[649] | 383 | oss << ", " << it->second->getName(); |
---|
| 384 | if (oss.tellp() - startPos > 90) |
---|
[313] | 385 | { |
---|
[649] | 386 | oss << " &" << iendl; |
---|
| 387 | startPos = oss.tellp(); |
---|
[313] | 388 | } |
---|
| 389 | } |
---|
[649] | 390 | oss << " )"; |
---|
| 391 | oss << std::endl; |
---|
[581] | 392 | oss << iendl; |
---|
[509] | 393 | |
---|
[581] | 394 | oss << "IMPLICIT NONE" << iendl++; |
---|
| 395 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
[509] | 396 | |
---|
[581] | 397 | for (it = begin; it != end; it++) |
---|
[313] | 398 | { |
---|
[581] | 399 | oss << iendl; |
---|
| 400 | it->second->generateFortranInterfaceDeclaration(oss, className); |
---|
[313] | 401 | } |
---|
[509] | 402 | |
---|
[581] | 403 | oss << std::endl << iendl; |
---|
[509] | 404 | |
---|
[581] | 405 | oss << "CALL xios(set_" << className << "_attr_hdl_) &" << iendl; |
---|
[509] | 406 | |
---|
[649] | 407 | startPos = oss.tellp(); |
---|
| 408 | |
---|
| 409 | oss << "( " << className << "_hdl"; |
---|
[581] | 410 | for (it = begin; it != end; it++) |
---|
[313] | 411 | { |
---|
[649] | 412 | oss << ", " << it->second->getName(); |
---|
| 413 | if (oss.tellp() - startPos > 90) |
---|
[313] | 414 | { |
---|
[649] | 415 | oss << " &" << iendl; |
---|
| 416 | startPos = oss.tellp(); |
---|
[313] | 417 | } |
---|
| 418 | } |
---|
[649] | 419 | oss << " )"; |
---|
[509] | 420 | |
---|
[581] | 421 | oss << std::endl << (iendl -= 2); |
---|
| 422 | oss << "END SUBROUTINE xios(set_" << className << "_attr_hdl)" << std::endl; |
---|
[509] | 423 | } |
---|
| 424 | |
---|
[313] | 425 | void CAttributeMap::generateFortranInterfaceGet_hdl(ostream& oss, const string& className) |
---|
| 426 | { |
---|
[581] | 427 | oss << "SUBROUTINE xios(get_" << className << "_attr_hdl) &" << iendl++; |
---|
| 428 | SuperClassMap::const_iterator it; |
---|
[313] | 429 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 430 | |
---|
[649] | 431 | long startPos = oss.tellp(); |
---|
| 432 | |
---|
| 433 | oss << "( " << className << "_hdl"; |
---|
[581] | 434 | for (it = begin; it != end; it++) |
---|
[313] | 435 | { |
---|
[649] | 436 | oss << ", " << it->second->getName(); |
---|
| 437 | if (oss.tellp() - startPos > 90) |
---|
[313] | 438 | { |
---|
[649] | 439 | oss << " &" << iendl; |
---|
| 440 | startPos = oss.tellp(); |
---|
[313] | 441 | } |
---|
| 442 | } |
---|
[649] | 443 | oss << " )"; |
---|
| 444 | oss << std::endl; |
---|
[581] | 445 | oss << iendl; |
---|
[509] | 446 | |
---|
[581] | 447 | oss << "IMPLICIT NONE" << iendl++; |
---|
| 448 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
[509] | 449 | |
---|
[581] | 450 | for (it = begin; it != end; it++) |
---|
[313] | 451 | { |
---|
[581] | 452 | oss << iendl; |
---|
| 453 | it->second->generateFortranInterfaceGetDeclaration(oss, className); |
---|
[313] | 454 | } |
---|
[509] | 455 | |
---|
[581] | 456 | oss << std::endl << iendl; |
---|
[509] | 457 | |
---|
[581] | 458 | oss << "CALL xios(get_" << className << "_attr_hdl_) &" << iendl; |
---|
[509] | 459 | |
---|
[649] | 460 | startPos = oss.tellp(); |
---|
| 461 | |
---|
| 462 | oss << "( " << className << "_hdl"; |
---|
[581] | 463 | for (it = begin; it != end; it++) |
---|
[313] | 464 | { |
---|
[649] | 465 | oss << ", " << it->second->getName(); |
---|
| 466 | if (oss.tellp() - startPos > 90) |
---|
[313] | 467 | { |
---|
[649] | 468 | oss << " &" << iendl; |
---|
| 469 | startPos = oss.tellp(); |
---|
[313] | 470 | } |
---|
| 471 | } |
---|
[649] | 472 | oss << " )"; |
---|
[509] | 473 | |
---|
[581] | 474 | oss << std::endl << (iendl -= 2); |
---|
| 475 | oss << "END SUBROUTINE xios(get_" << className << "_attr_hdl)" << std::endl; |
---|
[509] | 476 | } |
---|
[432] | 477 | |
---|
| 478 | void CAttributeMap::generateFortranInterfaceIsDefined_hdl(ostream& oss, const string& className) |
---|
| 479 | { |
---|
[581] | 480 | oss << "SUBROUTINE xios(is_defined_" << className << "_attr_hdl) &" << iendl++; |
---|
| 481 | SuperClassMap::const_iterator it; |
---|
[432] | 482 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 483 | |
---|
[649] | 484 | long startPos = oss.tellp(); |
---|
| 485 | |
---|
| 486 | oss << "( " << className << "_hdl"; |
---|
[581] | 487 | for (it = begin; it != end; it++) |
---|
[432] | 488 | { |
---|
[649] | 489 | oss << ", " << it->second->getName(); |
---|
| 490 | if (oss.tellp() - startPos > 90) |
---|
[432] | 491 | { |
---|
[649] | 492 | oss << " &" << iendl; |
---|
| 493 | startPos = oss.tellp(); |
---|
[432] | 494 | } |
---|
| 495 | } |
---|
[649] | 496 | oss << " )"; |
---|
| 497 | oss << std::endl; |
---|
[581] | 498 | oss << iendl; |
---|
[509] | 499 | |
---|
[581] | 500 | oss << "IMPLICIT NONE" << iendl++; |
---|
| 501 | oss << "TYPE(txios(" << className << ")) , INTENT(IN) :: " << className << "_hdl"; |
---|
[509] | 502 | |
---|
[581] | 503 | for (it = begin; it != end; it++) |
---|
[432] | 504 | { |
---|
[581] | 505 | oss << iendl; |
---|
| 506 | it->second->generateFortranInterfaceIsDefinedDeclaration(oss, className); |
---|
[432] | 507 | } |
---|
[509] | 508 | |
---|
[581] | 509 | oss << std::endl << iendl; |
---|
[509] | 510 | |
---|
[581] | 511 | oss << "CALL xios(is_defined_" << className << "_attr_hdl_) &" << iendl; |
---|
[509] | 512 | |
---|
[649] | 513 | startPos = oss.tellp(); |
---|
| 514 | |
---|
| 515 | oss << "( " << className << "_hdl"; |
---|
[581] | 516 | for (it = begin; it != end; it++) |
---|
[432] | 517 | { |
---|
[649] | 518 | oss << ", " << it->second->getName(); |
---|
| 519 | if (oss.tellp() - startPos > 90) |
---|
[432] | 520 | { |
---|
[649] | 521 | oss << " &" << iendl; |
---|
| 522 | startPos = oss.tellp(); |
---|
[432] | 523 | } |
---|
| 524 | } |
---|
[649] | 525 | oss << " )"; |
---|
[509] | 526 | |
---|
[581] | 527 | oss << std::endl << (iendl -= 2); |
---|
| 528 | oss << "END SUBROUTINE xios(is_defined_" << className << "_attr_hdl)" << std::endl; |
---|
[509] | 529 | } |
---|
[432] | 530 | |
---|
[313] | 531 | void CAttributeMap::generateFortranInterface_id(ostream& oss, const string& className) |
---|
| 532 | { |
---|
[581] | 533 | oss << "SUBROUTINE xios(set_" << className << "_attr) &" << iendl++; |
---|
| 534 | SuperClassMap::const_iterator it; |
---|
[313] | 535 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 536 | |
---|
[649] | 537 | long startPos = oss.tellp(); |
---|
| 538 | |
---|
| 539 | oss << "( " << className << "_id"; |
---|
[581] | 540 | for (it = begin; it != end; it++) |
---|
[313] | 541 | { |
---|
[649] | 542 | oss << ", " << it->second->getName(); |
---|
| 543 | if (oss.tellp() - startPos > 90) |
---|
[313] | 544 | { |
---|
[649] | 545 | oss << " &" << iendl; |
---|
| 546 | startPos = oss.tellp(); |
---|
[313] | 547 | } |
---|
| 548 | } |
---|
[649] | 549 | oss << " )"; |
---|
| 550 | oss << std::endl; |
---|
[581] | 551 | oss << iendl; |
---|
[509] | 552 | |
---|
[581] | 553 | oss << "IMPLICIT NONE" << iendl++; |
---|
[313] | 554 | |
---|
[581] | 555 | oss << "TYPE(txios(" << className << ")) :: " << className << "_hdl" << iendl; |
---|
| 556 | oss << "CHARACTER(LEN=*), INTENT(IN) ::" << className << "_id"; |
---|
[509] | 557 | |
---|
[581] | 558 | for (it = begin; it != end; it++) |
---|
[313] | 559 | { |
---|
[581] | 560 | oss << iendl; |
---|
| 561 | it->second->generateFortranInterfaceDeclaration(oss, className); |
---|
[313] | 562 | } |
---|
[509] | 563 | |
---|
[581] | 564 | oss << std::endl << iendl; |
---|
| 565 | oss << "CALL xios(get_" << className << "_handle)(" << className << "_id," << className << "_hdl)" << iendl; |
---|
| 566 | oss << "CALL xios(set_" << className << "_attr_hdl_) &" << iendl; |
---|
[649] | 567 | |
---|
| 568 | startPos = oss.tellp(); |
---|
| 569 | |
---|
| 570 | oss << "( " << className << "_hdl"; |
---|
[581] | 571 | for (it = begin; it != end; it++) |
---|
[313] | 572 | { |
---|
[649] | 573 | oss << ", " << it->second->getName(); |
---|
| 574 | if (oss.tellp() - startPos > 90) |
---|
[313] | 575 | { |
---|
[649] | 576 | oss << " &" << iendl; |
---|
| 577 | startPos = oss.tellp(); |
---|
[313] | 578 | } |
---|
| 579 | } |
---|
[649] | 580 | oss << " )"; |
---|
[509] | 581 | |
---|
[581] | 582 | oss << std::endl << (iendl -= 2); |
---|
| 583 | oss << "END SUBROUTINE xios(set_" << className << "_attr)" << std::endl; |
---|
[509] | 584 | } |
---|
| 585 | |
---|
[313] | 586 | void CAttributeMap::generateFortranInterfaceGet_id(ostream& oss, const string& className) |
---|
| 587 | { |
---|
[581] | 588 | oss << "SUBROUTINE xios(get_" << 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 | { |
---|
[649] | 597 | oss << ", " << it->second->getName(); |
---|
| 598 | if (oss.tellp() - startPos > 90) |
---|
[313] | 599 | { |
---|
[649] | 600 | oss << " &" << iendl; |
---|
| 601 | startPos = oss.tellp(); |
---|
[313] | 602 | } |
---|
| 603 | } |
---|
[649] | 604 | oss << " )"; |
---|
| 605 | oss << std::endl; |
---|
[581] | 606 | oss << iendl; |
---|
[509] | 607 | |
---|
[581] | 608 | oss << "IMPLICIT NONE" << iendl++; |
---|
[313] | 609 | |
---|
[581] | 610 | oss << "TYPE(txios(" << className << ")) :: " << className << "_hdl" << iendl; |
---|
| 611 | oss << "CHARACTER(LEN=*), INTENT(IN) ::" << className << "_id"; |
---|
[509] | 612 | |
---|
[581] | 613 | for (it = begin; it != end; it++) |
---|
[313] | 614 | { |
---|
[581] | 615 | oss << iendl; |
---|
| 616 | it->second->generateFortranInterfaceGetDeclaration(oss, className); |
---|
[313] | 617 | } |
---|
[509] | 618 | |
---|
[581] | 619 | oss << std::endl << iendl; |
---|
| 620 | oss << "CALL xios(get_" << className << "_handle)(" << className << "_id," << className << "_hdl)" << iendl; |
---|
| 621 | oss << "CALL xios(get_" << className << "_attr_hdl_) &" << iendl; |
---|
[649] | 622 | |
---|
| 623 | startPos = oss.tellp(); |
---|
| 624 | |
---|
| 625 | oss << "( " << className << "_hdl"; |
---|
[581] | 626 | for (it = begin; it != end; it++) |
---|
[313] | 627 | { |
---|
[649] | 628 | oss << ", " << it->second->getName(); |
---|
| 629 | if (oss.tellp() - startPos > 90) |
---|
[313] | 630 | { |
---|
[649] | 631 | oss << " &" << iendl; |
---|
| 632 | startPos = oss.tellp(); |
---|
[313] | 633 | } |
---|
| 634 | } |
---|
[649] | 635 | oss << " )"; |
---|
[509] | 636 | |
---|
[581] | 637 | oss << std::endl << (iendl -= 2); |
---|
| 638 | oss << "END SUBROUTINE xios(get_" << className << "_attr)" << std::endl; |
---|
[509] | 639 | } |
---|
| 640 | |
---|
[432] | 641 | void CAttributeMap::generateFortranInterfaceIsDefined_id(ostream& oss, const string& className) |
---|
| 642 | { |
---|
[581] | 643 | oss << "SUBROUTINE xios(is_defined_" << className << "_attr) &" << iendl++; |
---|
| 644 | SuperClassMap::const_iterator it; |
---|
[432] | 645 | SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end(); |
---|
[509] | 646 | |
---|
[649] | 647 | long startPos = oss.tellp(); |
---|
| 648 | |
---|
| 649 | oss << "( " << className << "_id"; |
---|
[581] | 650 | for (it = begin; it != end; it++) |
---|
[432] | 651 | { |
---|
[649] | 652 | oss << ", " << it->second->getName(); |
---|
| 653 | if (oss.tellp() - startPos > 90) |
---|
[432] | 654 | { |
---|
[649] | 655 | oss << " &" << iendl; |
---|
| 656 | startPos = oss.tellp(); |
---|
[432] | 657 | } |
---|
| 658 | } |
---|
[649] | 659 | oss << " )"; |
---|
| 660 | oss << std::endl; |
---|
[581] | 661 | oss << iendl; |
---|
[509] | 662 | |
---|
[581] | 663 | oss << "IMPLICIT NONE" << iendl++; |
---|
[432] | 664 | |
---|
[581] | 665 | oss << "TYPE(txios(" << className << ")) :: " << className << "_hdl" << iendl; |
---|
| 666 | oss << "CHARACTER(LEN=*), INTENT(IN) ::" << className << "_id"; |
---|
[509] | 667 | |
---|
[581] | 668 | for (it = begin; it != end; it++) |
---|
[432] | 669 | { |
---|
[581] | 670 | oss << iendl; |
---|
| 671 | it->second->generateFortranInterfaceIsDefinedDeclaration(oss, className); |
---|
[432] | 672 | } |
---|
[509] | 673 | |
---|
[581] | 674 | oss << std::endl << iendl; |
---|
| 675 | oss << "CALL xios(get_" << className << "_handle)(" << className << "_id," << className << "_hdl)" << iendl; |
---|
| 676 | oss << "CALL xios(is_defined_" << className << "_attr_hdl_) &" << iendl; |
---|
[649] | 677 | |
---|
| 678 | startPos = oss.tellp(); |
---|
| 679 | |
---|
| 680 | oss << "( " << className << "_hdl"; |
---|
[581] | 681 | for (it = begin; it != end; it++) |
---|
[432] | 682 | { |
---|
[649] | 683 | oss << ", " << it->second->getName(); |
---|
| 684 | if (oss.tellp() - startPos > 90) |
---|
[432] | 685 | { |
---|
[649] | 686 | oss << " &" << iendl; |
---|
| 687 | startPos = oss.tellp(); |
---|
[432] | 688 | } |
---|
| 689 | } |
---|
[649] | 690 | oss << " )"; |
---|
[509] | 691 | |
---|
[581] | 692 | oss << std::endl << (iendl -= 2); |
---|
| 693 | oss << "END SUBROUTINE xios(is_defined_" << className << "_attr)" << std::endl; |
---|
[509] | 694 | } |
---|
[591] | 695 | } // namespace xios |
---|