casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SysCalTable.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 SysCalTable.h
32  */
33 
34 #ifndef SysCalTable_CLASS
35 #define SysCalTable_CLASS
36 
37 #include <string>
38 #include <vector>
39 #include <map>
40 
41 
42 
43 
45 
46 
47 
48 #include <alma/ASDM/Temperature.h>
49 
50 
51 
52 #include <alma/ASDM/Tag.h>
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
76 
77 
78 
79 
80 
81 
82 
83 
84 
85 
86 
87 
88 
89 
90 
91 
92 
93 
95 #include <alma/ASDM/DuplicateKey.h>
97 #include <alma/ASDM/NoSuchRow.h>
98 #include <alma/ASDM/DuplicateKey.h>
99 
100 
101 #ifndef WITHOUT_ACS
102 #include <asdmIDLC.h>
103 #endif
104 
105 #include <alma/ASDM/Representable.h>
106 
107 #include <pthread.h>
108 
109 namespace asdm {
110 
111 //class asdm::ASDM;
112 //class asdm::SysCalRow;
113 
114 class ASDM;
115 class SysCalRow;
291 class SysCalTable : public Representable {
292  friend class ASDM;
293 
294 public:
295 
296 
302  static const std::vector<std::string>& getKeyName();
303 
304 
305  virtual ~SysCalTable();
306 
312  ASDM &getContainer() const;
313 
319  unsigned int size() const;
320 
328  std::string getName() const;
329 
337  static std::string name() ;
338 
343  std::string getVersion() const ;
344 
350  static const std::vector<std::string>& getAttributesNames();
351 
357  static const std::vector<std::string>& defaultAttributesNamesInBin();
358 
362  Entity getEntity() const;
363 
368  void setEntity(Entity e);
369 
377  std::string toXML() ;
378 
379 #ifndef WITHOUT_ACS
380  // Conversion Methods
386  asdmIDL::SysCalTableIDL *toIDL() ;
387 
395  void toIDL(asdmIDL::SysCalTableIDL& x) const;
396 
397 #endif
398 
399 #ifndef WITHOUT_ACS
400 
406  void fromIDL(asdmIDL::SysCalTableIDL x) ;
407 #endif
408 
409  //
410  // ====> Row creation.
411  //
412 
417  SysCalRow *newRow();
418 
419 
437  SysCalRow *newRow(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId, int numReceptor, int numChan);
438 
439 
440 
453  SysCalRow *newRow(SysCalRow *row);
454 
455  //
456  // ====> Append a row to its table.
457  //
458 
459 
476  SysCalRow* add(SysCalRow* x) ;
477 
478 
479 
480 
481 
482  //
483  // ====> Methods returning rows.
484  //
485 
491  std::vector<SysCalRow *> get() ;
492 
499  const std::vector<SysCalRow *>& get() const ;
500 
501 
512  std::vector <SysCalRow*> *getByContext(Tag antennaId, Tag spectralWindowId, int feedId);
513 
514 
515 
516 
517 
533  SysCalRow* getRowByKey(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId);
534 
535 
536 
537 
538 
558  SysCalRow* lookup(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId, int numReceptor, int numChan);
559 
560 
561  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
562  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
563 
564 private:
565 
575 
577 
578  bool archiveAsBin; // If true archive binary else archive XML
579  bool fileAsBin ; // If true file binary else file XML
580 
581  std::string version ;
582 
584 
585 
586 
587 
588 
589 
597  SysCalRow* checkAndAdd(SysCalRow* x, bool skipCheckUniqueness=false) ;
598 
604  void append(SysCalRow* x) ;
605 
612 
613 
614 
615 
616 
617 
625  SysCalRow * insertByStartTime(SysCalRow* x, std::vector<SysCalRow* >& row);
626 
627 
628 
629 // A data structure to store the pointers on the table's rows.
630 
631 // In all cases we maintain a private vector of SysCalRow s.
632  std::vector<SysCalRow * > privateRows;
633 
634 
635 
636 
637 
638 
639 
640 
641  typedef std::vector <SysCalRow* > TIME_ROWS;
642  std::map<std::string, TIME_ROWS > context;
643 
648  std::string Key(Tag antennaId, Tag spectralWindowId, int feedId) ;
649 
650 
651 
652 
658  void getByKeyNoAutoIncNoTime(std::vector <SysCalRow*>& vin, std::vector <SysCalRow*>& vout, Tag antennaId, Tag spectralWindowId, int feedId);
659 
660 
661 
662  void error() ; //throw(ConversionException);
663 
664 
671  void fromXML(std::string& xmlDoc) ;
672 
673  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
674 
679  void setFromMIMEFile(const std::string& directory);
680  /*
681  void openMIMEFile(const std::string& directory);
682  */
683  void setFromXMLFile(const std::string& directory);
684 
692  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
693 
694 
701  void setFromMIME(const std::string & mimeMsg);
702 
706  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
707 
717  void toFile(std::string directory);
718 
724  if (!presentInMemory && !loadInProgress) {
725  loadInProgress = true;
726  setFromFile(getContainer().getDirectory());
727  presentInMemory = true;
728  loadInProgress = false;
729  }
730  }
739  void setFromFile(const std::string& directory);
740 
741 };
742 
743 } // End namespace asdm
744 
745 #endif /* SysCalTable_CLASS */
std::string Key(Tag antennaId, Tag spectralWindowId, int feedId)
Returns a string built by concatenating the ascii representation of the parameters values suffixed wi...
std::vector< SysCalRow * > privateRows
A data structure to store the pointers on the table&#39;s rows.
Definition: SysCalTable.h:632
void getByKeyNoAutoIncNoTime(std::vector< SysCalRow * > &vin, std::vector< SysCalRow * > &vout, Tag antennaId, Tag spectralWindowId, int feedId)
Fills the vector vout (passed by reference) with pointers on elements of vin whose attributes are equ...
SysCalTable(ASDM &container)
Create a SysCalTable.
static const ByteOrder * Machine_Endianity
Definition: Misc.h:119
std::string getVersion() const
Return the version information about this table.
virtual ~SysCalTable()
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a SysCalTable as those produced by the toFile ...
void setEntity(Entity e)
Set this table&#39;s Entity.
std::vector< SysCalRow * > TIME_ROWS
Definition: SysCalTable.h:641
unsigned int size() const
Return the number of rows in the table.
void toFile(std::string directory)
Stores a representation (binary or XML) of this table into a file.
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...
struct _xmlDoc xmlDoc
Definition: Misc.h:59
The ArrayTimeInterval class aggregates an instance of ArrayTime and an instance of Interval...
bool loadInProgress
Load the table in memory if necessary.
Definition: SysCalTable.h:722
std::string MIMEXMLPart(const asdm::ByteOrder *byteOrder=asdm::ByteOrder::Machine_Endianity)
Private methods involved during the export of this table into disk file(s).
A class to represent byte order information.
Definition: Misc.h:115
SysCalRow * insertByStartTime(SysCalRow *x, std::vector< SysCalRow * > &row)
Insert a SysCalRow* in a vector of SysCalRow* so that it&#39;s ordered by ascending time.
void setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
static const std::vector< std::string > & defaultAttributesNamesInBin()
Return the default sorted list of attributes names in the binary representation of the table...
The ASDM class is the container for all tables.
Definition: ASDM.h:273
std::string version
Definition: SysCalTable.h:581
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
Definition: SysCalTable.h:673
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...
SysCalRow * newRow()
====&gt; Row creation.
std::map< std::string, TIME_ROWS > context
Definition: SysCalTable.h:642
void addWithoutCheckingUnique(SysCalRow *x)
Brutally append an SysCalRow x to the collection of rows already stored in this table.
SysCalRow * getRowByKey(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId)
Returns a SysCalRow* given a key.
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...
SysCalRow * checkAndAdd(SysCalRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
static std::string name()
Return the name of this table.
Entity getEntity() const
Return this table&#39;s Entity.
SysCalRow * add(SysCalRow *x)
====&gt; Append a row to its table.
asdmIDL::SysCalTableIDL * toIDL()
Conversion Methods.
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< SysCalRow * > * getByContext(Tag antennaId, Tag spectralWindowId, int feedId)
Returns all the rows sorted by ascending startTime for a given context.
void setFromXMLFile(const std::string &directory)
The SysCalTable class is an Alma table.
Definition: SysCalTable.h:291
The Tag class is an implementation of a unique index identifying a row of an ASDM table...
Definition: Tag.h:73
static const std::vector< std::string > & getKeyName()
Return the list of field names that make up key key as an array of strings.
SysCalRow * lookup(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId, int numReceptor, int numChan)
Look up the table for a row whose all attributes are equal to the corresponding parameters of the met...
void checkPresenceInMemory()
Definition: SysCalTable.h:723
static const std::vector< std::string > & getAttributesNames()
Return the names of the attributes of this table.
The SysCalRow class is a row of a SysCalTable.
Definition: SysCalRow.h:137
void append(SysCalRow *x)
Brutally append an SysCalRow x to the collection of rows already stored in 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
void fromIDL(asdmIDL::SysCalTableIDL x)
Populate this table from the content of a SysCalTableIDL Corba structure.
const Double e
e and functions thereof:
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
std::string toXML()
Produces an XML representation conform to the schema defined for SysCal (SysCalTable.xsd).
ASDM & getContainer() const
Return the container to which this table belongs.
std::string getName() const
Return the name of this table.
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59