casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
WeatherTable.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 WeatherTable.h
32  */
33 
34 #ifndef WeatherTable_CLASS
35 #define WeatherTable_CLASS
36 
37 #include <string>
38 #include <vector>
39 #include <map>
40 
41 
42 
43 
44 #include <alma/ASDM/Speed.h>
45 
46 
47 
49 
50 
51 
52 #include <alma/ASDM/Temperature.h>
53 
54 
55 
56 #include <alma/ASDM/Angle.h>
57 
58 
59 
60 #include <alma/ASDM/Length.h>
61 
62 
63 
64 #include <alma/ASDM/Humidity.h>
65 
66 
67 
68 #include <alma/ASDM/Tag.h>
69 
70 
71 
72 #include <alma/ASDM/Pressure.h>
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 
103 
104 
105 
106 
107 
108 
109 
111 #include <alma/ASDM/DuplicateKey.h>
113 #include <alma/ASDM/NoSuchRow.h>
114 #include <alma/ASDM/DuplicateKey.h>
115 
116 
117 #ifndef WITHOUT_ACS
118 #include <asdmIDLC.h>
119 #endif
120 
121 #include <alma/ASDM/Representable.h>
122 
123 #include <pthread.h>
124 
125 namespace asdm {
126 
127 //class asdm::ASDM;
128 //class asdm::WeatherRow;
129 
130 class ASDM;
131 class WeatherRow;
272 class WeatherTable : public Representable {
273  friend class ASDM;
274 
275 public:
276 
277 
283  static const std::vector<std::string>& getKeyName();
284 
285 
286  virtual ~WeatherTable();
287 
293  ASDM &getContainer() const;
294 
300  unsigned int size() const;
301 
309  std::string getName() const;
310 
318  static std::string name() ;
319 
324  std::string getVersion() const ;
325 
331  static const std::vector<std::string>& getAttributesNames();
332 
338  static const std::vector<std::string>& defaultAttributesNamesInBin();
339 
343  Entity getEntity() const;
344 
349  void setEntity(Entity e);
350 
358  std::string toXML() ;
359 
360 #ifndef WITHOUT_ACS
361  // Conversion Methods
367  asdmIDL::WeatherTableIDL *toIDL() ;
368 
376  void toIDL(asdmIDL::WeatherTableIDL& x) const;
377 
378 #endif
379 
380 #ifndef WITHOUT_ACS
381 
387  void fromIDL(asdmIDL::WeatherTableIDL x) ;
388 #endif
389 
390  //
391  // ====> Row creation.
392  //
393 
398  WeatherRow *newRow();
399 
400 
410  WeatherRow *newRow(Tag stationId, ArrayTimeInterval timeInterval);
411 
412 
413 
426  WeatherRow *newRow(WeatherRow *row);
427 
428  //
429  // ====> Append a row to its table.
430  //
431 
432 
449  WeatherRow* add(WeatherRow* x) ;
450 
451 
452 
453 
454 
455  //
456  // ====> Methods returning rows.
457  //
458 
464  std::vector<WeatherRow *> get() ;
465 
472  const std::vector<WeatherRow *>& get() const ;
473 
474 
485  std::vector <WeatherRow*> *getByContext(Tag stationId);
486 
487 
488 
489 
490 
502  WeatherRow* getRowByKey(Tag stationId, ArrayTimeInterval timeInterval);
503 
504 
505 
506 
507 
519  WeatherRow* lookup(Tag stationId, ArrayTimeInterval timeInterval);
520 
521 
522  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
523  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
524 
525 private:
526 
536 
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 
545 
546 
547 
548 
549 
550 
558  WeatherRow* checkAndAdd(WeatherRow* x, bool skipCheckUniqueness=false) ;
559 
565  void append(WeatherRow* x) ;
566 
573 
574 
575 
576 
577 
578 
586  WeatherRow * insertByStartTime(WeatherRow* x, std::vector<WeatherRow* >& row);
587 
588 
589 
590 // A data structure to store the pointers on the table's rows.
591 
592 // In all cases we maintain a private vector of WeatherRow s.
593  std::vector<WeatherRow * > privateRows;
594 
595 
596 
597 
598 
599 
600 
601 
602  typedef std::vector <WeatherRow* > TIME_ROWS;
603  std::map<std::string, TIME_ROWS > context;
604 
609  std::string Key(Tag stationId) ;
610 
611 
612 
613 
619  void getByKeyNoAutoIncNoTime(std::vector <WeatherRow*>& vin, std::vector <WeatherRow*>& vout, Tag stationId);
620 
621 
622 
623  void error() ; //throw(ConversionException);
624 
625 
632  void fromXML(std::string& xmlDoc) ;
633 
634  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
635 
640  void setFromMIMEFile(const std::string& directory);
641  /*
642  void openMIMEFile(const std::string& directory);
643  */
644  void setFromXMLFile(const std::string& directory);
645 
653  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
654 
655 
662  void setFromMIME(const std::string & mimeMsg);
663 
667  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
668 
678  void toFile(std::string directory);
679 
685  if (!presentInMemory && !loadInProgress) {
686  loadInProgress = true;
687  setFromFile(getContainer().getDirectory());
688  presentInMemory = true;
689  loadInProgress = false;
690  }
691  }
700  void setFromFile(const std::string& directory);
701 
702 };
703 
704 } // End namespace asdm
705 
706 #endif /* WeatherTable_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
void setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
struct _xmlDoc xmlDoc
Definition: Misc.h:59
The ArrayTimeInterval class aggregates an instance of ArrayTime and an instance of Interval...
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
Definition: WeatherTable.h:634
WeatherTable(ASDM &container)
Create a WeatherTable.
virtual ~WeatherTable()
void append(WeatherRow *x)
Brutally append an WeatherRow x to the collection of rows already stored in this table.
A class to represent byte order information.
Definition: Misc.h:115
ASDM & getContainer() const
Return the container to which this table belongs.
std::string version
Definition: WeatherTable.h:542
WeatherRow * checkAndAdd(WeatherRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
std::string getName() const
Return the name of this table.
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...
std::string Key(Tag stationId)
Returns a string built by concatenating the ascii representation of the parameters values suffixed wi...
The ASDM class is the container for all tables.
Definition: ASDM.h:273
std::vector< WeatherRow * > TIME_ROWS
Definition: WeatherTable.h:602
WeatherRow * getRowByKey(Tag stationId, ArrayTimeInterval timeInterval)
Returns a WeatherRow* given a key.
std::vector< WeatherRow * > * getByContext(Tag stationId)
Returns all the rows sorted by ascending startTime for a given context.
std::string getVersion() const
Return the version information about this table.
void setFromXMLFile(const std::string &directory)
static const std::vector< std::string > & getKeyName()
Return the list of field names that make up key key as an array of strings.
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a WeatherTable as those produced by the toFile...
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...
std::string toXML()
Produces an XML representation conform to the schema defined for Weather (WeatherTable.xsd).
void checkPresenceInMemory()
Definition: WeatherTable.h:684
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
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.
std::vector< WeatherRow * > privateRows
A data structure to store the pointers on the table&#39;s rows.
Definition: WeatherTable.h:593
bool loadInProgress
Load the table in memory if necessary.
Definition: WeatherTable.h:683
Entity getEntity() const
Return this table&#39;s Entity.
WeatherRow * add(WeatherRow *x)
====&gt; Append a row to its table.
std::map< std::string, TIME_ROWS > context
Definition: WeatherTable.h:603
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...
WeatherRow * insertByStartTime(WeatherRow *x, std::vector< WeatherRow * > &row)
Insert a WeatherRow* in a vector of WeatherRow* so that it&#39;s ordered by ascending time...
The Tag class is an implementation of a unique index identifying a row of an ASDM table...
Definition: Tag.h:73
void getByKeyNoAutoIncNoTime(std::vector< WeatherRow * > &vin, std::vector< WeatherRow * > &vout, Tag stationId)
Fills the vector vout (passed by reference) with pointers on elements of vin whose attributes are equ...
void setEntity(Entity e)
Set this table&#39;s Entity.
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
static std::string name()
Return the name of this table.
const Double e
e and functions thereof:
asdmIDL::WeatherTableIDL * toIDL()
Conversion Methods.
unsigned int size() const
Return the number of rows in the table.
The WeatherTable class is an Alma table.
Definition: WeatherTable.h:272
WeatherRow * newRow()
====&gt; Row creation.
The WeatherRow class is a row of a WeatherTable.
Definition: WeatherRow.h:147
void fromIDL(asdmIDL::WeatherTableIDL x)
Populate this table from the content of a WeatherTableIDL Corba structure.
static const std::vector< std::string > & getAttributesNames()
Return the names of the attributes of this table.
void toFile(std::string directory)
Stores a representation (binary or XML) of this table into a file.
WeatherRow * lookup(Tag stationId, ArrayTimeInterval timeInterval)
Look up the table for a row whose all attributes are equal to the corresponding parameters of the met...
std::string MIMEXMLPart(const asdm::ByteOrder *byteOrder=asdm::ByteOrder::Machine_Endianity)
Private methods involved during the export of this table into disk file(s).
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59
void addWithoutCheckingUnique(WeatherRow *x)
Brutally append an WeatherRow x to the collection of rows already stored in this table.