casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EphemerisTable.h
Go to the documentation of this file.
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 EphemerisTable.h
32  */
33 
34 #ifndef EphemerisTable_CLASS
35 #define EphemerisTable_CLASS
36 
37 #include <string>
38 #include <vector>
39 #include <map>
40 
41 
42 
43 
45 
46 
47 
48 #include <alma/ASDM/ArrayTime.h>
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
76 
77 
78 
79 
81 #include <alma/ASDM/DuplicateKey.h>
83 #include <alma/ASDM/NoSuchRow.h>
84 #include <alma/ASDM/DuplicateKey.h>
85 
86 
87 #ifndef WITHOUT_ACS
88 #include <asdmIDLC.h>
89 #endif
90 
92 
93 #include <pthread.h>
94 
95 namespace asdm {
96 
97 //class asdm::ASDM;
98 //class asdm::EphemerisRow;
99 
100 class ASDM;
101 class EphemerisRow;
240  friend class ASDM;
241 
242 public:
243 
244 
250  static const std::vector<std::string>& getKeyName();
251 
252 
253  virtual ~EphemerisTable();
254 
260  ASDM &getContainer() const;
261 
267  unsigned int size() const;
268 
276  std::string getName() const;
277 
285  static std::string name() ;
286 
291  std::string getVersion() const ;
292 
298  static const std::vector<std::string>& getAttributesNames();
299 
305  static const std::vector<std::string>& defaultAttributesNamesInBin();
306 
310  Entity getEntity() const;
311 
316  void setEntity(Entity e);
317 
325  std::string toXML() ;
326 
327 #ifndef WITHOUT_ACS
328  // Conversion Methods
334  asdmIDL::EphemerisTableIDL *toIDL() ;
335 
343  void toIDL(asdmIDL::EphemerisTableIDL& x) const;
344 
345 #endif
346 
347 #ifndef WITHOUT_ACS
348 
354  void fromIDL(asdmIDL::EphemerisTableIDL x) ;
355 #endif
356 
357  //
358  // ====> Row creation.
359  //
360 
365  EphemerisRow *newRow();
366 
367 
393  EphemerisRow *newRow(ArrayTimeInterval timeInterval, int ephemerisId, std::vector<double > observerLocation, double equinoxEquator, int numPolyDir, std::vector<std::vector<double > > dir, int numPolyDist, std::vector<double > distance, ArrayTime timeOrigin, std::string origin);
394 
395 
396 
410 
411  //
412  // ====> Append a row to its table.
413  //
414 
415 
433 
434 
435 
436 
437 
438  //
439  // ====> Methods returning rows.
440  //
441 
447  std::vector<EphemerisRow *> get() ;
448 
455  const std::vector<EphemerisRow *>& get() const ;
456 
457 
468  std::vector <EphemerisRow*> *getByContext(int ephemerisId);
469 
470 
471 
472 
473 
485  EphemerisRow* getRowByKey(ArrayTimeInterval timeInterval, int ephemerisId);
486 
487 
488 
489 
490 
518  EphemerisRow* lookup(ArrayTimeInterval timeInterval, int ephemerisId, std::vector<double > observerLocation, double equinoxEquator, int numPolyDir, std::vector<std::vector<double > > dir, int numPolyDist, std::vector<double > distance, ArrayTime timeOrigin, std::string origin);
519 
520 
521  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
522  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
523 
524 private:
525 
535 
537 
538  bool archiveAsBin; // If true archive binary else archive XML
539  bool fileAsBin ; // If true file binary else file XML
540 
541  std::string version ;
542 
544 
545 
546 
547 
548 
549 
557  EphemerisRow* checkAndAdd(EphemerisRow* x, bool skipCheckUniqueness=false) ;
558 
564  void append(EphemerisRow* x) ;
565 
572 
573 
574 
575 
576 
577 
585  EphemerisRow * insertByStartTime(EphemerisRow* x, std::vector<EphemerisRow* >& row);
586 
587 
588 
589 // A data structure to store the pointers on the table's rows.
590 
591 // In all cases we maintain a private vector of EphemerisRow s.
592  std::vector<EphemerisRow * > privateRows;
593 
594 
595 
596 
597 
598 
599 
600 
601  typedef std::vector <EphemerisRow* > TIME_ROWS;
602  std::map<std::string, TIME_ROWS > context;
603 
608  std::string Key(int ephemerisId) ;
609 
610 
611 
612 
618  void getByKeyNoAutoIncNoTime(std::vector <EphemerisRow*>& vin, std::vector <EphemerisRow*>& vout, int ephemerisId);
619 
620 
621 
622  void error() ; //throw(ConversionException);
623 
624 
631  void fromXML(std::string& xmlDoc) ;
632 
633  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
634 
639  void setFromMIMEFile(const std::string& directory);
640  /*
641  void openMIMEFile(const std::string& directory);
642  */
643  void setFromXMLFile(const std::string& directory);
644 
652  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
653 
654 
661  void setFromMIME(const std::string & mimeMsg);
662 
666  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
667 
677  void toFile(std::string directory);
678 
684  if (!presentInMemory && !loadInProgress) {
685  loadInProgress = true;
686  setFromFile(getContainer().getDirectory());
687  presentInMemory = true;
688  loadInProgress = false;
689  }
690  }
699  void setFromFile(const std::string& directory);
700 
701 };
702 
703 } // End namespace asdm
704 
705 #endif /* EphemerisTable_CLASS */
EphemerisRow * getRowByKey(ArrayTimeInterval timeInterval, int ephemerisId)
Returns a EphemerisRow* given a key.
std::string toXML()
Produces an XML representation conform to the schema defined for Ephemeris (EphemerisTable.xsd).
static const ByteOrder * Machine_Endianity
Definition: Misc.h:119
unsigned int size() const
Return the number of rows in the table.
void setFromXMLFile(const std::string &directory)
void setFromMIMEFile(const std::string &directory)
Private methods involved during the build of this table out of the content of file(s) containing an e...
void setFromMIME(const std::string &mimeMsg)
Extracts the binary part of a MIME message and deserialize its content to fill this with the result o...
The EphemerisTable class is an Alma table.
void getByKeyNoAutoIncNoTime(std::vector< EphemerisRow * > &vin, std::vector< EphemerisRow * > &vout, int ephemerisId)
Fills the vector vout (passed by reference) with pointers on elements of vin whose attributes are equ...
struct _xmlDoc xmlDoc
Definition: Misc.h:59
The ArrayTimeInterval class aggregates an instance of ArrayTime and an instance of Interval...
static const std::vector< std::string > & getKeyName()
Return the list of field names that make up key key as an array of strings.
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
A class to represent byte order information.
Definition: Misc.h:115
asdmIDL::EphemerisTableIDL * toIDL()
Conversion Methods.
The ASDM class is the container for all tables.
Definition: ASDM.h:273
void addWithoutCheckingUnique(EphemerisRow *x)
Brutally append an EphemerisRow x to the collection of rows already stored in this table...
EphemerisRow * add(EphemerisRow *x)
====&gt; Append a row to its table.
EphemerisTable(ASDM &container)
Create a EphemerisTable.
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a EphemerisTable as those produced by the toFi...
static std::string name()
Return the name of this table.
std::string Key(int ephemerisId)
Returns a string built by concatenating the ascii representation of the parameters values suffixed wi...
virtual ~EphemerisTable()
The EphemerisRow class is a row of a EphemerisTable.
Definition: EphemerisRow.h:114
std::map< std::string, TIME_ROWS > context
void setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
std::vector< EphemerisRow * > privateRows
A data structure to store the pointers on the table&#39;s rows.
ASDM & getContainer() const
Return the container to which this table belongs.
std::vector< EphemerisRow * > * getByContext(int ephemerisId)
Returns all the rows sorted by ascending startTime for a given context.
std::string toMIME(const asdm::ByteOrder *byteOrder=asdm::ByteOrder::Machine_Endianity)
Serialize this into a stream of bytes and encapsulates that stream into a MIME message.
EphemerisRow * newRow()
====&gt; Row creation.
static const std::vector< std::string > & getAttributesNames()
Return the names of the attributes of this table.
Entity getEntity() const
Return this table&#39;s Entity.
The ArrayTime class implements the concept of a point in time, implemented as an Interval of time sin...
Definition: ArrayTime.h:89
void fromIDL(asdmIDL::EphemerisTableIDL x)
Populate this table from the content of a EphemerisTableIDL Corba structure.
std::string getVersion() const
Return the version information about this table.
virtual Origin origin() const =0
ABSTRACT METHODS //.
void fromXML(std::string &xmlDoc)
Populate this table from the content of a XML document that is required to be conform to the XML sche...
void toFile(std::string directory)
Stores a representation (binary or XML) of this table into a file.
std::string MIMEXMLPart(const asdm::ByteOrder *byteOrder=asdm::ByteOrder::Machine_Endianity)
Private methods involved during the export of this table into disk file(s).
A pure virtual class whose derived classes are expected to be functors whose behaviours will be to re...
Definition: EndianStream.h:117
static const std::vector< std::string > & defaultAttributesNamesInBin()
Return the default sorted list of attributes names in the binary representation of the table...
The Representable interface is implemented by all tables and by the container.
Definition: Representable.h:53
std::vector< EphemerisRow * > TIME_ROWS
const Double e
e and functions thereof:
void append(EphemerisRow *x)
Brutally append an EphemerisRow x to the collection of rows already stored in this table...
EphemerisRow * checkAndAdd(EphemerisRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
bool loadInProgress
Load the table in memory if necessary.
EphemerisRow * lookup(ArrayTimeInterval timeInterval, int ephemerisId, std::vector< double > observerLocation, double equinoxEquator, int numPolyDir, std::vector< std::vector< double > > dir, int numPolyDist, std::vector< double > distance, ArrayTime timeOrigin, std::string origin)
Look up the table for a row whose all attributes are equal to the corresponding parameters of the met...
void setEntity(Entity e)
Set this table&#39;s Entity.
EphemerisRow * insertByStartTime(EphemerisRow *x, std::vector< EphemerisRow * > &row)
Insert a EphemerisRow* in a vector of EphemerisRow* so that it&#39;s ordered by ascending time...
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59
std::string getName() const
Return the name of this table.