casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DopplerTable.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 DopplerTable.h
32  */
33 
34 #ifndef DopplerTable_CLASS
35 #define DopplerTable_CLASS
36 
37 #include <string>
38 #include <vector>
39 #include <map>
40 
41 
42 
43 
44 
45 
46 
47 
48 
49 
50 
52 
53 
54 
55 
57 #include <alma/ASDM/DuplicateKey.h>
59 #include <alma/ASDM/NoSuchRow.h>
60 #include <alma/ASDM/DuplicateKey.h>
61 
62 
63 #ifndef WITHOUT_ACS
64 #include <asdmIDLC.h>
65 #endif
66 
68 
69 #include <pthread.h>
70 
71 namespace asdm {
72 
73 //class asdm::ASDM;
74 //class asdm::DopplerRow;
75 
76 class ASDM;
77 class DopplerRow;
134 class DopplerTable : public Representable {
135  friend class ASDM;
136 
137 public:
138 
139 
145  static const std::vector<std::string>& getKeyName();
146 
147 
148  virtual ~DopplerTable();
149 
155  ASDM &getContainer() const;
156 
162  unsigned int size() const;
163 
171  std::string getName() const;
172 
180  static std::string name() ;
181 
186  std::string getVersion() const ;
187 
193  static const std::vector<std::string>& getAttributesNames();
194 
200  static const std::vector<std::string>& defaultAttributesNamesInBin();
201 
205  Entity getEntity() const;
206 
211  void setEntity(Entity e);
212 
220  std::string toXML() ;
221 
222 #ifndef WITHOUT_ACS
223  // Conversion Methods
229  asdmIDL::DopplerTableIDL *toIDL() ;
230 
238  void toIDL(asdmIDL::DopplerTableIDL& x) const;
239 
240 #endif
241 
242 #ifndef WITHOUT_ACS
243 
249  void fromIDL(asdmIDL::DopplerTableIDL x) ;
250 #endif
251 
252  //
253  // ====> Row creation.
254  //
255 
260  DopplerRow *newRow();
261 
262 
274  DopplerRow *newRow(int sourceId, int transitionIndex, DopplerReferenceCodeMod::DopplerReferenceCode velDef);
275 
276 
277 
291 
292  //
293  // ====> Append a row to its table.
294  //
295 
296 
297 
298 
308  DopplerRow* add(DopplerRow* x) ;
309 
310 
311 
312  //
313  // ====> Methods returning rows.
314  //
315 
321  std::vector<DopplerRow *> get() ;
322 
329  const std::vector<DopplerRow *>& get() const ;
330 
331 
332 
333 
334 
346  DopplerRow* getRowByKey(int dopplerId, int sourceId);
347 
348 
349 
357  std::vector <DopplerRow *> getRowByDopplerId(int);
358 
359 
360 
374  DopplerRow* lookup(int sourceId, int transitionIndex, DopplerReferenceCodeMod::DopplerReferenceCode velDef);
375 
376 
377  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
378  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
379 
380 private:
381 
391 
393 
394  bool archiveAsBin; // If true archive binary else archive XML
395  bool fileAsBin ; // If true file binary else file XML
396 
397  std::string version ;
398 
400 
401 
402 
403 
404 
405  // A map for the autoincrementation algorithm
406  std::map<std::string,int> noAutoIncIds;
407  void autoIncrement(std::string key, DopplerRow* x);
408 
409 
419  DopplerRow* checkAndAdd(DopplerRow* x, bool skipCheckUniqueness=false) ;
420 
426  void append(DopplerRow* x) ;
427 
434 
435 
436 
437 
438 
439 // A data structure to store the pointers on the table's rows.
440 
441 // In all cases we maintain a private vector of DopplerRow s.
442  std::vector<DopplerRow * > privateRows;
443 
444 
445 
446  std::vector<DopplerRow *> row;
447 
448 
449  void error() ; //throw(ConversionException);
450 
451 
458  void fromXML(std::string& xmlDoc) ;
459 
460  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
461 
466  void setFromMIMEFile(const std::string& directory);
467  /*
468  void openMIMEFile(const std::string& directory);
469  */
470  void setFromXMLFile(const std::string& directory);
471 
479  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
480 
481 
488  void setFromMIME(const std::string & mimeMsg);
489 
493  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
494 
504  void toFile(std::string directory);
505 
511  if (!presentInMemory && !loadInProgress) {
512  loadInProgress = true;
513  setFromFile(getContainer().getDirectory());
514  presentInMemory = true;
515  loadInProgress = false;
516  }
517  }
526  void setFromFile(const std::string& directory);
527 
528 };
529 
530 } // End namespace asdm
531 
532 #endif /* DopplerTable_CLASS */
void checkPresenceInMemory()
Definition: DopplerTable.h:510
static const ByteOrder * Machine_Endianity
Definition: Misc.h:119
void toFile(std::string directory)
Stores a representation (binary or XML) of this table into a file.
void fromIDL(asdmIDL::DopplerTableIDL x)
Populate this table from the content of a DopplerTableIDL Corba structure.
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
Definition: DopplerTable.h:460
struct _xmlDoc xmlDoc
Definition: Misc.h:59
The DopplerRow class is a row of a DopplerTable.
Definition: DopplerRow.h:93
DopplerRow * add(DopplerRow *x)
====&gt; Append a row to its table.
A class to represent byte order information.
Definition: Misc.h:115
std::string getName() const
Return the name of this table.
The ASDM class is the container for all tables.
Definition: ASDM.h:273
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.
bool loadInProgress
Load the table in memory if necessary.
Definition: DopplerTable.h:509
DopplerRow * getRowByKey(int dopplerId, int sourceId)
Returns a DopplerRow* given a key.
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...
Entity getEntity() const
Return this table&#39;s Entity.
ASDM & getContainer() const
Return the container to which this table belongs.
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...
DopplerRow * newRow()
====&gt; Row creation.
virtual ~DopplerTable()
DopplerTable(ASDM &container)
Create a DopplerTable.
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 append(DopplerRow *x)
Brutally append an DopplerRow x to the collection of rows already stored in this table.
static const std::vector< std::string > & getKeyName()
Return the list of field names that make up key key as an array of strings.
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a DopplerTable as those produced by the toFile...
std::vector< DopplerRow * > privateRows
A data structure to store the pointers on the table&#39;s rows.
Definition: DopplerTable.h:442
void setFromXMLFile(const std::string &directory)
DopplerRow * checkAndAdd(DopplerRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
void autoIncrement(std::string key, DopplerRow *x)
static const std::vector< std::string > & defaultAttributesNamesInBin()
Return the default sorted list of attributes names in the binary representation of the table...
asdmIDL::DopplerTableIDL * toIDL()
Conversion Methods.
void addWithoutCheckingUnique(DopplerRow *x)
Brutally append an DopplerRow x to the collection of rows already stored in this table.
std::map< std::string, int > noAutoIncIds
A map for the autoincrementation algorithm.
Definition: DopplerTable.h:406
static std::string name()
Return the name of this table.
void setEntity(Entity e)
Set this table&#39;s Entity.
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
DopplerRow * lookup(int sourceId, int transitionIndex, DopplerReferenceCodeMod::DopplerReferenceCode velDef)
Look up the table for a row whose all attributes except the autoincrementable one are equal to the co...
const Double e
e and functions thereof:
void setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
std::string getVersion() const
Return the version information about this table.
std::string toXML()
Produces an XML representation conform to the schema defined for Doppler (DopplerTable.xsd).
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
std::vector< DopplerRow * > getRowByDopplerId(int)
Returns a vector of pointers on rows whose key element dopplerId is equal to the parameter dopplerId...
unsigned int size() const
Return the number of rows in the table.
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 version
Definition: DopplerTable.h:397
The DopplerTable class is an Alma table.
Definition: DopplerTable.h:134
std::vector< DopplerRow * > row
Definition: DopplerTable.h:446
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59