casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CalDeviceTable.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 CalDeviceTable.h
32  */
33 
34 #ifndef CalDeviceTable_CLASS
35 #define CalDeviceTable_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 
64 
65 
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
76 
77 
79 #include <alma/ASDM/DuplicateKey.h>
81 #include <alma/ASDM/NoSuchRow.h>
82 #include <alma/ASDM/DuplicateKey.h>
83 
84 
85 #ifndef WITHOUT_ACS
86 #include <asdmIDLC.h>
87 #endif
88 
90 
91 #include <pthread.h>
92 
93 namespace asdm {
94 
95 //class asdm::ASDM;
96 //class asdm::CalDeviceRow;
97 
98 class ASDM;
99 class CalDeviceRow;
213  friend class ASDM;
214 
215 public:
216 
217 
223  static const std::vector<std::string>& getKeyName();
224 
225 
226  virtual ~CalDeviceTable();
227 
233  ASDM &getContainer() const;
234 
240  unsigned int size() const;
241 
249  std::string getName() const;
250 
258  static std::string name() ;
259 
264  std::string getVersion() const ;
265 
271  static const std::vector<std::string>& getAttributesNames();
272 
278  static const std::vector<std::string>& defaultAttributesNamesInBin();
279 
283  Entity getEntity() const;
284 
289  void setEntity(Entity e);
290 
298  std::string toXML() ;
299 
300 #ifndef WITHOUT_ACS
301  // Conversion Methods
307  asdmIDL::CalDeviceTableIDL *toIDL() ;
308 
316  void toIDL(asdmIDL::CalDeviceTableIDL& x) const;
317 
318 #endif
319 
320 #ifndef WITHOUT_ACS
321 
327  void fromIDL(asdmIDL::CalDeviceTableIDL x) ;
328 #endif
329 
330  //
331  // ====> Row creation.
332  //
333 
338  CalDeviceRow *newRow();
339 
340 
358  CalDeviceRow *newRow(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId, int numCalload, std::vector<CalibrationDeviceMod::CalibrationDevice > calLoadNames);
359 
360 
361 
375 
376  //
377  // ====> Append a row to its table.
378  //
379 
380 
398 
399 
400 
401 
402 
403  //
404  // ====> Methods returning rows.
405  //
406 
412  std::vector<CalDeviceRow *> get() ;
413 
420  const std::vector<CalDeviceRow *>& get() const ;
421 
422 
433  std::vector <CalDeviceRow*> *getByContext(Tag antennaId, Tag spectralWindowId, int feedId);
434 
435 
436 
437 
438 
454  CalDeviceRow* getRowByKey(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId);
455 
456 
457 
458 
459 
479  CalDeviceRow* lookup(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId, int numCalload, std::vector<CalibrationDeviceMod::CalibrationDevice > calLoadNames);
480 
481 
482  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
483  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
484 
485 private:
486 
496 
498 
499  bool archiveAsBin; // If true archive binary else archive XML
500  bool fileAsBin ; // If true file binary else file XML
501 
502  std::string version ;
503 
505 
506 
507 
508 
509 
510 
518  CalDeviceRow* checkAndAdd(CalDeviceRow* x, bool skipCheckUniqueness=false) ;
519 
525  void append(CalDeviceRow* x) ;
526 
533 
534 
535 
536 
537 
538 
546  CalDeviceRow * insertByStartTime(CalDeviceRow* x, std::vector<CalDeviceRow* >& row);
547 
548 
549 
550 // A data structure to store the pointers on the table's rows.
551 
552 // In all cases we maintain a private vector of CalDeviceRow s.
553  std::vector<CalDeviceRow * > privateRows;
554 
555 
556 
557 
558 
559 
560 
561 
562  typedef std::vector <CalDeviceRow* > TIME_ROWS;
563  std::map<std::string, TIME_ROWS > context;
564 
569  std::string Key(Tag antennaId, Tag spectralWindowId, int feedId) ;
570 
571 
572 
573 
579  void getByKeyNoAutoIncNoTime(std::vector <CalDeviceRow*>& vin, std::vector <CalDeviceRow*>& vout, Tag antennaId, Tag spectralWindowId, int feedId);
580 
581 
582 
583  void error() ; //throw(ConversionException);
584 
585 
592  void fromXML(std::string& xmlDoc) ;
593 
594  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
595 
600  void setFromMIMEFile(const std::string& directory);
601  /*
602  void openMIMEFile(const std::string& directory);
603  */
604  void setFromXMLFile(const std::string& directory);
605 
613  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
614 
615 
622  void setFromMIME(const std::string & mimeMsg);
623 
627  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
628 
638  void toFile(std::string directory);
639 
645  if (!presentInMemory && !loadInProgress) {
646  loadInProgress = true;
647  setFromFile(getContainer().getDirectory());
648  presentInMemory = true;
649  loadInProgress = false;
650  }
651  }
660  void setFromFile(const std::string& directory);
661 
662 };
663 
664 } // End namespace asdm
665 
666 #endif /* CalDeviceTable_CLASS */
unsigned int size() const
Return the number of rows in the table.
void setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
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.
The CalDeviceRow class is a row of a CalDeviceTable.
Definition: CalDeviceRow.h:121
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 ByteOrder * Machine_Endianity
Definition: Misc.h:119
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
std::string toXML()
Produces an XML representation conform to the schema defined for CalDevice (CalDeviceTable.xsd).
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a CalDeviceTable as those produced by the toFi...
CalDeviceRow * insertByStartTime(CalDeviceRow *x, std::vector< CalDeviceRow * > &row)
Insert a CalDeviceRow* in a vector of CalDeviceRow* so that it&#39;s ordered by ascending time...
struct _xmlDoc xmlDoc
Definition: Misc.h:59
The ArrayTimeInterval class aggregates an instance of ArrayTime and an instance of Interval...
void toFile(std::string directory)
Stores a representation (binary or XML) of this table into a file.
A class to represent byte order information.
Definition: Misc.h:115
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...
The ASDM class is the container for all tables.
Definition: ASDM.h:273
CalDeviceRow * newRow()
====&gt; Row creation.
std::string Key(Tag antennaId, Tag spectralWindowId, int feedId)
Returns a string built by concatenating the ascii representation of the parameters values suffixed wi...
CalDeviceRow * add(CalDeviceRow *x)
====&gt; Append a row to its table.
static std::string name()
Return the name of this table.
std::vector< CalDeviceRow * > * getByContext(Tag antennaId, Tag spectralWindowId, int feedId)
Returns all the rows sorted by ascending startTime for a given context.
static const std::vector< std::string > & defaultAttributesNamesInBin()
Return the default sorted list of attributes names in the binary representation of the table...
CalDeviceRow * lookup(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId, int numCalload, std::vector< CalibrationDeviceMod::CalibrationDevice > calLoadNames)
Look up the table for a row whose all attributes are equal to the corresponding parameters of the met...
ASDM & getContainer() const
Return the container to which this table belongs.
static const std::vector< std::string > & getKeyName()
Return the list of field names that make up key key as an array of strings.
void fromIDL(asdmIDL::CalDeviceTableIDL x)
Populate this table from the content of a CalDeviceTableIDL Corba structure.
void setEntity(Entity e)
Set this table&#39;s Entity.
void addWithoutCheckingUnique(CalDeviceRow *x)
Brutally append an CalDeviceRow x to the collection of rows already stored in this table...
bool loadInProgress
Load the table in memory if necessary.
void getByKeyNoAutoIncNoTime(std::vector< CalDeviceRow * > &vin, std::vector< CalDeviceRow * > &vout, Tag antennaId, Tag spectralWindowId, int feedId)
Fills the vector vout (passed by reference) with pointers on elements of vin whose attributes are equ...
CalDeviceRow * getRowByKey(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId)
Returns a CalDeviceRow* given a key.
virtual ~CalDeviceTable()
CalDeviceRow * checkAndAdd(CalDeviceRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
std::vector< CalDeviceRow * > TIME_ROWS
The Tag class is an implementation of a unique index identifying a row of an ASDM table...
Definition: Tag.h:73
std::string getVersion() const
Return the version information about this table.
The CalDeviceTable class is an Alma table.
void append(CalDeviceRow *x)
Brutally append an CalDeviceRow x to the collection of rows already stored in this table...
std::string getName() const
Return the name of this table.
Entity getEntity() const
Return this table&#39;s Entity.
std::map< std::string, TIME_ROWS > context
static const std::vector< std::string > & getAttributesNames()
Return the names of the attributes of this table.
std::vector< CalDeviceRow * > privateRows
A data structure to store the pointers on the table&#39;s rows.
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 setFromXMLFile(const std::string &directory)
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 MIMEXMLPart(const asdm::ByteOrder *byteOrder=asdm::ByteOrder::Machine_Endianity)
Private methods involved during the export of this table into disk file(s).
asdmIDL::CalDeviceTableIDL * toIDL()
Conversion Methods.
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
CalDeviceTable(ASDM &container)
Create a CalDeviceTable.