Line data Source code
1 : 2 : /* 3 : * ALMA - Atacama Large Millimeter Array 4 : * (c) European Southern Observatory, 2002 5 : * (c) Associated Universities Inc., 2002 6 : * Copyright by ESO (in the framework of the ALMA collaboration), 7 : * Copyright by AUI (in the framework of the ALMA collaboration), 8 : * All rights reserved. 9 : * 10 : * This library is free software; you can redistribute it and/or 11 : * modify it under the terms of the GNU Lesser General Public 12 : * License as published by the Free software Foundation; either 13 : * version 2.1 of the License, or (at your option) any later version. 14 : * 15 : * This library is distributed in the hope that it will be useful, 16 : * but WITHOUT ANY WARRANTY, without even the implied warranty of 17 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 : * Lesser General Public License for more details. 19 : * 20 : * You should have received a copy of the GNU Lesser General Public 21 : * License along with this library; if not, write to the Free Software 22 : * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 23 : * MA 02111-1307 USA 24 : * 25 : * Warning! 26 : * -------------------------------------------------------------------- 27 : * | This is generated code! Do not modify this file. | 28 : * | If you do, all changes will be lost when the file is re-generated. | 29 : * -------------------------------------------------------------------- 30 : * 31 : * File DelayModelFixedParametersTable.h 32 : */ 33 : 34 : #ifndef DelayModelFixedParametersTable_CLASS 35 : #define DelayModelFixedParametersTable_CLASS 36 : 37 : #include <string> 38 : #include <vector> 39 : #include <map> 40 : 41 : 42 : 43 : 44 : #include <alma/ASDM/Speed.h> 45 : 46 : 47 : 48 : #include <alma/ASDM/AngularRate.h> 49 : 50 : 51 : 52 : #include <alma/ASDM/Length.h> 53 : 54 : 55 : 56 : #include <alma/ASDM/Tag.h> 57 : 58 : 59 : 60 : 61 : 62 : 63 : 64 : 65 : 66 : 67 : 68 : 69 : 70 : 71 : 72 : 73 : 74 : 75 : 76 : 77 : 78 : 79 : 80 : 81 : 82 : 83 : 84 : 85 : 86 : 87 : 88 : 89 : 90 : 91 : 92 : 93 : 94 : 95 : 96 : 97 : 98 : 99 : 100 : 101 : 102 : #include <alma/ASDM/ConversionException.h> 103 : #include <alma/ASDM/DuplicateKey.h> 104 : #include <alma/ASDM/UniquenessViolationException.h> 105 : #include <alma/ASDM/NoSuchRow.h> 106 : #include <alma/ASDM/DuplicateKey.h> 107 : 108 : 109 : #ifndef WITHOUT_ACS 110 : #include <asdmIDLC.h> 111 : #endif 112 : 113 : #include <alma/ASDM/Representable.h> 114 : 115 : #include <pthread.h> 116 : 117 : namespace asdm { 118 : 119 : //class asdm::ASDM; 120 : //class asdm::DelayModelFixedParametersRow; 121 : 122 : class ASDM; 123 : class DelayModelFixedParametersRow; 124 : /** 125 : * The DelayModelFixedParametersTable class is an Alma table. 126 : * <BR> 127 : * 128 : * \par Role 129 : * 130 : * <BR> 131 : 132 : * Generated from model's revision "-1", branch "" 133 : * 134 : * <TABLE BORDER="1"> 135 : * <CAPTION> Attributes of DelayModelFixedParameters </CAPTION> 136 : * <TR BGCOLOR="#AAAAAA"> <TH> Name </TH> <TH> Type </TH> <TH> Expected shape </TH> <TH> Comment </TH></TR> 137 : 138 : * <TR> <TH BGCOLOR="#CCCCCC" colspan="4" align="center"> Key </TD></TR> 139 : 140 : * <TR> 141 : 142 : * <TD><I> delayModelFixedParametersId </I></TD> 143 : 144 : * <TD> Tag</TD> 145 : * <TD> </TD> 146 : * <TD> identifies a unique row in the table. </TD> 147 : * </TR> 148 : 149 : 150 : 151 : * <TR> <TH BGCOLOR="#CCCCCC" colspan="4" valign="center"> Value <br> (Mandatory) </TH></TR> 152 : 153 : * <TR> 154 : * <TD> delayModelVersion </TD> 155 : * <TD> std::string </TD> 156 : * <TD> </TD> 157 : * <TD> should include the name of the software and its version. Something like "CALC v11" or "VDT v1.0" or "MODEST v2.1". </TD> 158 : * </TR> 159 : 160 : * <TR> 161 : * <TD> execBlockId </TD> 162 : * <TD> Tag </TD> 163 : * <TD> </TD> 164 : * <TD> refers to a unique row of the ExecBlock table. </TD> 165 : * </TR> 166 : 167 : 168 : 169 : * <TR> <TH BGCOLOR="#CCCCCC" colspan="4" valign="center"> Value <br> (Optional) </TH></TR> 170 : 171 : * <TR> 172 : * <TD> gaussConstant</TD> 173 : * <TD> AngularRate </TD> 174 : * <TD> </TD> 175 : * <TD> the Gauss gravitational constant (should be of order \f$ 1.720209895.10^{-2} rad/d \f$ but in SI units of \f$ rad s^{-1} \f$). </TD> 176 : * </TR> 177 : 178 : * <TR> 179 : * <TD> newtonianConstant</TD> 180 : * <TD> double </TD> 181 : * <TD> </TD> 182 : * <TD> the newtonian constant of gravitation (should be of order \f$ 6.67259.10^{-11} m^3 kg^{-1} s^2 \f$). </TD> 183 : * </TR> 184 : 185 : * <TR> 186 : * <TD> gravity</TD> 187 : * <TD> double </TD> 188 : * <TD> </TD> 189 : * <TD> the gravity acceleration in \f$ m s^{-2} \f$. </TD> 190 : * </TR> 191 : 192 : * <TR> 193 : * <TD> earthFlattening</TD> 194 : * <TD> double </TD> 195 : * <TD> </TD> 196 : * <TD> the ratio of equatorial to polar radii. </TD> 197 : * </TR> 198 : 199 : * <TR> 200 : * <TD> earthRadius</TD> 201 : * <TD> Length </TD> 202 : * <TD> </TD> 203 : * <TD> the earth equatorial radius in \f$ m \f$. </TD> 204 : * </TR> 205 : 206 : * <TR> 207 : * <TD> moonEarthMassRatio</TD> 208 : * <TD> double </TD> 209 : * <TD> </TD> 210 : * <TD> </TD> 211 : * </TR> 212 : 213 : * <TR> 214 : * <TD> ephemerisEpoch</TD> 215 : * <TD> std::string </TD> 216 : * <TD> </TD> 217 : * <TD> should always be 'J2000'. </TD> 218 : * </TR> 219 : 220 : * <TR> 221 : * <TD> earthTideLag</TD> 222 : * <TD> double </TD> 223 : * <TD> </TD> 224 : * <TD> </TD> 225 : * </TR> 226 : 227 : * <TR> 228 : * <TD> earthGM</TD> 229 : * <TD> double </TD> 230 : * <TD> </TD> 231 : * <TD> the earth gravitation constant in \f$ m^3 s^{-2} \f$. </TD> 232 : * </TR> 233 : 234 : * <TR> 235 : * <TD> moonGM</TD> 236 : * <TD> double </TD> 237 : * <TD> </TD> 238 : * <TD> the moon gravitation constant in \f$ m^3 s^{-2} \f$. </TD> 239 : * </TR> 240 : 241 : * <TR> 242 : * <TD> sunGM</TD> 243 : * <TD> double </TD> 244 : * <TD> </TD> 245 : * <TD> the sun gravitation constant in \f$ m^3 s^{-2} \f$. </TD> 246 : * </TR> 247 : 248 : * <TR> 249 : * <TD> loveNumberH</TD> 250 : * <TD> double </TD> 251 : * <TD> </TD> 252 : * <TD> the earth global Love number H. </TD> 253 : * </TR> 254 : 255 : * <TR> 256 : * <TD> loveNumberL</TD> 257 : * <TD> double </TD> 258 : * <TD> </TD> 259 : * <TD> the earth global Love number L. </TD> 260 : * </TR> 261 : 262 : * <TR> 263 : * <TD> precessionConstant</TD> 264 : * <TD> AngularRate </TD> 265 : * <TD> </TD> 266 : * <TD> the general precession constant in \f$ arcsec \ s^{-1} \f$. </TD> 267 : * </TR> 268 : 269 : * <TR> 270 : * <TD> lightTime1AU</TD> 271 : * <TD> double </TD> 272 : * <TD> </TD> 273 : * <TD> the light time for 1 AU in seconds. </TD> 274 : * </TR> 275 : 276 : * <TR> 277 : * <TD> speedOfLight</TD> 278 : * <TD> Speed </TD> 279 : * <TD> </TD> 280 : * <TD> the speed of light in \f$ m s^{-1} \f$. 281 : </TD> 282 : * </TR> 283 : 284 : * <TR> 285 : * <TD> delayModelFlags</TD> 286 : * <TD> std::string </TD> 287 : * <TD> </TD> 288 : * <TD> the delay model switches. </TD> 289 : * </TR> 290 : 291 : 292 : * </TABLE> 293 : */ 294 : class DelayModelFixedParametersTable : public Representable { 295 : friend class ASDM; 296 : 297 : public: 298 : 299 : 300 : /** 301 : * Return the list of field names that make up key key 302 : * as an array of strings. 303 : * @return a vector of string. 304 : */ 305 : static const std::vector<std::string>& getKeyName(); 306 : 307 : 308 : virtual ~DelayModelFixedParametersTable(); 309 : 310 : /** 311 : * Return the container to which this table belongs. 312 : * 313 : * @return the ASDM containing this table. 314 : */ 315 : ASDM &getContainer() const; 316 : 317 : /** 318 : * Return the number of rows in the table. 319 : * 320 : * @return the number of rows in an unsigned int. 321 : */ 322 : unsigned int size() const; 323 : 324 : /** 325 : * Return the name of this table. 326 : * 327 : * This is a instance method of the class. 328 : * 329 : * @return the name of this table in a string. 330 : */ 331 : std::string getName() const; 332 : 333 : /** 334 : * Return the name of this table. 335 : * 336 : * This is a static method of the class. 337 : * 338 : * @return the name of this table in a string. 339 : */ 340 : static std::string name() ; 341 : 342 : /** 343 : * Return the version information about this table. 344 : * 345 : */ 346 : std::string getVersion() const ; 347 : 348 : /** 349 : * Return the names of the attributes of this table. 350 : * 351 : * @return a vector of string 352 : */ 353 : static const std::vector<std::string>& getAttributesNames(); 354 : 355 : /** 356 : * Return the default sorted list of attributes names in the binary representation of the table. 357 : * 358 : * @return a const reference to a vector of string 359 : */ 360 : static const std::vector<std::string>& defaultAttributesNamesInBin(); 361 : 362 : /** 363 : * Return this table's Entity. 364 : */ 365 : Entity getEntity() const; 366 : 367 : /** 368 : * Set this table's Entity. 369 : * @param e An entity. 370 : */ 371 : void setEntity(Entity e); 372 : 373 : /** 374 : * Produces an XML representation conform 375 : * to the schema defined for DelayModelFixedParameters (DelayModelFixedParametersTable.xsd). 376 : * 377 : * @returns a string containing the XML representation. 378 : * @throws ConversionException 379 : */ 380 : std::string toXML() ; 381 : 382 : #ifndef WITHOUT_ACS 383 : // Conversion Methods 384 : /** 385 : * Convert this table into a DelayModelFixedParametersTableIDL CORBA structure. 386 : * 387 : * @return a pointer to a DelayModelFixedParametersTableIDL 388 : */ 389 : asdmIDL::DelayModelFixedParametersTableIDL *toIDL() ; 390 : 391 : /** 392 : * Fills the CORBA data structure passed in parameter 393 : * with the content of this table. 394 : * 395 : * @param x a reference to the asdmIDL::DelayModelFixedParametersTableIDL to be populated 396 : * with the content of this. 397 : */ 398 : void toIDL(asdmIDL::DelayModelFixedParametersTableIDL& x) const; 399 : 400 : #endif 401 : 402 : #ifndef WITHOUT_ACS 403 : /** 404 : * Populate this table from the content of a DelayModelFixedParametersTableIDL Corba structure. 405 : * 406 : * @throws DuplicateKey Thrown if the method tries to add a row having a key that is already in the table. 407 : * @throws ConversionException 408 : */ 409 : void fromIDL(asdmIDL::DelayModelFixedParametersTableIDL x) ; 410 : #endif 411 : 412 : // 413 : // ====> Row creation. 414 : // 415 : 416 : /** 417 : * Create a new row with default values. 418 : * @return a pointer on a DelayModelFixedParametersRow 419 : */ 420 : DelayModelFixedParametersRow *newRow(); 421 : 422 : 423 : /** 424 : * Create a new row initialized to the specified values. 425 : * @return a pointer on the created and initialized row. 426 : 427 : * @param delayModelVersion 428 : 429 : * @param execBlockId 430 : 431 : */ 432 : DelayModelFixedParametersRow *newRow(std::string delayModelVersion, Tag execBlockId); 433 : 434 : 435 : 436 : /** 437 : * Create a new row using a copy constructor mechanism. 438 : * 439 : * The method creates a new DelayModelFixedParametersRow owned by this. Each attribute of the created row 440 : * is a (deep) copy of the corresponding attribute of row. The method does not add 441 : * the created row to this, its simply parents it to this, a call to the add method 442 : * has to be done in order to get the row added (very likely after having modified 443 : * some of its attributes). 444 : * If row is null then the method returns a new DelayModelFixedParametersRow with default values for its attributes. 445 : * 446 : * @param row the row which is to be copied. 447 : */ 448 : DelayModelFixedParametersRow *newRow(DelayModelFixedParametersRow *row); 449 : 450 : // 451 : // ====> Append a row to its table. 452 : // 453 : 454 : 455 : 456 : 457 : /** 458 : * Add a row. 459 : * If there table contains a row whose key's fields are equal 460 : * to x's ones then return a pointer on this row (i.e. no actual insertion is performed) 461 : * otherwise add x to the table and return x. 462 : * @param x . A pointer on the row to be added. 463 : * @returns a pointer to a DelayModelFixedParametersRow. 464 : */ 465 : 466 : DelayModelFixedParametersRow* add(DelayModelFixedParametersRow* x) ; 467 : 468 : 469 : 470 : // 471 : // ====> Methods returning rows. 472 : // 473 : 474 : /** 475 : * Get a collection of pointers on the rows of the table. 476 : * @return Alls rows in a vector of pointers of DelayModelFixedParametersRow. The elements of this vector are stored in the order 477 : * in which they have been added to the DelayModelFixedParametersTable. 478 : */ 479 : std::vector<DelayModelFixedParametersRow *> get() ; 480 : 481 : /** 482 : * Get a const reference on the collection of rows pointers internally hold by the table. 483 : * @return A const reference of a vector of pointers of DelayModelFixedParametersRow. The elements of this vector are stored in the order 484 : * in which they have been added to the DelayModelFixedParametersTable. 485 : * 486 : */ 487 : const std::vector<DelayModelFixedParametersRow *>& get() const ; 488 : 489 : 490 : 491 : 492 : 493 : /** 494 : * Returns a DelayModelFixedParametersRow* given a key. 495 : * @return a pointer to the row having the key whose values are passed as parameters, or 0 if 496 : * no row exists for that key. 497 : 498 : * @param delayModelFixedParametersId 499 : 500 : * 501 : */ 502 : DelayModelFixedParametersRow* getRowByKey(Tag delayModelFixedParametersId); 503 : 504 : 505 : 506 : 507 : 508 : /** 509 : * Look up the table for a row whose all attributes except the autoincrementable one 510 : * are equal to the corresponding parameters of the method. 511 : * @return a pointer on this row if any, null otherwise. 512 : * 513 : 514 : * @param delayModelVersion 515 : 516 : * @param execBlockId 517 : 518 : */ 519 : DelayModelFixedParametersRow* lookup(std::string delayModelVersion, Tag execBlockId); 520 : 521 : 522 : void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr); 523 : BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const; 524 : 525 : private: 526 : 527 : /** 528 : * Create a DelayModelFixedParametersTable. 529 : * <p> 530 : * This constructor is private because only the 531 : * container can create tables. All tables must know the container 532 : * to which they belong. 533 : * @param container The container to which this table belongs. 534 : */ 535 : DelayModelFixedParametersTable (ASDM & container); 536 : 537 : ASDM & container; 538 : 539 : bool archiveAsBin; // If true archive binary else archive XML 540 : bool fileAsBin ; // If true file binary else file XML 541 : 542 : std::string version ; 543 : 544 : Entity entity; 545 : 546 : 547 : 548 : 549 : 550 : // A map for the autoincrementation algorithm 551 : std::map<std::string,int> noAutoIncIds; 552 : void autoIncrement(std::string key, DelayModelFixedParametersRow* x); 553 : 554 : 555 : /** 556 : * If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and throw exception if not. 557 : * Check if *x verifies the key uniqueness rule and throw an exception if not. 558 : * Append x to its table. 559 : * @throws DuplicateKey 560 : 561 : * @throws UniquenessViolationException 562 : 563 : */ 564 : DelayModelFixedParametersRow* checkAndAdd(DelayModelFixedParametersRow* x, bool skipCheckUniqueness=false) ; 565 : 566 : /** 567 : * Brutally append an DelayModelFixedParametersRow x to the collection of rows already stored in this table. No uniqueness check is done ! 568 : * 569 : * @param DelayModelFixedParametersRow* x a pointer onto the DelayModelFixedParametersRow to be appended. 570 : */ 571 : void append(DelayModelFixedParametersRow* x) ; 572 : 573 : /** 574 : * Brutally append an DelayModelFixedParametersRow x to the collection of rows already stored in this table. No uniqueness check is done ! 575 : * 576 : * @param DelayModelFixedParametersRow* x a pointer onto the DelayModelFixedParametersRow to be appended. 577 : */ 578 : void addWithoutCheckingUnique(DelayModelFixedParametersRow* x) ; 579 : 580 : 581 : 582 : 583 : 584 : // A data structure to store the pointers on the table's rows. 585 : 586 : // In all cases we maintain a private vector of DelayModelFixedParametersRow s. 587 : std::vector<DelayModelFixedParametersRow * > privateRows; 588 : 589 : 590 : 591 : std::vector<DelayModelFixedParametersRow *> row; 592 : 593 : 594 : void error() ; //throw(ConversionException); 595 : 596 : 597 : /** 598 : * Populate this table from the content of a XML document that is required to 599 : * be conform to the XML schema defined for a DelayModelFixedParameters (DelayModelFixedParametersTable.xsd). 600 : * @throws ConversionException 601 : * 602 : */ 603 : void fromXML(std::string& xmlDoc) ; 604 : 605 : std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors; 606 : 607 : /** 608 : * Private methods involved during the build of this table out of the content 609 : * of file(s) containing an external representation of a DelayModelFixedParameters table. 610 : */ 611 : void setFromMIMEFile(const std::string& directory); 612 : /* 613 : void openMIMEFile(const std::string& directory); 614 : */ 615 : void setFromXMLFile(const std::string& directory); 616 : 617 : /** 618 : * Serialize this into a stream of bytes and encapsulates that stream into a MIME message. 619 : * @returns a string containing the MIME message. 620 : * 621 : * @param byteOrder a const pointer to a static instance of the class ByteOrder. 622 : * 623 : */ 624 : std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 625 : 626 : 627 : /** 628 : * Extracts the binary part of a MIME message and deserialize its content 629 : * to fill this with the result of the deserialization. 630 : * @param mimeMsg the string containing the MIME message. 631 : * @throws ConversionException 632 : */ 633 : void setFromMIME(const std::string & mimeMsg); 634 : 635 : /** 636 : * Private methods involved during the export of this table into disk file(s). 637 : */ 638 : std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 639 : 640 : /** 641 : * Stores a representation (binary or XML) of this table into a file. 642 : * 643 : * Depending on the boolean value of its private field fileAsBin a binary serialization of this (fileAsBin==true) 644 : * will be saved in a file "DelayModelFixedParameters.bin" or an XML representation (fileAsBin==false) will be saved in a file "DelayModelFixedParameters.xml". 645 : * The file is always written in a directory whose name is passed as a parameter. 646 : * @param directory The name of directory where the file containing the table's representation will be saved. 647 : * 648 : */ 649 : void toFile(std::string directory); 650 : 651 : /** 652 : * Load the table in memory if necessary. 653 : */ 654 : bool loadInProgress; 655 0 : void checkPresenceInMemory() { 656 0 : if (!presentInMemory && !loadInProgress) { 657 0 : loadInProgress = true; 658 0 : setFromFile(getContainer().getDirectory()); 659 0 : presentInMemory = true; 660 0 : loadInProgress = false; 661 : } 662 0 : } 663 : /** 664 : * Reads and parses a file containing a representation of a DelayModelFixedParametersTable as those produced by the toFile method. 665 : * This table is populated with the result of the parsing. 666 : * @param directory The name of the directory containing the file te be read and parsed. 667 : * @throws ConversionException If any error occurs while reading the 668 : * files in the directory or parsing them. 669 : * 670 : */ 671 : void setFromFile(const std::string& directory); 672 : 673 : }; 674 : 675 : } // End namespace asdm 676 : 677 : #endif /* DelayModelFixedParametersTable_CLASS */