casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CalDataTable.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 CalDataTable.h
32  */
33 
34 #ifndef CalDataTable_CLASS
35 #define CalDataTable_CLASS
36 
37 #include <string>
38 #include <vector>
39 #include <map>
40 
41 
42 
43 
44 #include <alma/ASDM/ArrayTime.h>
45 
46 
47 
48 #include <alma/ASDM/Tag.h>
49 
50 
51 
52 #include <alma/ASDM/EntityRef.h>
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
68 
69 
70 
72 
73 
74 
75 
76 
77 
78 
79 
80 
82 
83 
84 
85 
86 
87 
88 
89 
90 
92 
93 
94 
95 
97 #include <alma/ASDM/DuplicateKey.h>
99 #include <alma/ASDM/NoSuchRow.h>
100 #include <alma/ASDM/DuplicateKey.h>
101 
102 
103 #ifndef WITHOUT_ACS
104 #include <asdmIDLC.h>
105 #endif
106 
107 #include <alma/ASDM/Representable.h>
108 
109 #include <pthread.h>
110 
111 namespace asdm {
112 
113 //class asdm::ASDM;
114 //class asdm::CalDataRow;
115 
116 class ASDM;
117 class CalDataRow;
245 class CalDataTable : public Representable {
246  friend class ASDM;
247 
248 public:
249 
250 
256  static const std::vector<std::string>& getKeyName();
257 
258 
259  virtual ~CalDataTable();
260 
266  ASDM &getContainer() const;
267 
273  unsigned int size() const;
274 
282  std::string getName() const;
283 
291  static std::string name() ;
292 
297  std::string getVersion() const ;
298 
304  static const std::vector<std::string>& getAttributesNames();
305 
311  static const std::vector<std::string>& defaultAttributesNamesInBin();
312 
316  Entity getEntity() const;
317 
322  void setEntity(Entity e);
323 
331  std::string toXML() ;
332 
333 #ifndef WITHOUT_ACS
334  // Conversion Methods
340  asdmIDL::CalDataTableIDL *toIDL() ;
341 
349  void toIDL(asdmIDL::CalDataTableIDL& x) const;
350 
351 #endif
352 
353 #ifndef WITHOUT_ACS
354 
360  void fromIDL(asdmIDL::CalDataTableIDL x) ;
361 #endif
362 
363  //
364  // ====> Row creation.
365  //
366 
371  CalDataRow *newRow();
372 
373 
393  CalDataRow *newRow(ArrayTime startTimeObserved, ArrayTime endTimeObserved, EntityRef execBlockUID, CalDataOriginMod::CalDataOrigin calDataType, CalTypeMod::CalType calType, int numScan, std::vector<int > scanSet);
394 
395 
396 
410 
411  //
412  // ====> Append a row to its table.
413  //
414 
415 
416 
417 
427  CalDataRow* add(CalDataRow* x) ;
428 
429 
430 
431  //
432  // ====> Methods returning rows.
433  //
434 
440  std::vector<CalDataRow *> get() ;
441 
448  const std::vector<CalDataRow *>& get() const ;
449 
450 
451 
452 
453 
463  CalDataRow* getRowByKey(Tag calDataId);
464 
465 
466 
467 
468 
490  CalDataRow* lookup(ArrayTime startTimeObserved, ArrayTime endTimeObserved, EntityRef execBlockUID, CalDataOriginMod::CalDataOrigin calDataType, CalTypeMod::CalType calType, int numScan, std::vector<int > scanSet);
491 
492 
493  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
494  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
495 
496 private:
497 
507 
509 
510  bool archiveAsBin; // If true archive binary else archive XML
511  bool fileAsBin ; // If true file binary else file XML
512 
513  std::string version ;
514 
516 
517 
518 
519 
520 
521  // A map for the autoincrementation algorithm
522  std::map<std::string,int> noAutoIncIds;
523  void autoIncrement(std::string key, CalDataRow* x);
524 
525 
535  CalDataRow* checkAndAdd(CalDataRow* x, bool skipCheckUniqueness=false) ;
536 
542  void append(CalDataRow* x) ;
543 
550 
551 
552 
553 
554 
555 // A data structure to store the pointers on the table's rows.
556 
557 // In all cases we maintain a private vector of CalDataRow s.
558  std::vector<CalDataRow * > privateRows;
559 
560 
561 
562  std::vector<CalDataRow *> row;
563 
564 
565  void error() ; //throw(ConversionException);
566 
567 
574  void fromXML(std::string& xmlDoc) ;
575 
576  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
577 
582  void setFromMIMEFile(const std::string& directory);
583  /*
584  void openMIMEFile(const std::string& directory);
585  */
586  void setFromXMLFile(const std::string& directory);
587 
595  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
596 
597 
604  void setFromMIME(const std::string & mimeMsg);
605 
609  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
610 
620  void toFile(std::string directory);
621 
627  if (!presentInMemory && !loadInProgress) {
628  loadInProgress = true;
629  setFromFile(getContainer().getDirectory());
630  presentInMemory = true;
631  loadInProgress = false;
632  }
633  }
642  void setFromFile(const std::string& directory);
643 
644 };
645 
646 } // End namespace asdm
647 
648 #endif /* CalDataTable_CLASS */
CalDataRow * lookup(ArrayTime startTimeObserved, ArrayTime endTimeObserved, EntityRef execBlockUID, CalDataOriginMod::CalDataOrigin calDataType, CalTypeMod::CalType calType, int numScan, std::vector< int > scanSet)
Look up the table for a row whose all attributes except the autoincrementable one are equal to the co...
static const ByteOrder * Machine_Endianity
Definition: Misc.h:119
void addWithoutCheckingUnique(CalDataRow *x)
Brutally append an CalDataRow x to the collection of rows already stored in this table.
CalDataRow * checkAndAdd(CalDataRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
struct _xmlDoc xmlDoc
Definition: Misc.h:59
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a CalDataTable as those produced by the toFile...
ASDM & getContainer() const
Return the container to which this table belongs.
std::string getVersion() const
Return the version information about this table.
A class to represent byte order information.
Definition: Misc.h:115
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 > & getAttributesNames()
Return the names of the attributes of this table.
bool loadInProgress
Load the table in memory if necessary.
Definition: CalDataTable.h:625
std::string getName() const
Return the name of this table.
The ASDM class is the container for all tables.
Definition: ASDM.h:273
std::map< std::string, int > noAutoIncIds
A map for the autoincrementation algorithm.
Definition: CalDataTable.h:522
void fromIDL(asdmIDL::CalDataTableIDL x)
Populate this table from the content of a CalDataTableIDL Corba structure.
void append(CalDataRow *x)
Brutally append an CalDataRow x to the collection of rows already stored in this table.
std::vector< CalDataRow * > privateRows
A data structure to store the pointers on the table&#39;s rows.
Definition: CalDataTable.h:558
void checkPresenceInMemory()
Definition: CalDataTable.h:626
CalDataTable(ASDM &container)
Create a CalDataTable.
std::string version
Definition: CalDataTable.h:513
void setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
CalDataRow * newRow()
====&gt; Row creation.
unsigned int size() const
Return the number of rows in the table.
The EntityRef class is an identification of a persistant entity in the ALMA archive.
Definition: EntityRef.h:58
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...
std::string toXML()
Produces an XML representation conform to the schema defined for CalData (CalDataTable.xsd).
asdmIDL::CalDataTableIDL * toIDL()
Conversion Methods.
Entity getEntity() const
Return this table&#39;s Entity.
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
Definition: CalDataTable.h:576
virtual ~CalDataTable()
void autoIncrement(std::string key, CalDataRow *x)
CalDataRow * add(CalDataRow *x)
====&gt; Append a row to its table.
void setEntity(Entity e)
Set 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
The Tag class is an implementation of a unique index identifying a row of an ASDM table...
Definition: Tag.h:73
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...
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
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 setFromXMLFile(const std::string &directory)
const Double e
e and functions thereof:
std::vector< CalDataRow * > row
Definition: CalDataTable.h:562
static std::string name()
Return the name of this table.
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).
The CalDataTable class is an Alma table.
Definition: CalDataTable.h:245
The CalDataRow class is a row of a CalDataTable.
Definition: CalDataRow.h:130
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 toMIME(const asdm::ByteOrder *byteOrder=asdm::ByteOrder::Machine_Endianity)
Serialize this into a stream of bytes and encapsulates that stream into a MIME message.
static const std::vector< std::string > & getKeyName()
Return the list of field names that make up key key as an array of strings.
CalDataRow * getRowByKey(Tag calDataId)
Returns a CalDataRow* given a key.
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59