casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StationTable.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 StationTable.h
32  */
33 
34 #ifndef StationTable_CLASS
35 #define StationTable_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/ArrayTime.h>
49 
50 
51 
52 #include <alma/ASDM/Tag.h>
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
66 
67 
68 
69 
70 
71 
73 #include <alma/ASDM/DuplicateKey.h>
75 #include <alma/ASDM/NoSuchRow.h>
76 #include <alma/ASDM/DuplicateKey.h>
77 
78 
79 #ifndef WITHOUT_ACS
80 #include <asdmIDLC.h>
81 #endif
82 
84 
85 #include <pthread.h>
86 
87 namespace asdm {
88 
89 //class asdm::ASDM;
90 //class asdm::StationRow;
91 
92 class ASDM;
93 class StationRow;
158 class StationTable : public Representable {
159  friend class ASDM;
160 
161 public:
162 
163 
169  static const std::vector<std::string>& getKeyName();
170 
171 
172  virtual ~StationTable();
173 
179  ASDM &getContainer() const;
180 
186  unsigned int size() const;
187 
195  std::string getName() const;
196 
204  static std::string name() ;
205 
210  std::string getVersion() const ;
211 
217  static const std::vector<std::string>& getAttributesNames();
218 
224  static const std::vector<std::string>& defaultAttributesNamesInBin();
225 
229  Entity getEntity() const;
230 
235  void setEntity(Entity e);
236 
244  std::string toXML() ;
245 
246 #ifndef WITHOUT_ACS
247  // Conversion Methods
253  asdmIDL::StationTableIDL *toIDL() ;
254 
262  void toIDL(asdmIDL::StationTableIDL& x) const;
263 
264 #endif
265 
266 #ifndef WITHOUT_ACS
267 
273  void fromIDL(asdmIDL::StationTableIDL x) ;
274 #endif
275 
276  //
277  // ====> Row creation.
278  //
279 
284  StationRow *newRow();
285 
286 
298  StationRow *newRow(std::string name, std::vector<Length > position, StationTypeMod::StationType type);
299 
300 
301 
315 
316  //
317  // ====> Append a row to its table.
318  //
319 
320 
321 
322 
332  StationRow* add(StationRow* x) ;
333 
334 
335 
336  //
337  // ====> Methods returning rows.
338  //
339 
345  std::vector<StationRow *> get() ;
346 
353  const std::vector<StationRow *>& get() const ;
354 
355 
356 
357 
358 
368  StationRow* getRowByKey(Tag stationId);
369 
370 
371 
372 
373 
387  StationRow* lookup(std::string name, std::vector<Length > position, StationTypeMod::StationType type);
388 
389 
390  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
391  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
392 
393 private:
394 
404 
406 
407  bool archiveAsBin; // If true archive binary else archive XML
408  bool fileAsBin ; // If true file binary else file XML
409 
410  std::string version ;
411 
413 
414 
415 
416 
417 
418  // A map for the autoincrementation algorithm
419  std::map<std::string,int> noAutoIncIds;
420  void autoIncrement(std::string key, StationRow* x);
421 
422 
432  StationRow* checkAndAdd(StationRow* x, bool skipCheckUniqueness=false) ;
433 
439  void append(StationRow* x) ;
440 
447 
448 
449 
450 
451 
452 // A data structure to store the pointers on the table's rows.
453 
454 // In all cases we maintain a private vector of StationRow s.
455  std::vector<StationRow * > privateRows;
456 
457 
458 
459  std::vector<StationRow *> row;
460 
461 
462  void error() ; //throw(ConversionException);
463 
464 
471  void fromXML(std::string& xmlDoc) ;
472 
473  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
474 
479  void setFromMIMEFile(const std::string& directory);
480  /*
481  void openMIMEFile(const std::string& directory);
482  */
483  void setFromXMLFile(const std::string& directory);
484 
492  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
493 
494 
501  void setFromMIME(const std::string & mimeMsg);
502 
506  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
507 
517  void toFile(std::string directory);
518 
524  if (!presentInMemory && !loadInProgress) {
525  loadInProgress = true;
526  setFromFile(getContainer().getDirectory());
527  presentInMemory = true;
528  loadInProgress = false;
529  }
530  }
539  void setFromFile(const std::string& directory);
540 
541 };
542 
543 } // End namespace asdm
544 
545 #endif /* StationTable_CLASS */
static const std::vector< std::string > & getAttributesNames()
Return the names of the attributes of this table.
std::vector< StationRow * > privateRows
A data structure to store the pointers on the table&#39;s rows.
Definition: StationTable.h:455
asdmIDL::StationTableIDL * toIDL()
Conversion Methods.
Entity getEntity() const
Return this table&#39;s Entity.
static const ByteOrder * Machine_Endianity
Definition: Misc.h:119
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...
struct _xmlDoc xmlDoc
Definition: Misc.h:59
void setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
ASDM & getContainer() const
Return the container to which this table belongs.
A class to represent byte order information.
Definition: Misc.h:115
std::string getVersion() const
Return the version information about this 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).
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
virtual ~StationTable()
void setEntity(Entity e)
Set this table&#39;s Entity.
std::string version
Definition: StationTable.h:410
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a StationTable as those produced by the toFile...
static const std::vector< std::string > & getKeyName()
Return the list of field names that make up key key as an array of strings.
The StationTable class is an Alma table.
Definition: StationTable.h:158
std::vector< StationRow * > row
Definition: StationTable.h:459
static std::string name()
Return the name of this table.
void toFile(std::string directory)
Stores a representation (binary or XML) of this table into a file.
void addWithoutCheckingUnique(StationRow *x)
Brutally append an StationRow x to the collection of rows already stored in this table.
StationRow * lookup(std::string name, std::vector< Length > position, StationTypeMod::StationType type)
Look up the table for a row whose all attributes except the autoincrementable one are equal to the co...
The Tag class is an implementation of a unique index identifying a row of an ASDM table...
Definition: Tag.h:73
StationRow * add(StationRow *x)
====&gt; Append a row to its 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.
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
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:
StationRow * getRowByKey(Tag stationId)
Returns a StationRow* 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...
static const std::vector< std::string > & defaultAttributesNamesInBin()
Return the default sorted list of attributes names in the binary representation of the table...
bool loadInProgress
Load the table in memory if necessary.
Definition: StationTable.h:522
void checkPresenceInMemory()
Definition: StationTable.h:523
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...
void append(StationRow *x)
Brutally append an StationRow x to the collection of rows already stored in this table.
void autoIncrement(std::string key, StationRow *x)
StationRow * checkAndAdd(StationRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
Definition: StationTable.h:473
std::string getName() const
Return the name of this table.
The StationRow class is a row of a StationTable.
Definition: StationRow.h:106
std::string toXML()
Produces an XML representation conform to the schema defined for Station (StationTable.xsd).
unsigned int size() const
Return the number of rows in the table.
StationRow * newRow()
====&gt; Row creation.
void fromIDL(asdmIDL::StationTableIDL x)
Populate this table from the content of a StationTableIDL Corba structure.
std::map< std::string, int > noAutoIncIds
A map for the autoincrementation algorithm.
Definition: StationTable.h:419
void setFromXMLFile(const std::string &directory)
StationTable(ASDM &container)
Create a StationTable.
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59