casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FieldTable.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 FieldTable.h
32  */
33 
34 #ifndef FieldTable_CLASS
35 #define FieldTable_CLASS
36 
37 #include <string>
38 #include <vector>
39 #include <map>
40 
41 
42 
43 
44 #include <alma/ASDM/Angle.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 
65 
66 
67 
68 
69 
70 
71 
72 
73 
74 
76 
77 
78 
79 
80 
81 
82 
83 
85 #include <alma/ASDM/DuplicateKey.h>
87 #include <alma/ASDM/NoSuchRow.h>
88 #include <alma/ASDM/DuplicateKey.h>
89 
90 
91 #ifndef WITHOUT_ACS
92 #include <asdmIDLC.h>
93 #endif
94 
96 
97 #include <pthread.h>
98 
99 namespace asdm {
100 
101 //class asdm::ASDM;
102 //class asdm::FieldRow;
103 
104 class ASDM;
105 class FieldRow;
233 class FieldTable : public Representable {
234  friend class ASDM;
235 
236 public:
237 
238 
244  static const std::vector<std::string>& getKeyName();
245 
246 
247  virtual ~FieldTable();
248 
254  ASDM &getContainer() const;
255 
261  unsigned int size() const;
262 
270  std::string getName() const;
271 
279  static std::string name() ;
280 
285  std::string getVersion() const ;
286 
292  static const std::vector<std::string>& getAttributesNames();
293 
299  static const std::vector<std::string>& defaultAttributesNamesInBin();
300 
304  Entity getEntity() const;
305 
310  void setEntity(Entity e);
311 
319  std::string toXML() ;
320 
321 #ifndef WITHOUT_ACS
322  // Conversion Methods
328  asdmIDL::FieldTableIDL *toIDL() ;
329 
337  void toIDL(asdmIDL::FieldTableIDL& x) const;
338 
339 #endif
340 
341 #ifndef WITHOUT_ACS
342 
348  void fromIDL(asdmIDL::FieldTableIDL x) ;
349 #endif
350 
351  //
352  // ====> Row creation.
353  //
354 
359  FieldRow *newRow();
360 
361 
377  FieldRow *newRow(std::string fieldName, int numPoly, std::vector<std::vector<Angle > > delayDir, std::vector<std::vector<Angle > > phaseDir, std::vector<std::vector<Angle > > referenceDir);
378 
379 
380 
394 
395  //
396  // ====> Append a row to its table.
397  //
398 
399 
400 
401 
411  FieldRow* add(FieldRow* x) ;
412 
413 
414 
415  //
416  // ====> Methods returning rows.
417  //
418 
424  std::vector<FieldRow *> get() ;
425 
432  const std::vector<FieldRow *>& get() const ;
433 
434 
435 
436 
437 
447  FieldRow* getRowByKey(Tag fieldId);
448 
449 
450 
451 
452 
470  FieldRow* lookup(std::string fieldName, int numPoly, std::vector<std::vector<Angle > > delayDir, std::vector<std::vector<Angle > > phaseDir, std::vector<std::vector<Angle > > referenceDir);
471 
472 
473  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
474  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
475 
476 private:
477 
487 
489 
490  bool archiveAsBin; // If true archive binary else archive XML
491  bool fileAsBin ; // If true file binary else file XML
492 
493  std::string version ;
494 
496 
497 
498 
499 
500 
501  // A map for the autoincrementation algorithm
502  std::map<std::string,int> noAutoIncIds;
503  void autoIncrement(std::string key, FieldRow* x);
504 
505 
515  FieldRow* checkAndAdd(FieldRow* x, bool skipCheckUniqueness=false) ;
516 
522  void append(FieldRow* x) ;
523 
530 
531 
532 
533 
534 
535 // A data structure to store the pointers on the table's rows.
536 
537 // In all cases we maintain a private vector of FieldRow s.
538  std::vector<FieldRow * > privateRows;
539 
540 
541 
542  std::vector<FieldRow *> row;
543 
544 
545  void error() ; //throw(ConversionException);
546 
547 
554  void fromXML(std::string& xmlDoc) ;
555 
556  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
557 
562  void setFromMIMEFile(const std::string& directory);
563  /*
564  void openMIMEFile(const std::string& directory);
565  */
566  void setFromXMLFile(const std::string& directory);
567 
575  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
576 
577 
584  void setFromMIME(const std::string & mimeMsg);
585 
589  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
590 
600  void toFile(std::string directory);
601 
607  if (!presentInMemory && !loadInProgress) {
608  loadInProgress = true;
609  setFromFile(getContainer().getDirectory());
610  presentInMemory = true;
611  loadInProgress = false;
612  }
613  }
622  void setFromFile(const std::string& directory);
623 
624 };
625 
626 } // End namespace asdm
627 
628 #endif /* FieldTable_CLASS */
FieldTable(ASDM &container)
Create a FieldTable.
virtual ~FieldTable()
std::vector< FieldRow * > privateRows
A data structure to store the pointers on the table&#39;s rows.
Definition: FieldTable.h:538
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.
The FieldTable class is an Alma table.
Definition: FieldTable.h:233
struct _xmlDoc xmlDoc
Definition: Misc.h:59
static const std::vector< std::string > & defaultAttributesNamesInBin()
Return the default sorted list of attributes names in the binary representation of the table...
A class to represent byte order information.
Definition: Misc.h:115
bool loadInProgress
Load the table in memory if necessary.
Definition: FieldTable.h:605
FieldRow * add(FieldRow *x)
====&gt; Append a row to its table.
The ASDM class is the container for all tables.
Definition: ASDM.h:273
void setFromXMLFile(const std::string &directory)
static std::string name()
Return the name of 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...
asdmIDL::FieldTableIDL * toIDL()
Conversion Methods.
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
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...
std::string getName() const
Return the name of this table.
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).
ASDM & getContainer() const
Return the container to which this table belongs.
static const std::vector< std::string > & getAttributesNames()
Return the names of the attributes of this table.
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
Definition: FieldTable.h:556
static const std::vector< std::string > & getKeyName()
Return the list of field names that make up key key as an array of strings.
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 Field (FieldTable.xsd).
void checkPresenceInMemory()
Definition: FieldTable.h:606
FieldRow * lookup(std::string fieldName, int numPoly, std::vector< std::vector< Angle > > delayDir, std::vector< std::vector< Angle > > phaseDir, std::vector< std::vector< Angle > > referenceDir)
Look up the table for a row whose all attributes except the autoincrementable one are equal to the co...
void addWithoutCheckingUnique(FieldRow *x)
Brutally append an FieldRow x to the collection of rows already stored in this table.
The Tag class is an implementation of a unique index identifying a row of an ASDM table...
Definition: Tag.h:73
unsigned int size() const
Return the number of rows in the table.
FieldRow * checkAndAdd(FieldRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
The FieldRow class is a row of a FieldTable.
Definition: FieldRow.h:127
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:
std::map< std::string, int > noAutoIncIds
A map for the autoincrementation algorithm.
Definition: FieldTable.h:502
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a FieldTable as those produced by the toFile m...
void setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
void setEntity(Entity e)
Set this table&#39;s Entity.
void append(FieldRow *x)
Brutally append an FieldRow x to the collection of rows already stored in this table.
Entity getEntity() const
Return this table&#39;s Entity.
std::vector< FieldRow * > row
Definition: FieldTable.h:542
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.
void fromIDL(asdmIDL::FieldTableIDL x)
Populate this table from the content of a FieldTableIDL Corba structure.
void autoIncrement(std::string key, FieldRow *x)
FieldRow * newRow()
====&gt; Row creation.
FieldRow * getRowByKey(Tag fieldId)
Returns a FieldRow* given a key.
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59
std::string version
Definition: FieldTable.h:493