casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CalReductionTable.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 CalReductionTable.h
32  */
33 
34 #ifndef CalReductionTable_CLASS
35 #define CalReductionTable_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 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
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::CalReductionRow;
99 
100 class ASDM;
101 class CalReductionRow;
206  friend class ASDM;
207 
208 public:
209 
210 
216  static const std::vector<std::string>& getKeyName();
217 
218 
219  virtual ~CalReductionTable();
220 
226  ASDM &getContainer() const;
227 
233  unsigned int size() const;
234 
242  std::string getName() const;
243 
251  static std::string name() ;
252 
257  std::string getVersion() const ;
258 
264  static const std::vector<std::string>& getAttributesNames();
265 
271  static const std::vector<std::string>& defaultAttributesNamesInBin();
272 
276  Entity getEntity() const;
277 
282  void setEntity(Entity e);
283 
291  std::string toXML() ;
292 
293 #ifndef WITHOUT_ACS
294  // Conversion Methods
300  asdmIDL::CalReductionTableIDL *toIDL() ;
301 
309  void toIDL(asdmIDL::CalReductionTableIDL& x) const;
310 
311 #endif
312 
313 #ifndef WITHOUT_ACS
314 
320  void fromIDL(asdmIDL::CalReductionTableIDL x) ;
321 #endif
322 
323  //
324  // ====> Row creation.
325  //
326 
332 
333 
359  CalReductionRow *newRow(int numApplied, std::vector<std::string > appliedCalibrations, int numParam, std::vector<std::string > paramSet, int numInvalidConditions, std::vector<InvalidatingConditionMod::InvalidatingCondition > invalidConditions, ArrayTime timeReduced, std::string messages, std::string software, std::string softwareVersion);
360 
361 
362 
376 
377  //
378  // ====> Append a row to its table.
379  //
380 
381 
382 
383 
394 
395 
396 
397  //
398  // ====> Methods returning rows.
399  //
400 
406  std::vector<CalReductionRow *> get() ;
407 
414  const std::vector<CalReductionRow *>& get() const ;
415 
416 
417 
418 
419 
429  CalReductionRow* getRowByKey(Tag calReductionId);
430 
431 
432 
433 
434 
462  CalReductionRow* lookup(int numApplied, std::vector<std::string > appliedCalibrations, int numParam, std::vector<std::string > paramSet, int numInvalidConditions, std::vector<InvalidatingConditionMod::InvalidatingCondition > invalidConditions, ArrayTime timeReduced, std::string messages, std::string software, std::string softwareVersion);
463 
464 
465  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
466  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
467 
468 private:
469 
479 
481 
482  bool archiveAsBin; // If true archive binary else archive XML
483  bool fileAsBin ; // If true file binary else file XML
484 
485  std::string version ;
486 
488 
489 
490 
491 
492 
493  // A map for the autoincrementation algorithm
494  std::map<std::string,int> noAutoIncIds;
495  void autoIncrement(std::string key, CalReductionRow* x);
496 
497 
507  CalReductionRow* checkAndAdd(CalReductionRow* x, bool skipCheckUniqueness=false) ;
508 
514  void append(CalReductionRow* x) ;
515 
522 
523 
524 
525 
526 
527 // A data structure to store the pointers on the table's rows.
528 
529 // In all cases we maintain a private vector of CalReductionRow s.
530  std::vector<CalReductionRow * > privateRows;
531 
532 
533 
534  std::vector<CalReductionRow *> row;
535 
536 
537  void error() ; //throw(ConversionException);
538 
539 
546  void fromXML(std::string& xmlDoc) ;
547 
548  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
549 
554  void setFromMIMEFile(const std::string& directory);
555  /*
556  void openMIMEFile(const std::string& directory);
557  */
558  void setFromXMLFile(const std::string& directory);
559 
567  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
568 
569 
576  void setFromMIME(const std::string & mimeMsg);
577 
581  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
582 
592  void toFile(std::string directory);
593 
599  if (!presentInMemory && !loadInProgress) {
600  loadInProgress = true;
601  setFromFile(getContainer().getDirectory());
602  presentInMemory = true;
603  loadInProgress = false;
604  }
605  }
614  void setFromFile(const std::string& directory);
615 
616 };
617 
618 } // End namespace asdm
619 
620 #endif /* CalReductionTable_CLASS */
ASDM & getContainer() const
Return the container to which this table belongs.
static const ByteOrder * Machine_Endianity
Definition: Misc.h:119
CalReductionRow * getRowByKey(Tag calReductionId)
Returns a CalReductionRow* given a key.
bool loadInProgress
Load the table in memory if necessary.
struct _xmlDoc xmlDoc
Definition: Misc.h:59
void addWithoutCheckingUnique(CalReductionRow *x)
Brutally append an CalReductionRow x to the collection of rows already stored in this table...
CalReductionRow * checkAndAdd(CalReductionRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
std::string getVersion() const
Return the version information about this table.
A class to represent byte order information.
Definition: Misc.h:115
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 setFromXMLFile(const std::string &directory)
void setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
The ASDM class is the container for all tables.
Definition: ASDM.h:273
void autoIncrement(std::string key, CalReductionRow *x)
void fromIDL(asdmIDL::CalReductionTableIDL x)
Populate this table from the content of a CalReductionTableIDL Corba structure.
std::vector< CalReductionRow * > 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.
unsigned int size() const
Return the number of rows in the table.
The CalReductionTable class is an Alma table.
void setEntity(Entity e)
Set this table&#39;s Entity.
std::string toXML()
Produces an XML representation conform to the schema defined for CalReduction (CalReductionTable.xsd).
std::vector< CalReductionRow * > row
asdmIDL::CalReductionTableIDL * toIDL()
Conversion Methods.
CalReductionTable(ASDM &container)
Create a CalReductionTable.
The CalReductionRow class is a row of a CalReductionTable.
static const std::vector< std::string > & defaultAttributesNamesInBin()
Return the default sorted list of attributes names in the binary representation of the table...
void append(CalReductionRow *x)
Brutally append an CalReductionRow x to the collection of rows already stored in this table...
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
static std::string name()
Return the name of this table.
The ArrayTime class implements the concept of a point in time, implemented as an Interval of time sin...
Definition: ArrayTime.h:89
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...
Entity getEntity() const
Return this table&#39;s Entity.
The Tag class is an implementation of a unique index identifying a row of an ASDM table...
Definition: Tag.h:73
void toFile(std::string directory)
Stores a representation (binary or XML) of this table into a file.
CalReductionRow * newRow()
====&gt; Row creation.
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 setFromMIMEFile(const std::string &directory)
Private methods involved during the build of this table out of the content of file(s) containing an e...
static const std::vector< std::string > & getKeyName()
Return the list of field names that make up key key as an array of strings.
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...
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.
static const std::vector< std::string > & getAttributesNames()
Return the names of the attributes of this table.
CalReductionRow * lookup(int numApplied, std::vector< std::string > appliedCalibrations, int numParam, std::vector< std::string > paramSet, int numInvalidConditions, std::vector< InvalidatingConditionMod::InvalidatingCondition > invalidConditions, ArrayTime timeReduced, std::string messages, std::string software, std::string softwareVersion)
Look up the table for a row whose all attributes except the autoincrementable one are equal to the co...
std::string getName() const
Return the name of this table.
CalReductionRow * add(CalReductionRow *x)
====&gt; Append a row to its table.
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a CalReductionTable as those produced by the t...
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59