casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SeeingTable.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 SeeingTable.h
32  */
33 
34 #ifndef SeeingTable_CLASS
35 #define SeeingTable_CLASS
36 
37 #include <string>
38 #include <vector>
39 #include <map>
40 
41 
42 
43 
45 
46 
47 
48 #include <alma/ASDM/Angle.h>
49 
50 
51 
52 #include <alma/ASDM/Length.h>
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
73 #include <alma/ASDM/DuplicateKey.h>
75 #include <alma/ASDM/NoSuchRow.h>
76 #include <alma/ASDM/DuplicateKey.h>
77 
78 
79 #ifndef WITHOUT_ACS
80 #include <asdmIDLC.h>
81 #endif
82 
84 
85 #include <pthread.h>
86 
87 namespace asdm {
88 
89 //class asdm::ASDM;
90 //class asdm::SeeingRow;
91 
92 class ASDM;
93 class SeeingRow;
162 class SeeingTable : public Representable {
163  friend class ASDM;
164 
165 public:
166 
167 
173  static const std::vector<std::string>& getKeyName();
174 
175 
176  virtual ~SeeingTable();
177 
183  ASDM &getContainer() const;
184 
190  unsigned int size() const;
191 
199  std::string getName() const;
200 
208  static std::string name() ;
209 
214  std::string getVersion() const ;
215 
221  static const std::vector<std::string>& getAttributesNames();
222 
228  static const std::vector<std::string>& defaultAttributesNamesInBin();
229 
233  Entity getEntity() const;
234 
239  void setEntity(Entity e);
240 
248  std::string toXML() ;
249 
250 #ifndef WITHOUT_ACS
251  // Conversion Methods
257  asdmIDL::SeeingTableIDL *toIDL() ;
258 
266  void toIDL(asdmIDL::SeeingTableIDL& x) const;
267 
268 #endif
269 
270 #ifndef WITHOUT_ACS
271 
277  void fromIDL(asdmIDL::SeeingTableIDL x) ;
278 #endif
279 
280  //
281  // ====> Row creation.
282  //
283 
288  SeeingRow *newRow();
289 
290 
308  SeeingRow *newRow(ArrayTimeInterval timeInterval, int numBaseLength, std::vector<Length > baseLength, std::vector<Angle > phaseRms, float seeing, float exponent);
309 
310 
311 
325 
326  //
327  // ====> Append a row to its table.
328  //
329 
330 
347  SeeingRow* add(SeeingRow* x) ;
348 
349 
350 
351 
352 
353  //
354  // ====> Methods returning rows.
355  //
356 
362  std::vector<SeeingRow *> get() ;
363 
370  const std::vector<SeeingRow *>& get() const ;
371 
372 
383  std::vector <SeeingRow*> *getByContext();
384 
385 
386 
387 
388 
398  SeeingRow* getRowByKey(ArrayTimeInterval timeInterval);
399 
400 
401 
402 
403 
423  SeeingRow* lookup(ArrayTimeInterval timeInterval, int numBaseLength, std::vector<Length > baseLength, std::vector<Angle > phaseRms, float seeing, float exponent);
424 
425 
426  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
427  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
428 
429 private:
430 
440 
442 
443  bool archiveAsBin; // If true archive binary else archive XML
444  bool fileAsBin ; // If true file binary else file XML
445 
446  std::string version ;
447 
449 
450 
451 
452 
453 
454 
462  SeeingRow* checkAndAdd(SeeingRow* x, bool skipCheckUniqueness=false) ;
463 
469  void append(SeeingRow* x) ;
470 
477 
478 
479 
480 
481 
482 
490  SeeingRow * insertByStartTime(SeeingRow* x, std::vector<SeeingRow* >& row);
491 
492 
493 
494 // A data structure to store the pointers on the table's rows.
495 
496 // In all cases we maintain a private vector of SeeingRow s.
497  std::vector<SeeingRow * > privateRows;
498 
499 
500 
501 
502 
503 
504 
505 
506  std::vector <SeeingRow *> row;
507 
508 
509 
510 
511 
512 
513  void error() ; //throw(ConversionException);
514 
515 
522  void fromXML(std::string& xmlDoc) ;
523 
524  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
525 
530  void setFromMIMEFile(const std::string& directory);
531  /*
532  void openMIMEFile(const std::string& directory);
533  */
534  void setFromXMLFile(const std::string& directory);
535 
543  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
544 
545 
552  void setFromMIME(const std::string & mimeMsg);
553 
557  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
558 
568  void toFile(std::string directory);
569 
575  if (!presentInMemory && !loadInProgress) {
576  loadInProgress = true;
577  setFromFile(getContainer().getDirectory());
578  presentInMemory = true;
579  loadInProgress = false;
580  }
581  }
590  void setFromFile(const std::string& directory);
591 
592 };
593 
594 } // End namespace asdm
595 
596 #endif /* SeeingTable_CLASS */
static const std::vector< std::string > & defaultAttributesNamesInBin()
Return the default sorted list of attributes names in the binary representation of the table...
static const ByteOrder * Machine_Endianity
Definition: Misc.h:119
static std::string name()
Return the name of this table.
SeeingTable(ASDM &container)
Create a SeeingTable.
unsigned int size() const
Return the number of rows in the table.
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
Definition: SeeingTable.h:524
struct _xmlDoc xmlDoc
Definition: Misc.h:59
The ArrayTimeInterval class aggregates an instance of ArrayTime and an instance of Interval...
std::vector< SeeingRow * > privateRows
A data structure to store the pointers on the table&#39;s rows.
Definition: SeeingTable.h:497
A class to represent byte order information.
Definition: Misc.h:115
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 fromIDL(asdmIDL::SeeingTableIDL x)
Populate this table from the content of a SeeingTableIDL Corba structure.
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
The ASDM class is the container for all tables.
Definition: ASDM.h:273
std::vector< SeeingRow * > * getByContext()
Returns all the rows sorted by ascending startTime for a given context.
SeeingRow * newRow()
====&gt; Row creation.
void toFile(std::string directory)
Stores a representation (binary or XML) of this table into a file.
void checkPresenceInMemory()
Definition: SeeingTable.h:574
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...
The SeeingTable class is an Alma table.
Definition: SeeingTable.h:162
std::vector< SeeingRow * > row
Definition: SeeingTable.h:506
std::string getVersion() const
Return the version information about this table.
asdmIDL::SeeingTableIDL * toIDL()
Conversion Methods.
SeeingRow * insertByStartTime(SeeingRow *x, std::vector< SeeingRow * > &row)
Insert a SeeingRow* in a vector of SeeingRow* so that it&#39;s ordered by ascending time.
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.
virtual ~SeeingTable()
The SeeingRow class is a row of a SeeingTable.
Definition: SeeingRow.h:106
std::string toXML()
Produces an XML representation conform to the schema defined for Seeing (SeeingTable.xsd).
Entity getEntity() const
Return this table&#39;s Entity.
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...
void append(SeeingRow *x)
Brutally append an SeeingRow x to the collection of rows already stored in this table.
static const std::vector< std::string > & getAttributesNames()
Return the names of the attributes of this table.
A pure virtual class whose derived classes are expected to be functors whose behaviours will be to re...
Definition: EndianStream.h:117
The Representable interface is implemented by all tables and by the container.
Definition: Representable.h:53
const Double e
e and functions thereof:
void setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
std::string getName() const
Return the name of this table.
ASDM & getContainer() const
Return the container to which this table belongs.
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a SeeingTable as those produced by the toFile ...
std::string MIMEXMLPart(const asdm::ByteOrder *byteOrder=asdm::ByteOrder::Machine_Endianity)
Private methods involved during the export of this table into disk file(s).
SeeingRow * lookup(ArrayTimeInterval timeInterval, int numBaseLength, std::vector< Length > baseLength, std::vector< Angle > phaseRms, float seeing, float exponent)
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.
void addWithoutCheckingUnique(SeeingRow *x)
Brutally append an SeeingRow x to the collection of rows already stored in this table.
SeeingRow * checkAndAdd(SeeingRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
static const std::vector< std::string > & getKeyName()
Return the list of field names that make up key key as an array of strings.
SeeingRow * getRowByKey(ArrayTimeInterval timeInterval)
Returns a SeeingRow* given a key.
bool loadInProgress
Load the table in memory if necessary.
Definition: SeeingTable.h:573
void setFromXMLFile(const std::string &directory)
std::string version
Definition: SeeingTable.h:446
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59
SeeingRow * add(SeeingRow *x)
====&gt; Append a row to its table.