casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ObservationTable.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 ObservationTable.h
32  */
33 
34 #ifndef ObservationTable_CLASS
35 #define ObservationTable_CLASS
36 
37 #include <string>
38 #include <vector>
39 #include <map>
40 
41 
42 
43 
44 #include <alma/ASDM/Tag.h>
45 
46 
47 
48 
49 
50 
51 
52 
53 
55 #include <alma/ASDM/DuplicateKey.h>
57 #include <alma/ASDM/NoSuchRow.h>
58 #include <alma/ASDM/DuplicateKey.h>
59 
60 
61 #ifndef WITHOUT_ACS
62 #include <asdmIDLC.h>
63 #endif
64 
66 
67 #include <pthread.h>
68 
69 namespace asdm {
70 
71 //class asdm::ASDM;
72 //class asdm::ObservationRow;
73 
74 class ASDM;
75 class ObservationRow;
107  friend class ASDM;
108 
109 public:
110 
111 
117  static const std::vector<std::string>& getKeyName();
118 
119 
120  virtual ~ObservationTable();
121 
127  ASDM &getContainer() const;
128 
134  unsigned int size() const;
135 
143  std::string getName() const;
144 
152  static std::string name() ;
153 
158  std::string getVersion() const ;
159 
165  static const std::vector<std::string>& getAttributesNames();
166 
172  static const std::vector<std::string>& defaultAttributesNamesInBin();
173 
177  Entity getEntity() const;
178 
183  void setEntity(Entity e);
184 
192  std::string toXML() ;
193 
194 #ifndef WITHOUT_ACS
195  // Conversion Methods
201  asdmIDL::ObservationTableIDL *toIDL() ;
202 
210  void toIDL(asdmIDL::ObservationTableIDL& x) const;
211 
212 #endif
213 
214 #ifndef WITHOUT_ACS
215 
221  void fromIDL(asdmIDL::ObservationTableIDL x) ;
222 #endif
223 
224  //
225  // ====> Row creation.
226  //
227 
233 
234 
235 
249 
250  //
251  // ====> Append a row to its table.
252  //
253 
254 
255 
256 
267 
268 
269 
270  //
271  // ====> Methods returning rows.
272  //
273 
279  std::vector<ObservationRow *> get() ;
280 
287  const std::vector<ObservationRow *>& get() const ;
288 
289 
290 
291 
292 
302  ObservationRow* getRowByKey(Tag observationId);
303 
304 
305 
306 
307 
308 
309  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
310  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
311 
312 private:
313 
323 
325 
326  bool archiveAsBin; // If true archive binary else archive XML
327  bool fileAsBin ; // If true file binary else file XML
328 
329  std::string version ;
330 
332 
333 
334 
335 
336 
337  // A map for the autoincrementation algorithm
338  std::map<std::string,int> noAutoIncIds;
339  void autoIncrement(std::string key, ObservationRow* x);
340 
341 
351  ObservationRow* checkAndAdd(ObservationRow* x, bool skipCheckUniqueness=false) ;
352 
358  void append(ObservationRow* x) ;
359 
366 
367 
368 
369 
370 
371 // A data structure to store the pointers on the table's rows.
372 
373 // In all cases we maintain a private vector of ObservationRow s.
374  std::vector<ObservationRow * > privateRows;
375 
376 
377 
378  std::vector<ObservationRow *> row;
379 
380 
381  void error() ; //throw(ConversionException);
382 
383 
390  void fromXML(std::string& xmlDoc) ;
391 
392  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
393 
398  void setFromMIMEFile(const std::string& directory);
399  /*
400  void openMIMEFile(const std::string& directory);
401  */
402  void setFromXMLFile(const std::string& directory);
403 
411  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
412 
413 
420  void setFromMIME(const std::string & mimeMsg);
421 
425  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
426 
436  void toFile(std::string directory);
437 
443  if (!presentInMemory && !loadInProgress) {
444  loadInProgress = true;
445  setFromFile(getContainer().getDirectory());
446  presentInMemory = true;
447  loadInProgress = false;
448  }
449  }
458  void setFromFile(const std::string& directory);
459 
460 };
461 
462 } // End namespace asdm
463 
464 #endif /* ObservationTable_CLASS */
ObservationTable(ASDM &container)
Create a ObservationTable.
void setEntity(Entity e)
Set this table&#39;s Entity.
static const ByteOrder * Machine_Endianity
Definition: Misc.h:119
static const std::vector< std::string > & getAttributesNames()
Return the names of the attributes of this table.
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
ASDM & getContainer() const
Return the container to which this table belongs.
ObservationRow * checkAndAdd(ObservationRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a ObservationTable as those produced by the to...
struct _xmlDoc xmlDoc
Definition: Misc.h:59
A class to represent byte order information.
Definition: Misc.h:115
void addWithoutCheckingUnique(ObservationRow *x)
Brutally append an ObservationRow x to the collection of rows already stored in this table...
ObservationRow * add(ObservationRow *x)
====&gt; Append a row to its table.
The ASDM class is the container for all tables.
Definition: ASDM.h:273
std::string MIMEXMLPart(const asdm::ByteOrder *byteOrder=asdm::ByteOrder::Machine_Endianity)
Private methods involved during the export of this table into disk file(s).
void autoIncrement(std::string key, ObservationRow *x)
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.
asdmIDL::ObservationTableIDL * toIDL()
Conversion Methods.
void fromIDL(asdmIDL::ObservationTableIDL x)
Populate this table from the content of a ObservationTableIDL Corba structure.
void setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
The ObservationTable class is an Alma table.
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
std::vector< ObservationRow * > privateRows
A data structure to store the pointers on the table&#39;s rows.
std::map< std::string, int > noAutoIncIds
A map for the autoincrementation algorithm.
static const std::vector< std::string > & defaultAttributesNamesInBin()
Return the default sorted list of attributes names in the binary representation of the table...
static const std::vector< std::string > & getKeyName()
Return the list of field names that make up key key as an array of strings.
std::string toXML()
Produces an XML representation conform to the schema defined for Observation (ObservationTable.xsd).
void toFile(std::string directory)
Stores a representation (binary or XML) of this table into a file.
std::string getName() const
Return the name of this table.
The Tag class is an implementation of a unique index identifying a row of an ASDM table...
Definition: Tag.h:73
bool loadInProgress
Load the table in memory if necessary.
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
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...
const Double e
e and functions thereof:
std::vector< ObservationRow * > row
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 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 append(ObservationRow *x)
Brutally append an ObservationRow x to the collection of rows already stored in this table...
void setFromXMLFile(const std::string &directory)
ObservationRow * newRow()
====&gt; Row creation.
The ObservationRow class is a row of a ObservationTable.
ObservationRow * getRowByKey(Tag observationId)
Returns a ObservationRow* given a key.
static std::string name()
Return the name of this table.
Entity getEntity() const
Return this table&#39;s Entity.
unsigned int size() const
Return the number of rows in the table.
std::string getVersion() const
Return the version information about this table.
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59