casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DataDescriptionTable.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 DataDescriptionTable.h
32  */
33 
34 #ifndef DataDescriptionTable_CLASS
35 #define DataDescriptionTable_CLASS
36 
37 #include <string>
38 #include <vector>
39 #include <map>
40 
41 
42 
43 
44 #include <alma/ASDM/Tag.h>
45 
46 
47 
48 
49 
50 
51 
52 
53 
55 #include <alma/ASDM/DuplicateKey.h>
57 #include <alma/ASDM/NoSuchRow.h>
58 #include <alma/ASDM/DuplicateKey.h>
59 
60 
61 #ifndef WITHOUT_ACS
62 #include <asdmIDLC.h>
63 #endif
64 
66 
67 #include <pthread.h>
68 
69 namespace asdm {
70 
71 //class asdm::ASDM;
72 //class asdm::DataDescriptionRow;
73 
74 class ASDM;
75 class DataDescriptionRow;
134  friend class ASDM;
135 
136 public:
137 
138 
144  static const std::vector<std::string>& getKeyName();
145 
146 
147  virtual ~DataDescriptionTable();
148 
154  ASDM &getContainer() const;
155 
161  unsigned int size() const;
162 
170  std::string getName() const;
171 
179  static std::string name() ;
180 
185  std::string getVersion() const ;
186 
192  static const std::vector<std::string>& getAttributesNames();
193 
199  static const std::vector<std::string>& defaultAttributesNamesInBin();
200 
204  Entity getEntity() const;
205 
210  void setEntity(Entity e);
211 
219  std::string toXML() ;
220 
221 #ifndef WITHOUT_ACS
222  // Conversion Methods
228  asdmIDL::DataDescriptionTableIDL *toIDL() ;
229 
237  void toIDL(asdmIDL::DataDescriptionTableIDL& x) const;
238 
239 #endif
240 
241 #ifndef WITHOUT_ACS
242 
248  void fromIDL(asdmIDL::DataDescriptionTableIDL x) ;
249 #endif
250 
251  //
252  // ====> Row creation.
253  //
254 
260 
261 
271  DataDescriptionRow *newRow(Tag polOrHoloId, Tag spectralWindowId);
272 
273 
274 
288 
289  //
290  // ====> Append a row to its table.
291  //
292 
293 
294 
295 
306 
307 
308 
309  //
310  // ====> Methods returning rows.
311  //
312 
318  std::vector<DataDescriptionRow *> get() ;
319 
326  const std::vector<DataDescriptionRow *>& get() const ;
327 
328 
329 
330 
331 
341  DataDescriptionRow* getRowByKey(Tag dataDescriptionId);
342 
343 
344 
345 
346 
358  DataDescriptionRow* lookup(Tag polOrHoloId, Tag spectralWindowId);
359 
360 
361  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
362  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
363 
364 private:
365 
375 
377 
378  bool archiveAsBin; // If true archive binary else archive XML
379  bool fileAsBin ; // If true file binary else file XML
380 
381  std::string version ;
382 
384 
385 
386 
387 
388 
389  // A map for the autoincrementation algorithm
390  std::map<std::string,int> noAutoIncIds;
391  void autoIncrement(std::string key, DataDescriptionRow* x);
392 
393 
403  DataDescriptionRow* checkAndAdd(DataDescriptionRow* x, bool skipCheckUniqueness=false) ;
404 
410  void append(DataDescriptionRow* x) ;
411 
418 
419 
420 
421 
422 
423 // A data structure to store the pointers on the table's rows.
424 
425 // In all cases we maintain a private vector of DataDescriptionRow s.
426  std::vector<DataDescriptionRow * > privateRows;
427 
428 
429 
430  std::vector<DataDescriptionRow *> row;
431 
432 
433  void error() ; //throw(ConversionException);
434 
435 
442  void fromXML(std::string& xmlDoc) ;
443 
444  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
445 
450  void setFromMIMEFile(const std::string& directory);
451  /*
452  void openMIMEFile(const std::string& directory);
453  */
454  void setFromXMLFile(const std::string& directory);
455 
463  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
464 
465 
472  void setFromMIME(const std::string & mimeMsg);
473 
477  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
478 
488  void toFile(std::string directory);
489 
495  if (!presentInMemory && !loadInProgress) {
496  loadInProgress = true;
497  setFromFile(getContainer().getDirectory());
498  presentInMemory = true;
499  loadInProgress = false;
500  }
501  }
510  void setFromFile(const std::string& directory);
511 
512 };
513 
514 } // End namespace asdm
515 
516 #endif /* DataDescriptionTable_CLASS */
static const ByteOrder * Machine_Endianity
Definition: Misc.h:119
void append(DataDescriptionRow *x)
Brutally append an DataDescriptionRow x to the collection of rows already stored in this table...
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...
DataDescriptionRow * lookup(Tag polOrHoloId, Tag spectralWindowId)
Look up the table for a row whose all attributes except the autoincrementable one are equal to the co...
struct _xmlDoc xmlDoc
Definition: Misc.h:59
void addWithoutCheckingUnique(DataDescriptionRow *x)
Brutally append an DataDescriptionRow x to the collection of rows already stored in this table...
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 autoIncrement(std::string key, DataDescriptionRow *x)
unsigned int size() const
Return the number of rows in the table.
void setFromXMLFile(const std::string &directory)
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.
The ASDM class is the container for all tables.
Definition: ASDM.h:273
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...
The DataDescriptionTable class is an Alma table.
std::string getName() const
Return the name of this table.
void fromIDL(asdmIDL::DataDescriptionTableIDL x)
Populate this table from the content of a DataDescriptionTableIDL 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).
asdmIDL::DataDescriptionTableIDL * toIDL()
Conversion Methods.
std::map< std::string, int > noAutoIncIds
A map for the autoincrementation algorithm.
std::string getVersion() const
Return the version information about this table.
DataDescriptionRow * checkAndAdd(DataDescriptionRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
static const std::vector< std::string > & defaultAttributesNamesInBin()
Return the default sorted list of attributes names in the binary representation of the table...
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...
static std::string name()
Return the name of this table.
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
void setEntity(Entity e)
Set this table&#39;s Entity.
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
std::string toXML()
Produces an XML representation conform to the schema defined for DataDescription (DataDescriptionTabl...
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a DataDescriptionTable as those produced by th...
The Tag class is an implementation of a unique index identifying a row of an ASDM table...
Definition: Tag.h:73
The DataDescriptionRow class is a row of a DataDescriptionTable.
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:
DataDescriptionRow * getRowByKey(Tag dataDescriptionId)
Returns a DataDescriptionRow* given a key.
std::vector< DataDescriptionRow * > privateRows
A data structure to store the pointers on the table&#39;s rows.
DataDescriptionTable(ASDM &container)
Create a DataDescriptionTable.
DataDescriptionRow * add(DataDescriptionRow *x)
====&gt; Append a row to its table.
bool loadInProgress
Load the table in memory if necessary.
void setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
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.
DataDescriptionRow * newRow()
====&gt; Row creation.
Entity getEntity() const
Return this table&#39;s Entity.
std::vector< DataDescriptionRow * > row
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59