casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StateTable.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 StateTable.h
32  */
33 
34 #ifndef StateTable_CLASS
35 #define StateTable_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 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
67 #include <alma/ASDM/DuplicateKey.h>
69 #include <alma/ASDM/NoSuchRow.h>
70 #include <alma/ASDM/DuplicateKey.h>
71 
72 
73 #ifndef WITHOUT_ACS
74 #include <asdmIDLC.h>
75 #endif
76 
78 
79 #include <pthread.h>
80 
81 namespace asdm {
82 
83 //class asdm::ASDM;
84 //class asdm::StateRow;
85 
86 class ASDM;
87 class StateRow;
159 class StateTable : public Representable {
160  friend class ASDM;
161 
162 public:
163 
164 
170  static const std::vector<std::string>& getKeyName();
171 
172 
173  virtual ~StateTable();
174 
180  ASDM &getContainer() const;
181 
187  unsigned int size() const;
188 
196  std::string getName() const;
197 
205  static std::string name() ;
206 
211  std::string getVersion() const ;
212 
218  static const std::vector<std::string>& getAttributesNames();
219 
225  static const std::vector<std::string>& defaultAttributesNamesInBin();
226 
230  Entity getEntity() const;
231 
236  void setEntity(Entity e);
237 
245  std::string toXML() ;
246 
247 #ifndef WITHOUT_ACS
248  // Conversion Methods
254  asdmIDL::StateTableIDL *toIDL() ;
255 
263  void toIDL(asdmIDL::StateTableIDL& x) const;
264 
265 #endif
266 
267 #ifndef WITHOUT_ACS
268 
274  void fromIDL(asdmIDL::StateTableIDL x) ;
275 #endif
276 
277  //
278  // ====> Row creation.
279  //
280 
285  StateRow *newRow();
286 
287 
301  StateRow *newRow(CalibrationDeviceMod::CalibrationDevice calDeviceName, bool sig, bool ref, bool onSky);
302 
303 
304 
318 
319  //
320  // ====> Append a row to its table.
321  //
322 
323 
324 
325 
335  StateRow* add(StateRow* x) ;
336 
337 
338 
339  //
340  // ====> Methods returning rows.
341  //
342 
348  std::vector<StateRow *> get() ;
349 
356  const std::vector<StateRow *>& get() const ;
357 
358 
359 
360 
361 
371  StateRow* getRowByKey(Tag stateId);
372 
373 
374 
375 
376 
392  StateRow* lookup(CalibrationDeviceMod::CalibrationDevice calDeviceName, bool sig, bool ref, bool onSky);
393 
394 
395  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
396  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
397 
398 private:
399 
409 
411 
412  bool archiveAsBin; // If true archive binary else archive XML
413  bool fileAsBin ; // If true file binary else file XML
414 
415  std::string version ;
416 
418 
419 
420 
421 
422 
423  // A map for the autoincrementation algorithm
424  std::map<std::string,int> noAutoIncIds;
425  void autoIncrement(std::string key, StateRow* x);
426 
427 
437  StateRow* checkAndAdd(StateRow* x, bool skipCheckUniqueness=false) ;
438 
444  void append(StateRow* x) ;
445 
452 
453 
454 
455 
456 
457 // A data structure to store the pointers on the table's rows.
458 
459 // In all cases we maintain a private vector of StateRow s.
460  std::vector<StateRow * > privateRows;
461 
462 
463 
464  std::vector<StateRow *> row;
465 
466 
467  void error() ; //throw(ConversionException);
468 
469 
476  void fromXML(std::string& xmlDoc) ;
477 
478  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
479 
484  void setFromMIMEFile(const std::string& directory);
485  /*
486  void openMIMEFile(const std::string& directory);
487  */
488  void setFromXMLFile(const std::string& directory);
489 
497  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
498 
499 
506  void setFromMIME(const std::string & mimeMsg);
507 
511  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
512 
522  void toFile(std::string directory);
523 
529  if (!presentInMemory && !loadInProgress) {
530  loadInProgress = true;
531  setFromFile(getContainer().getDirectory());
532  presentInMemory = true;
533  loadInProgress = false;
534  }
535  }
544  void setFromFile(const std::string& directory);
545 
546 };
547 
548 } // End namespace asdm
549 
550 #endif /* StateTable_CLASS */
void toFile(std::string directory)
Stores a representation (binary or XML) of this table into a file.
static const ByteOrder * Machine_Endianity
Definition: Misc.h:119
virtual ~StateTable()
Entity getEntity() const
Return this table&#39;s Entity.
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.
ASDM & getContainer() const
Return the container to which this table belongs.
StateRow * checkAndAdd(StateRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
struct _xmlDoc xmlDoc
Definition: Misc.h:59
std::vector< StateRow * > privateRows
A data structure to store the pointers on the table&#39;s rows.
Definition: StateTable.h:460
void fromIDL(asdmIDL::StateTableIDL x)
Populate this table from the content of a StateTableIDL Corba structure.
void setFromXMLFile(const std::string &directory)
void autoIncrement(std::string key, StateRow *x)
A class to represent byte order information.
Definition: Misc.h:115
std::string getVersion() const
Return the version information about 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...
The ASDM class is the container for all tables.
Definition: ASDM.h:273
static std::string name()
Return the name of this table.
unsigned int size() const
Return the number of rows in the table.
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
Definition: StateTable.h:478
std::string getName() const
Return the name of this table.
The StateRow class is a row of a StateTable.
Definition: StateRow.h:100
std::string version
Definition: StateTable.h:415
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...
std::string toXML()
Produces an XML representation conform to the schema defined for State (StateTable.xsd).
The StateTable class is an Alma table.
Definition: StateTable.h:159
StateRow * newRow()
====&gt; Row creation.
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
StateRow * getRowByKey(Tag stateId)
Returns a StateRow* given a key.
std::map< std::string, int > noAutoIncIds
A map for the autoincrementation algorithm.
Definition: StateTable.h:424
void setEntity(Entity e)
Set this table&#39;s Entity.
static const std::vector< std::string > & getKeyName()
Return the list of field names that make up key key as an array of strings.
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 checkPresenceInMemory()
Definition: StateTable.h:528
The Tag class is an implementation of a unique index identifying a row of an ASDM table...
Definition: Tag.h:73
StateRow * lookup(CalibrationDeviceMod::CalibrationDevice calDeviceName, bool sig, bool ref, bool onSky)
Look up the table for a row whose all attributes except the autoincrementable one are equal to the co...
StateTable(ASDM &container)
Create a StateTable.
static const std::vector< std::string > & defaultAttributesNamesInBin()
Return the default sorted list of attributes names in the binary representation of the table...
static const std::vector< std::string > & getAttributesNames()
Return the names of the attributes of this table.
std::vector< StateRow * > row
Definition: StateTable.h:464
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 setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
const Double e
e and functions thereof:
asdmIDL::StateTableIDL * toIDL()
Conversion Methods.
void append(StateRow *x)
Brutally append an StateRow x to the collection of rows already stored in this table.
void addWithoutCheckingUnique(StateRow *x)
Brutally append an StateRow x to the collection of rows already stored in this table.
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a StateTable as those produced by the toFile m...
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...
StateRow * add(StateRow *x)
====&gt; Append a row to its table.
bool loadInProgress
Load the table in memory if necessary.
Definition: StateTable.h:527
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59