casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HolographyTable.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 HolographyTable.h
32  */
33 
34 #ifndef HolographyTable_CLASS
35 #define HolographyTable_CLASS
36 
37 #include <string>
38 #include <vector>
39 #include <map>
40 
41 
42 
43 
44 #include <alma/ASDM/Length.h>
45 
46 
47 
48 #include <alma/ASDM/Tag.h>
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
64 
65 
66 
67 
69 #include <alma/ASDM/DuplicateKey.h>
71 #include <alma/ASDM/NoSuchRow.h>
72 #include <alma/ASDM/DuplicateKey.h>
73 
74 
75 #ifndef WITHOUT_ACS
76 #include <asdmIDLC.h>
77 #endif
78 
80 
81 #include <pthread.h>
82 
83 namespace asdm {
84 
85 //class asdm::ASDM;
86 //class asdm::HolographyRow;
87 
88 class ASDM;
89 class HolographyRow;
152  friend class ASDM;
153 
154 public:
155 
156 
162  static const std::vector<std::string>& getKeyName();
163 
164 
165  virtual ~HolographyTable();
166 
172  ASDM &getContainer() const;
173 
179  unsigned int size() const;
180 
188  std::string getName() const;
189 
197  static std::string name() ;
198 
203  std::string getVersion() const ;
204 
210  static const std::vector<std::string>& getAttributesNames();
211 
217  static const std::vector<std::string>& defaultAttributesNamesInBin();
218 
222  Entity getEntity() const;
223 
228  void setEntity(Entity e);
229 
237  std::string toXML() ;
238 
239 #ifndef WITHOUT_ACS
240  // Conversion Methods
246  asdmIDL::HolographyTableIDL *toIDL() ;
247 
255  void toIDL(asdmIDL::HolographyTableIDL& x) const;
256 
257 #endif
258 
259 #ifndef WITHOUT_ACS
260 
266  void fromIDL(asdmIDL::HolographyTableIDL x) ;
267 #endif
268 
269  //
270  // ====> Row creation.
271  //
272 
278 
279 
293  HolographyRow *newRow(Length distance, Length focus, int numCorr, std::vector<HolographyChannelTypeMod::HolographyChannelType > type);
294 
295 
296 
310 
311  //
312  // ====> Append a row to its table.
313  //
314 
315 
316 
317 
328 
329 
330 
331  //
332  // ====> Methods returning rows.
333  //
334 
340  std::vector<HolographyRow *> get() ;
341 
348  const std::vector<HolographyRow *>& get() const ;
349 
350 
351 
352 
353 
363  HolographyRow* getRowByKey(Tag holographyId);
364 
365 
366 
367 
368 
384  HolographyRow* lookup(Length distance, Length focus, int numCorr, std::vector<HolographyChannelTypeMod::HolographyChannelType > type);
385 
386 
387  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
388  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
389 
390 private:
391 
401 
403 
404  bool archiveAsBin; // If true archive binary else archive XML
405  bool fileAsBin ; // If true file binary else file XML
406 
407  std::string version ;
408 
410 
411 
412 
413 
414 
415  // A map for the autoincrementation algorithm
416  std::map<std::string,int> noAutoIncIds;
417  void autoIncrement(std::string key, HolographyRow* x);
418 
419 
429  HolographyRow* checkAndAdd(HolographyRow* x, bool skipCheckUniqueness=false) ;
430 
436  void append(HolographyRow* x) ;
437 
444 
445 
446 
447 
448 
449 // A data structure to store the pointers on the table's rows.
450 
451 // In all cases we maintain a private vector of HolographyRow s.
452  std::vector<HolographyRow * > privateRows;
453 
454 
455 
456  std::vector<HolographyRow *> row;
457 
458 
459  void error() ; //throw(ConversionException);
460 
461 
468  void fromXML(std::string& xmlDoc) ;
469 
470  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
471 
476  void setFromMIMEFile(const std::string& directory);
477  /*
478  void openMIMEFile(const std::string& directory);
479  */
480  void setFromXMLFile(const std::string& directory);
481 
489  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
490 
491 
498  void setFromMIME(const std::string & mimeMsg);
499 
503  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
504 
514  void toFile(std::string directory);
515 
521  if (!presentInMemory && !loadInProgress) {
522  loadInProgress = true;
523  setFromFile(getContainer().getDirectory());
524  presentInMemory = true;
525  loadInProgress = false;
526  }
527  }
536  void setFromFile(const std::string& directory);
537 
538 };
539 
540 } // End namespace asdm
541 
542 #endif /* HolographyTable_CLASS */
std::string toXML()
Produces an XML representation conform to the schema defined for Holography (HolographyTable.xsd).
static const ByteOrder * Machine_Endianity
Definition: Misc.h:119
std::vector< HolographyRow * > row
ASDM & getContainer() const
Return the container to which this table belongs.
void setFromXMLFile(const std::string &directory)
virtual ~HolographyTable()
struct _xmlDoc xmlDoc
Definition: Misc.h:59
The HolographyRow class is a row of a HolographyTable.
A class to represent byte order information.
Definition: Misc.h:115
static std::string name()
Return the name of this table.
Entity getEntity() const
Return this table&#39;s Entity.
HolographyRow * lookup(Length distance, Length focus, int numCorr, std::vector< HolographyChannelTypeMod::HolographyChannelType > type)
Look up the table for a row whose all attributes except the autoincrementable one are equal to the co...
The ASDM class is the container for all tables.
Definition: ASDM.h:273
virtual casacore::String type() const
Implements RegionShape::type.
Definition: RegionShapes.h:548
void fromIDL(asdmIDL::HolographyTableIDL x)
Populate this table from the content of a HolographyTableIDL Corba structure.
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 getVersion() const
Return the version information about this table.
void setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
void setEntity(Entity e)
Set this table&#39;s Entity.
void toFile(std::string directory)
Stores a representation (binary or XML) of this table into a file.
static const std::vector< std::string > & defaultAttributesNamesInBin()
Return the default sorted list of attributes names in the binary representation of the table...
The HolographyTable class is an Alma table.
The Length class implements a quantity of length in meters.
Definition: Length.h:53
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 autoIncrement(std::string key, HolographyRow *x)
std::map< std::string, int > noAutoIncIds
A map for the autoincrementation algorithm.
std::vector< HolographyRow * > privateRows
A data structure to store the pointers on the table&#39;s rows.
The Tag class is an implementation of a unique index identifying a row of an ASDM table...
Definition: Tag.h:73
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 append(HolographyRow *x)
Brutally append an HolographyRow x to the collection of rows already stored in this table...
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
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.
static const std::vector< std::string > & getAttributesNames()
Return the names of the attributes of 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
unsigned int size() const
Return the number of rows in the table.
static const std::vector< std::string > & getKeyName()
Return the list of field names that make up key key as an array of strings.
HolographyRow * add(HolographyRow *x)
====&gt; Append a row to its table.
const Double e
e and functions thereof:
HolographyRow * checkAndAdd(HolographyRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
void addWithoutCheckingUnique(HolographyRow *x)
Brutally append an HolographyRow x to the collection of rows already stored in this table...
std::string getName() const
Return the name of this table.
HolographyRow * newRow()
====&gt; Row creation.
HolographyRow * getRowByKey(Tag holographyId)
Returns a HolographyRow* given a key.
asdmIDL::HolographyTableIDL * toIDL()
Conversion Methods.
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a HolographyTable as those produced by the toF...
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...
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
HolographyTable(ASDM &container)
Create a HolographyTable.
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59
bool loadInProgress
Load the table in memory if necessary.