casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PolarizationTable.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 PolarizationTable.h
32  */
33 
34 #ifndef PolarizationTable_CLASS
35 #define PolarizationTable_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 
54 
56 
57 
58 
60 
61 
62 
63 
65 #include <alma/ASDM/DuplicateKey.h>
67 #include <alma/ASDM/NoSuchRow.h>
68 #include <alma/ASDM/DuplicateKey.h>
69 
70 
71 #ifndef WITHOUT_ACS
72 #include <asdmIDLC.h>
73 #endif
74 
76 
77 #include <pthread.h>
78 
79 namespace asdm {
80 
81 //class asdm::ASDM;
82 //class asdm::PolarizationRow;
83 
84 class ASDM;
85 class PolarizationRow;
141  friend class ASDM;
142 
143 public:
144 
145 
151  static const std::vector<std::string>& getKeyName();
152 
153 
154  virtual ~PolarizationTable();
155 
161  ASDM &getContainer() const;
162 
168  unsigned int size() const;
169 
177  std::string getName() const;
178 
186  static std::string name() ;
187 
192  std::string getVersion() const ;
193 
199  static const std::vector<std::string>& getAttributesNames();
200 
206  static const std::vector<std::string>& defaultAttributesNamesInBin();
207 
211  Entity getEntity() const;
212 
217  void setEntity(Entity e);
218 
226  std::string toXML() ;
227 
228 #ifndef WITHOUT_ACS
229  // Conversion Methods
235  asdmIDL::PolarizationTableIDL *toIDL() ;
236 
244  void toIDL(asdmIDL::PolarizationTableIDL& x) const;
245 
246 #endif
247 
248 #ifndef WITHOUT_ACS
249 
255  void fromIDL(asdmIDL::PolarizationTableIDL x) ;
256 #endif
257 
258  //
259  // ====> Row creation.
260  //
261 
267 
268 
280  PolarizationRow *newRow(int numCorr, std::vector<StokesParameterMod::StokesParameter > corrType, std::vector<std::vector<PolarizationTypeMod::PolarizationType > > corrProduct);
281 
282 
283 
297 
298  //
299  // ====> Append a row to its table.
300  //
301 
302 
303 
304 
315 
316 
317 
318  //
319  // ====> Methods returning rows.
320  //
321 
327  std::vector<PolarizationRow *> get() ;
328 
335  const std::vector<PolarizationRow *>& get() const ;
336 
337 
338 
339 
340 
350  PolarizationRow* getRowByKey(Tag polarizationId);
351 
352 
353 
354 
355 
369  PolarizationRow* lookup(int numCorr, std::vector<StokesParameterMod::StokesParameter > corrType, std::vector<std::vector<PolarizationTypeMod::PolarizationType > > corrProduct);
370 
371 
372  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
373  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
374 
375 private:
376 
386 
388 
389  bool archiveAsBin; // If true archive binary else archive XML
390  bool fileAsBin ; // If true file binary else file XML
391 
392  std::string version ;
393 
395 
396 
397 
398 
399 
400  // A map for the autoincrementation algorithm
401  std::map<std::string,int> noAutoIncIds;
402  void autoIncrement(std::string key, PolarizationRow* x);
403 
404 
414  PolarizationRow* checkAndAdd(PolarizationRow* x, bool skipCheckUniqueness=false) ;
415 
421  void append(PolarizationRow* x) ;
422 
429 
430 
431 
432 
433 
434 // A data structure to store the pointers on the table's rows.
435 
436 // In all cases we maintain a private vector of PolarizationRow s.
437  std::vector<PolarizationRow * > privateRows;
438 
439 
440 
441  std::vector<PolarizationRow *> row;
442 
443 
444  void error() ; //throw(ConversionException);
445 
446 
453  void fromXML(std::string& xmlDoc) ;
454 
455  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
456 
461  void setFromMIMEFile(const std::string& directory);
462  /*
463  void openMIMEFile(const std::string& directory);
464  */
465  void setFromXMLFile(const std::string& directory);
466 
474  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
475 
476 
483  void setFromMIME(const std::string & mimeMsg);
484 
488  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
489 
499  void toFile(std::string directory);
500 
506  if (!presentInMemory && !loadInProgress) {
507  loadInProgress = true;
508  setFromFile(getContainer().getDirectory());
509  presentInMemory = true;
510  loadInProgress = false;
511  }
512  }
521  void setFromFile(const std::string& directory);
522 
523 };
524 
525 } // End namespace asdm
526 
527 #endif /* PolarizationTable_CLASS */
static const ByteOrder * Machine_Endianity
Definition: Misc.h:119
static std::string name()
Return the name of this table.
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
PolarizationRow * newRow()
====&gt; Row creation.
struct _xmlDoc xmlDoc
Definition: Misc.h:59
A class to represent byte order information.
Definition: Misc.h:115
bool loadInProgress
Load the table in memory if necessary.
void append(PolarizationRow *x)
Brutally append an PolarizationRow x to the collection of rows already stored in this table...
The ASDM class is the container for all tables.
Definition: ASDM.h:273
std::string MIMEXMLPart(const asdm::ByteOrder *byteOrder=asdm::ByteOrder::Machine_Endianity)
Private methods involved during the export of this table into disk file(s).
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.
void setEntity(Entity e)
Set this table&#39;s Entity.
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...
static const std::vector< std::string > & defaultAttributesNamesInBin()
Return the default sorted list of attributes names in the binary representation of the table...
ASDM & getContainer() const
Return the container to which this table belongs.
PolarizationRow * checkAndAdd(PolarizationRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
unsigned int size() const
Return the number of rows in the table.
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
PolarizationRow * add(PolarizationRow *x)
====&gt; Append a row to its table.
void fromIDL(asdmIDL::PolarizationTableIDL x)
Populate this table from the content of a PolarizationTableIDL Corba structure.
PolarizationTable(ASDM &container)
Create a PolarizationTable.
std::map< std::string, int > noAutoIncIds
A map for the autoincrementation algorithm.
asdmIDL::PolarizationTableIDL * toIDL()
Conversion Methods.
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a PolarizationTable as those produced by the t...
std::vector< PolarizationRow * > 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 autoIncrement(std::string key, PolarizationRow *x)
void setFromXMLFile(const std::string &directory)
std::string getVersion() const
Return the version information about this table.
Entity getEntity() const
Return this table&#39;s Entity.
PolarizationRow * lookup(int numCorr, std::vector< StokesParameterMod::StokesParameter > corrType, std::vector< std::vector< PolarizationTypeMod::PolarizationType > > corrProduct)
Look up the table for a row whose all attributes except the autoincrementable one are equal to the co...
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...
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
void addWithoutCheckingUnique(PolarizationRow *x)
Brutally append an PolarizationRow x to the collection of rows already stored in this table...
const Double e
e and functions thereof:
static const std::vector< std::string > & getKeyName()
Return the list of field names that make up key key as an array of strings.
The PolarizationTable class is an Alma table.
The PolarizationRow class is a row of a PolarizationTable.
void setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
static const std::vector< std::string > & getAttributesNames()
Return the names of the attributes of this table.
std::string toXML()
Produces an XML representation conform to the schema defined for Polarization (PolarizationTable.xsd).
std::vector< PolarizationRow * > row
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.
PolarizationRow * getRowByKey(Tag polarizationId)
Returns a PolarizationRow* given a key.
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59