casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MainTable.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 MainTable.h
32  */
33 
34 #ifndef MainTable_CLASS
35 #define MainTable_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 #include <alma/ASDM/Interval.h>
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
68 
69 
70 
71 
72 
73 
74 
75 
76 
77 
78 
79 
80 
81 
82 
83 
85 #include <alma/ASDM/DuplicateKey.h>
87 #include <alma/ASDM/NoSuchRow.h>
88 #include <alma/ASDM/DuplicateKey.h>
89 
90 
91 #ifndef WITHOUT_ACS
92 #include <asdmIDLC.h>
93 #endif
94 
96 
97 #include <pthread.h>
98 
99 namespace asdm {
100 
101 //class asdm::ASDM;
102 //class asdm::MainRow;
103 
104 class ASDM;
105 class MainRow;
228 class MainTable : public Representable {
229  friend class ASDM;
230 
231 public:
232 
233 
239  static const std::vector<std::string>& getKeyName();
240 
241 
242  virtual ~MainTable();
243 
249  ASDM &getContainer() const;
250 
256  unsigned int size() const;
257 
265  std::string getName() const;
266 
274  static std::string name() ;
275 
280  std::string getVersion() const ;
281 
287  static const std::vector<std::string>& getAttributesNames();
288 
294  static const std::vector<std::string>& defaultAttributesNamesInBin();
295 
299  Entity getEntity() const;
300 
305  void setEntity(Entity e);
306 
314  std::string toXML() ;
315 
316 #ifndef WITHOUT_ACS
317  // Conversion Methods
323  asdmIDL::MainTableIDL *toIDL() ;
324 
332  void toIDL(asdmIDL::MainTableIDL& x) const;
333 
334 #endif
335 
336 #ifndef WITHOUT_ACS
337 
343  void fromIDL(asdmIDL::MainTableIDL x) ;
344 #endif
345 
346  //
347  // ====> Row creation.
348  //
349 
354  MainRow *newRow();
355 
356 
388  MainRow *newRow(ArrayTime time, Tag configDescriptionId, Tag fieldId, int numAntenna, TimeSamplingMod::TimeSampling timeSampling, Interval interval, int numIntegration, int scanNumber, int subscanNumber, int64_t dataSize, EntityRef dataUID, std::vector<Tag> stateId, Tag execBlockId);
389 
390 
391 
404  MainRow *newRow(MainRow *row);
405 
406  //
407  // ====> Append a row to its table.
408  //
409 
410 
427  MainRow* add(MainRow* x) ;
428 
429 
430 
431 
432 
433  //
434  // ====> Methods returning rows.
435  //
436 
442  std::vector<MainRow *> get() ;
443 
450  const std::vector<MainRow *>& get() const ;
451 
452 
463  std::vector <MainRow*> *getByContext(Tag configDescriptionId, Tag fieldId);
464 
465 
466 
467 
468 
482  MainRow* getRowByKey(ArrayTime time, Tag configDescriptionId, Tag fieldId);
483 
484 
485 
486 
487 
521  MainRow* lookup(ArrayTime time, Tag configDescriptionId, Tag fieldId, int numAntenna, TimeSamplingMod::TimeSampling timeSampling, Interval interval, int numIntegration, int scanNumber, int subscanNumber, int64_t dataSize, EntityRef dataUID, std::vector<Tag> stateId, Tag execBlockId);
522 
523 
524  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
525  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
526 
527 private:
528 
538 
540 
541  bool archiveAsBin; // If true archive binary else archive XML
542  bool fileAsBin ; // If true file binary else file XML
543 
544  std::string version ;
545 
547 
548 
549 
550 
551 
552 
560  MainRow* checkAndAdd(MainRow* x, bool skipCheckUniqueness=false) ;
561 
567  void append(MainRow* x) ;
568 
575 
576 
577 
578 
579 
580 
588  MainRow * insertByTime(MainRow* x, std::vector<MainRow *>&row );
589 
590 
591 
592 // A data structure to store the pointers on the table's rows.
593 
594 // In all cases we maintain a private vector of MainRow s.
595  std::vector<MainRow * > privateRows;
596 
597 
598 
599 
600 
601 
602 
603 
604  typedef std::vector <MainRow* > TIME_ROWS;
605  std::map<std::string, TIME_ROWS > context;
606 
611  std::string Key(Tag configDescriptionId, Tag fieldId) ;
612 
613 
614 
615 
621  void getByKeyNoAutoIncNoTime(std::vector <MainRow*>& vin, std::vector <MainRow*>& vout, Tag configDescriptionId, Tag fieldId);
622 
623 
624 
625  void error() ; //throw(ConversionException);
626 
627 
634  void fromXML(std::string& xmlDoc) ;
635 
636  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
637 
642  void setFromMIMEFile(const std::string& directory);
643  /*
644  void openMIMEFile(const std::string& directory);
645  */
646  void setFromXMLFile(const std::string& directory);
647 
655  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
656 
657 
664  void setFromMIME(const std::string & mimeMsg);
665 
669  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
670 
680  void toFile(std::string directory);
681 
687  if (!presentInMemory && !loadInProgress) {
688  loadInProgress = true;
689  setFromFile(getContainer().getDirectory());
690  presentInMemory = true;
691  loadInProgress = false;
692  }
693  }
702  void setFromFile(const std::string& directory);
703 
704 };
705 
706 } // End namespace asdm
707 
708 #endif /* MainTable_CLASS */
std::string MIMEXMLPart(const asdm::ByteOrder *byteOrder=asdm::ByteOrder::Machine_Endianity)
Private methods involved during the export of this table into disk file(s).
std::string getName() const
Return the name of this table.
std::map< std::string, TIME_ROWS > context
Definition: MainTable.h:605
static const ByteOrder * Machine_Endianity
Definition: Misc.h:119
std::vector< MainRow * > * getByContext(Tag configDescriptionId, Tag fieldId)
Returns all the rows sorted by ascending startTime for a given context.
The Interval class implements an interval of time in units of nanoseconds.
Definition: Interval.h:58
MainRow * checkAndAdd(MainRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
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...
struct _xmlDoc xmlDoc
Definition: Misc.h:59
A class to represent byte order information.
Definition: Misc.h:115
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: MainTable.h:686
void getByKeyNoAutoIncNoTime(std::vector< MainRow * > &vin, std::vector< MainRow * > &vout, Tag configDescriptionId, Tag fieldId)
Fills the vector vout (passed by reference) with pointers on elements of vin whose attributes are equ...
ABSTRACT TOOL CLASSES A PlotTool is a higher level event handler for a PlotCanvas The idea is to take common tasks which may require multiple events and put them in one place PlotTools also provide additional functionality in that they can be active and blocking non blocking The PlotCanvas will only send events to active and will not send events to later tools or event handlers if the latest tool was blocking In this way a single tool can be used to handle ALL user interaction via the GUI at one time
Definition: PlotTool.h:43
The ASDM class is the container for all tables.
Definition: ASDM.h:273
std::string Key(Tag configDescriptionId, Tag fieldId)
Returns a string built by concatenating the ascii representation of the parameters values suffixed wi...
void setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
MainRow * newRow()
====&gt; Row creation.
std::string toXML()
Produces an XML representation conform to the schema defined for Main (MainTable.xsd).
MainTable(ASDM &container)
Create a MainTable.
bool loadInProgress
Load the table in memory if necessary.
Definition: MainTable.h:685
std::vector< MainRow * > TIME_ROWS
Definition: MainTable.h:604
The EntityRef class is an identification of a persistant entity in the ALMA archive.
Definition: EntityRef.h:58
Entity getEntity() const
Return this table&#39;s Entity.
void addWithoutCheckingUnique(MainRow *x)
Brutally append an MainRow x to the collection of rows already stored in this table.
MainRow * getRowByKey(ArrayTime time, Tag configDescriptionId, Tag fieldId)
Returns a MainRow* given a key.
std::vector< MainRow * > privateRows
A data structure to store the pointers on the table&#39;s rows.
Definition: MainTable.h:595
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
The MainRow class is a row of a MainTable.
Definition: MainRow.h:132
void fromIDL(asdmIDL::MainTableIDL x)
Populate this table from the content of a MainTableIDL Corba structure.
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
Definition: MainTable.h:636
ASDM & getContainer() const
Return the container to which this table belongs.
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 setFromMIMEFile(const std::string &directory)
Private methods involved during the build of this table out of the content of file(s) containing an e...
asdmIDL::MainTableIDL * toIDL()
Conversion Methods.
MainRow * insertByTime(MainRow *x, std::vector< MainRow * > &row)
Insert a MainRow* in a vector of MainRow* so that it&#39;s ordered by ascending time. ...
The ArrayTime class implements the concept of a point in time, implemented as an Interval of time sin...
Definition: ArrayTime.h:89
static std::string name()
Return the name of this table.
The Tag class is an implementation of a unique index identifying a row of an ASDM table...
Definition: Tag.h:73
MainRow * lookup(ArrayTime time, Tag configDescriptionId, Tag fieldId, int numAntenna, TimeSamplingMod::TimeSampling timeSampling, Interval interval, int numIntegration, int scanNumber, int subscanNumber, int64_t dataSize, EntityRef dataUID, std::vector< Tag > stateId, Tag execBlockId)
Look up the table for a row whose all attributes are equal to the corresponding parameters of the met...
static const std::vector< std::string > & defaultAttributesNamesInBin()
Return the default sorted list of attributes names in the binary representation of the table...
void append(MainRow *x)
Brutally append an MainRow x to the collection of rows already stored in this table.
virtual ~MainTable()
MainRow * add(MainRow *x)
====&gt; Append a row to its table.
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.
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:
std::string version
Definition: MainTable.h:544
std::string getVersion() const
Return the version information about this table.
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a MainTable as those produced by the toFile me...
void setEntity(Entity e)
Set this table&#39;s Entity.
ASDM & container
Definition: MainTable.h:539
The MainTable class is an Alma table.
Definition: MainTable.h:228
static const std::vector< std::string > & getAttributesNames()
Return the names of the attributes of this table.
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.
void setFromXMLFile(const std::string &directory)
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59