casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SourceTable.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 SourceTable.h
32  */
33 
34 #ifndef SourceTable_CLASS
35 #define SourceTable_CLASS
36 
37 #include <string>
38 #include <vector>
39 #include <map>
40 
41 
42 
43 
44 #include <alma/ASDM/Speed.h>
45 
46 
47 
48 #include <alma/ASDM/AngularRate.h>
49 
50 
51 
52 #include <alma/ASDM/ArrayTime.h>
53 
54 
55 
56 #include <alma/ASDM/Flux.h>
57 
58 
59 
61 
62 
63 
64 #include <alma/ASDM/Angle.h>
65 
66 
67 
68 #include <alma/ASDM/Length.h>
69 
70 
71 
72 #include <alma/ASDM/Frequency.h>
73 
74 
75 
76 #include <alma/ASDM/Tag.h>
77 
78 
79 
80 
81 
82 
83 
84 
85 
86 
87 
88 
89 
90 
91 
92 
93 
94 
96 
97 
98 
99 
100 
101 
102 
103 
104 
105 
106 
107 
108 
109 
110 
111 
112 
113 
114 
115 
116 
117 
118 
120 
121 
122 
124 
125 
126 
127 
128 
129 
130 
131 
132 
133 
134 
136 
137 
138 
139 
140 
141 
142 
143 
144 
145 
146 
147 
148 
149 
150 
152 
153 
154 
155 
156 
158 
159 
160 
162 
163 
164 
165 
166 
167 
169 #include <alma/ASDM/DuplicateKey.h>
171 #include <alma/ASDM/NoSuchRow.h>
172 #include <alma/ASDM/DuplicateKey.h>
173 
174 
175 #ifndef WITHOUT_ACS
176 #include <asdmIDLC.h>
177 #endif
178 
179 #include <alma/ASDM/Representable.h>
180 
181 #include <pthread.h>
182 
183 namespace asdm {
184 
185 //class asdm::ASDM;
186 //class asdm::SourceRow;
187 
188 class ASDM;
189 class SourceRow;
475 class SourceTable : public Representable {
476  friend class ASDM;
477 
478 public:
479 
480 
486  static const std::vector<std::string>& getKeyName();
487 
488 
489  virtual ~SourceTable();
490 
496  ASDM &getContainer() const;
497 
503  unsigned int size() const;
504 
512  std::string getName() const;
513 
521  static std::string name() ;
522 
527  std::string getVersion() const ;
528 
534  static const std::vector<std::string>& getAttributesNames();
535 
541  static const std::vector<std::string>& defaultAttributesNamesInBin();
542 
546  Entity getEntity() const;
547 
552  void setEntity(Entity e);
553 
561  std::string toXML() ;
562 
563 #ifndef WITHOUT_ACS
564  // Conversion Methods
570  asdmIDL::SourceTableIDL *toIDL() ;
571 
579  void toIDL(asdmIDL::SourceTableIDL& x) const;
580 
581 #endif
582 
583 #ifndef WITHOUT_ACS
584 
590  void fromIDL(asdmIDL::SourceTableIDL x) ;
591 #endif
592 
593  //
594  // ====> Row creation.
595  //
596 
601  SourceRow *newRow();
602 
603 
621  SourceRow *newRow(ArrayTimeInterval timeInterval, Tag spectralWindowId, std::string code, std::vector<Angle > direction, std::vector<AngularRate > properMotion, std::string sourceName);
622 
623 
624 
637  SourceRow *newRow(SourceRow *row);
638 
639  //
640  // ====> Append a row to its table.
641  //
642 
643 
644 
645 
646 
656  SourceRow* add(SourceRow* x) ;
657 
658 
659 
660  //
661  // ====> Methods returning rows.
662  //
663 
669  std::vector<SourceRow *> get() ;
670 
677  const std::vector<SourceRow *>& get() const ;
678 
679 
680 
681 
682 
696  SourceRow* getRowByKey(int sourceId, ArrayTimeInterval timeInterval, Tag spectralWindowId);
697 
698 
699 
707  std::vector <SourceRow *> getRowBySourceId(int);
708 
709 
710 
730  SourceRow* lookup(ArrayTimeInterval timeInterval, Tag spectralWindowId, std::string code, std::vector<Angle > direction, std::vector<AngularRate > properMotion, std::string sourceName);
731 
732 
733  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
734  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
735 
736 private:
737 
747 
749 
750  bool archiveAsBin; // If true archive binary else archive XML
751  bool fileAsBin ; // If true file binary else file XML
752 
753  std::string version ;
754 
756 
757 
758 
759 
760  /*
761  ** Let's use a map to implement the condition "one sourceName -> one sourceId"
762  */
763  std::map<const std::string, int> name2id_m;
764 
765 
766 
767 
777  SourceRow* checkAndAdd(SourceRow* x, bool skipCheckUniqueness=false) ;
778 
784  void append(SourceRow* x) ;
785 
792 
793 
794 
795 
796 
797 
805  SourceRow * insertByStartTime(SourceRow* x, std::vector<SourceRow* >& row);
806 
807 
808 
809 // A data structure to store the pointers on the table's rows.
810 
811 // In all cases we maintain a private vector of SourceRow s.
812  std::vector<SourceRow * > privateRows;
813 
814 
815 
816 
817 
818 
819 
820 
821  typedef std::vector <std::vector <SourceRow* > > ID_TIME_ROWS;
822  std::map<std::string, ID_TIME_ROWS > context;
823 
828  std::string Key(Tag spectralWindowId) ;
829 
830 
831 
832 
838  void getByKeyNoAutoIncNoTime(std::vector <SourceRow*>& vin, std::vector <SourceRow*>& vout, Tag spectralWindowId);
839 
840 
841 
842  void error() ; //throw(ConversionException);
843 
844 
851  void fromXML(std::string& xmlDoc) ;
852 
853  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
854 
859  void setFromMIMEFile(const std::string& directory);
860  /*
861  void openMIMEFile(const std::string& directory);
862  */
863  void setFromXMLFile(const std::string& directory);
864 
872  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
873 
874 
881  void setFromMIME(const std::string & mimeMsg);
882 
886  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
887 
897  void toFile(std::string directory);
898 
904  if (!presentInMemory && !loadInProgress) {
905  loadInProgress = true;
906  setFromFile(getContainer().getDirectory());
907  presentInMemory = true;
908  loadInProgress = false;
909  }
910  }
919  void setFromFile(const std::string& directory);
920 
921 };
922 
923 } // End namespace asdm
924 
925 #endif /* SourceTable_CLASS */
SourceRow * lookup(ArrayTimeInterval timeInterval, Tag spectralWindowId, std::string code, std::vector< Angle > direction, std::vector< AngularRate > properMotion, std::string sourceName)
Look up the table for a row whose all attributes except the autoincrementable one are equal to the co...
static const std::vector< std::string > & getKeyName()
Return the list of field names that make up key key as an array of strings.
void checkPresenceInMemory()
Definition: SourceTable.h:903
static const ByteOrder * Machine_Endianity
Definition: Misc.h:119
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
Definition: SourceTable.h:853
std::string MIMEXMLPart(const asdm::ByteOrder *byteOrder=asdm::ByteOrder::Machine_Endianity)
Private methods involved during the export of this table into disk file(s).
struct _xmlDoc xmlDoc
Definition: Misc.h:59
The ArrayTimeInterval class aggregates an instance of ArrayTime and an instance of Interval...
void getByKeyNoAutoIncNoTime(std::vector< SourceRow * > &vin, std::vector< SourceRow * > &vout, Tag spectralWindowId)
Fills the vector vout (passed by reference) with pointers on elements of vin whose attributes are equ...
A class to represent byte order information.
Definition: Misc.h:115
std::string toXML()
Produces an XML representation conform to the schema defined for Source (SourceTable.xsd).
The SourceTable class is an Alma table.
Definition: SourceTable.h:475
unsigned int size() const
Return the number of rows in the table.
std::string getVersion() const
Return the version information about this table.
The ASDM class is the container for all tables.
Definition: ASDM.h:273
The SourceRow class is a row of a SourceTable.
Definition: SourceRow.h:205
bool loadInProgress
Load the table in memory if necessary.
Definition: SourceTable.h:902
SourceRow * insertByStartTime(SourceRow *x, std::vector< SourceRow * > &row)
Insert a SourceRow* in a vector of SourceRow* so that it&#39;s ordered by ascending time.
SourceRow * checkAndAdd(SourceRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
SourceTable(ASDM &container)
Create a SourceTable.
static std::string name()
Return the name of this table.
std::string getName() const
Return the name of this table.
void toFile(std::string directory)
Stores a representation (binary or XML) of this table into a file.
std::map< std::string, ID_TIME_ROWS > context
Definition: SourceTable.h:822
SourceRow * getRowByKey(int sourceId, ArrayTimeInterval timeInterval, Tag spectralWindowId)
Returns a SourceRow* given a key.
std::vector< SourceRow * > getRowBySourceId(int)
Returns a vector of pointers on rows whose key element sourceId is equal to the parameter sourceId...
Entity getEntity() const
Return this table&#39;s Entity.
void setFromXMLFile(const std::string &directory)
std::string Key(Tag spectralWindowId)
Returns a string built by concatenating the ascii representation of the parameters values suffixed wi...
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< SourceRow * > privateRows
A data structure to store the pointers on the table&#39;s rows.
Definition: SourceTable.h:812
std::string version
Definition: SourceTable.h:753
asdmIDL::SourceTableIDL * toIDL()
Conversion Methods.
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...
The Tag class is an implementation of a unique index identifying a row of an ASDM table...
Definition: Tag.h:73
virtual ~SourceTable()
SourceRow * newRow()
====&gt; Row creation.
ASDM & getContainer() const
Return the container to which this table belongs.
void setEntity(Entity e)
Set this table&#39;s Entity.
void addWithoutCheckingUnique(SourceRow *x)
Brutally append an SourceRow 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
static const std::vector< std::string > & getAttributesNames()
Return the names of the attributes of this table.
const Double e
e and functions thereof:
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
std::map< const std::string, int > name2id_m
Definition: SourceTable.h:763
SourceRow * add(SourceRow *x)
====&gt; Append a row to its table.
void setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
std::vector< std::vector< SourceRow * > > ID_TIME_ROWS
Definition: SourceTable.h:821
void append(SourceRow *x)
Brutally append an SourceRow x to the collection of rows already stored in this table.
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a SourceTable as those produced by the toFile ...
static const std::vector< std::string > & defaultAttributesNamesInBin()
Return the default sorted list of attributes names in the binary representation of the table...
void fromIDL(asdmIDL::SourceTableIDL x)
Populate this table from the content of a SourceTableIDL Corba structure.
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59
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...