casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SubscanTable.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 SubscanTable.h
32  */
33 
34 #ifndef SubscanTable_CLASS
35 #define SubscanTable_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 
66 
67 
68 
70 
71 
72 
73 
74 
75 
76 
78 
79 
80 
81 
83 #include <alma/ASDM/DuplicateKey.h>
85 #include <alma/ASDM/NoSuchRow.h>
86 #include <alma/ASDM/DuplicateKey.h>
87 
88 
89 #ifndef WITHOUT_ACS
90 #include <asdmIDLC.h>
91 #endif
92 
94 
95 #include <pthread.h>
96 
97 namespace asdm {
98 
99 //class asdm::ASDM;
100 //class asdm::SubscanRow;
101 
102 class ASDM;
103 class SubscanRow;
214 class SubscanTable : public Representable {
215  friend class ASDM;
216 
217 public:
218 
219 
225  static const std::vector<std::string>& getKeyName();
226 
227 
228  virtual ~SubscanTable();
229 
235  ASDM &getContainer() const;
236 
242  unsigned int size() const;
243 
251  std::string getName() const;
252 
260  static std::string name() ;
261 
266  std::string getVersion() const ;
267 
273  static const std::vector<std::string>& getAttributesNames();
274 
280  static const std::vector<std::string>& defaultAttributesNamesInBin();
281 
285  Entity getEntity() const;
286 
291  void setEntity(Entity e);
292 
300  std::string toXML() ;
301 
302 #ifndef WITHOUT_ACS
303  // Conversion Methods
309  asdmIDL::SubscanTableIDL *toIDL() ;
310 
318  void toIDL(asdmIDL::SubscanTableIDL& x) const;
319 
320 #endif
321 
322 #ifndef WITHOUT_ACS
323 
329  void fromIDL(asdmIDL::SubscanTableIDL x) ;
330 #endif
331 
332  //
333  // ====> Row creation.
334  //
335 
340  SubscanRow *newRow();
341 
342 
366  SubscanRow *newRow(Tag execBlockId, int scanNumber, int subscanNumber, ArrayTime startTime, ArrayTime endTime, std::string fieldName, SubscanIntentMod::SubscanIntent subscanIntent, int numIntegration, std::vector<int > numSubintegration);
367 
368 
369 
383 
384  //
385  // ====> Append a row to its table.
386  //
387 
388 
401  SubscanRow* add(SubscanRow* x) ;
402 
403 
404 
405 
406 
407  //
408  // ====> Methods returning rows.
409  //
410 
416  std::vector<SubscanRow *> get() ;
417 
424  const std::vector<SubscanRow *>& get() const ;
425 
426 
427 
428 
429 
443  SubscanRow* getRowByKey(Tag execBlockId, int scanNumber, int subscanNumber);
444 
445 
446 
447 
448 
474  SubscanRow* lookup(Tag execBlockId, int scanNumber, int subscanNumber, ArrayTime startTime, ArrayTime endTime, std::string fieldName, SubscanIntentMod::SubscanIntent subscanIntent, int numIntegration, std::vector<int > numSubintegration);
475 
476 
477  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
478  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
479 
480 private:
481 
491 
493 
494  bool archiveAsBin; // If true archive binary else archive XML
495  bool fileAsBin ; // If true file binary else file XML
496 
497  std::string version ;
498 
500 
501 
502 
503 
504 
505 
513  SubscanRow* checkAndAdd(SubscanRow* x, bool skipCheckUniqueness=false) ;
514 
520  void append(SubscanRow* x) ;
521 
528 
529 
530 
531 
532 
533 // A data structure to store the pointers on the table's rows.
534 
535 // In all cases we maintain a private vector of SubscanRow s.
536  std::vector<SubscanRow * > privateRows;
537 
538 
539 
540  std::vector<SubscanRow *> row;
541 
542 
543  void error() ; //throw(ConversionException);
544 
545 
552  void fromXML(std::string& xmlDoc) ;
553 
554  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
555 
560  void setFromMIMEFile(const std::string& directory);
561  /*
562  void openMIMEFile(const std::string& directory);
563  */
564  void setFromXMLFile(const std::string& directory);
565 
573  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
574 
575 
582  void setFromMIME(const std::string & mimeMsg);
583 
587  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
588 
598  void toFile(std::string directory);
599 
605  if (!presentInMemory && !loadInProgress) {
606  loadInProgress = true;
607  setFromFile(getContainer().getDirectory());
608  presentInMemory = true;
609  loadInProgress = false;
610  }
611  }
620  void setFromFile(const std::string& directory);
621 
622 };
623 
624 } // End namespace asdm
625 
626 #endif /* SubscanTable_CLASS */
unsigned int size() const
Return the number of rows in the table.
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
Definition: SubscanTable.h:554
static const ByteOrder * Machine_Endianity
Definition: Misc.h:119
SubscanRow * checkAndAdd(SubscanRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
void fromIDL(asdmIDL::SubscanTableIDL x)
Populate this table from the content of a SubscanTableIDL Corba structure.
virtual ~SubscanTable()
SubscanRow * getRowByKey(Tag execBlockId, int scanNumber, int subscanNumber)
Returns a SubscanRow* given a key.
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a SubscanTable as those produced by the toFile...
struct _xmlDoc xmlDoc
Definition: Misc.h:59
std::vector< SubscanRow * > privateRows
A data structure to store the pointers on the table&#39;s rows.
Definition: SubscanTable.h:536
void addWithoutCheckingUnique(SubscanRow *x)
Brutally append an SubscanRow x to the collection of rows already stored in this table.
A class to represent byte order information.
Definition: Misc.h:115
static const std::vector< std::string > & getAttributesNames()
Return the names of the attributes of this table.
The SubscanRow class is a row of a SubscanTable.
Definition: SubscanRow.h:119
The ASDM class is the container for all tables.
Definition: ASDM.h:273
void setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
void checkPresenceInMemory()
Definition: SubscanTable.h:604
SubscanTable(ASDM &container)
Create a SubscanTable.
void setFromXMLFile(const std::string &directory)
ASDM & getContainer() const
Return the container to which this table belongs.
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 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< SubscanRow * > row
Definition: SubscanTable.h:540
static std::string name()
Return the name of this table.
SubscanRow * newRow()
====&gt; Row creation.
asdmIDL::SubscanTableIDL * toIDL()
Conversion Methods.
bool loadInProgress
Load the table in memory if necessary.
Definition: SubscanTable.h:603
SubscanRow * lookup(Tag execBlockId, int scanNumber, int subscanNumber, ArrayTime startTime, ArrayTime endTime, std::string fieldName, SubscanIntentMod::SubscanIntent subscanIntent, int numIntegration, std::vector< int > numSubintegration)
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...
The ArrayTime class implements the concept of a point in time, implemented as an Interval of time sin...
Definition: ArrayTime.h:89
The Tag class is an implementation of a unique index identifying a row of an ASDM table...
Definition: Tag.h:73
std::string toXML()
Produces an XML representation conform to the schema defined for Subscan (SubscanTable.xsd).
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
void append(SubscanRow *x)
Brutally append an SubscanRow 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
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...
Entity getEntity() const
Return this table&#39;s Entity.
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...
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 SubscanTable class is an Alma table.
Definition: SubscanTable.h:214
std::string getVersion() const
Return the version information about this table.
SubscanRow * add(SubscanRow *x)
====&gt; Append a row to its table.
void toFile(std::string directory)
Stores a representation (binary or XML) of this table into a file.
std::string getName() const
Return the name of this table.
std::string version
Definition: SubscanTable.h:497
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59
static const std::vector< std::string > & getKeyName()
Return the list of field names that make up key key as an array of strings.
void setEntity(Entity e)
Set this table&#39;s Entity.