casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FlagTable.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 FlagTable.h
32  */
33 
34 #ifndef FlagTable_CLASS
35 #define FlagTable_CLASS
36 
37 #include <string>
38 #include <vector>
39 #include <map>
40 
41 
42 
43 
44 #include <alma/ASDM/ArrayTime.h>
45 
46 
47 
48 #include <alma/ASDM/Tag.h>
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72 
74 
75 
76 
77 
78 
79 
81 #include <alma/ASDM/DuplicateKey.h>
83 #include <alma/ASDM/NoSuchRow.h>
84 #include <alma/ASDM/DuplicateKey.h>
85 
86 
87 #ifndef WITHOUT_ACS
88 #include <asdmIDLC.h>
89 #endif
90 
92 
93 #include <pthread.h>
94 
95 namespace asdm {
96 
97 //class asdm::ASDM;
98 //class asdm::FlagRow;
99 
100 class ASDM;
101 class FlagRow;
234 class FlagTable : public Representable {
235  friend class ASDM;
236 
237 public:
238 
239 
245  static const std::vector<std::string>& getKeyName();
246 
247 
248  virtual ~FlagTable();
249 
255  ASDM &getContainer() const;
256 
262  unsigned int size() const;
263 
271  std::string getName() const;
272 
280  static std::string name() ;
281 
286  std::string getVersion() const ;
287 
293  static const std::vector<std::string>& getAttributesNames();
294 
300  static const std::vector<std::string>& defaultAttributesNamesInBin();
301 
305  Entity getEntity() const;
306 
311  void setEntity(Entity e);
312 
320  std::string toXML() ;
321 
322 #ifndef WITHOUT_ACS
323  // Conversion Methods
329  asdmIDL::FlagTableIDL *toIDL() ;
330 
338  void toIDL(asdmIDL::FlagTableIDL& x) const;
339 
340 #endif
341 
342 #ifndef WITHOUT_ACS
343 
349  void fromIDL(asdmIDL::FlagTableIDL x) ;
350 #endif
351 
352  //
353  // ====> Row creation.
354  //
355 
360  FlagRow *newRow();
361 
362 
378  FlagRow *newRow(ArrayTime startTime, ArrayTime endTime, std::string reason, int numAntenna, std::vector<Tag> antennaId);
379 
380 
381 
395 
396  //
397  // ====> Append a row to its table.
398  //
399 
400 
401 
402 
412  FlagRow* add(FlagRow* x) ;
413 
414 
415 
416  //
417  // ====> Methods returning rows.
418  //
419 
425  std::vector<FlagRow *> get() ;
426 
433  const std::vector<FlagRow *>& get() const ;
434 
435 
436 
437 
438 
448  FlagRow* getRowByKey(Tag flagId);
449 
450 
451 
452 
453 
471  FlagRow* lookup(ArrayTime startTime, ArrayTime endTime, std::string reason, int numAntenna, std::vector<Tag> antennaId);
472 
473 
474  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
475  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
476 
477 private:
478 
488 
490 
491  bool archiveAsBin; // If true archive binary else archive XML
492  bool fileAsBin ; // If true file binary else file XML
493 
494  std::string version ;
495 
497 
498 
499 
500 
501 
502  // A map for the autoincrementation algorithm
503  std::map<std::string,int> noAutoIncIds;
504  void autoIncrement(std::string key, FlagRow* x);
505 
506 
516  FlagRow* checkAndAdd(FlagRow* x, bool skipCheckUniqueness=false) ;
517 
523  void append(FlagRow* x) ;
524 
531 
532 
533 
534 
535 
536 // A data structure to store the pointers on the table's rows.
537 
538 // In all cases we maintain a private vector of FlagRow s.
539  std::vector<FlagRow * > privateRows;
540 
541 
542 
543  std::vector<FlagRow *> row;
544 
545 
546  void error() ; //throw(ConversionException);
547 
548 
555  void fromXML(std::string& xmlDoc) ;
556 
557  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
558 
563  void setFromMIMEFile(const std::string& directory);
564  /*
565  void openMIMEFile(const std::string& directory);
566  */
567  void setFromXMLFile(const std::string& directory);
568 
576  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
577 
578 
585  void setFromMIME(const std::string & mimeMsg);
586 
590  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
591 
601  void toFile(std::string directory);
602 
608  if (!presentInMemory && !loadInProgress) {
609  loadInProgress = true;
610  setFromFile(getContainer().getDirectory());
611  presentInMemory = true;
612  loadInProgress = false;
613  }
614  }
623  void setFromFile(const std::string& directory);
624 
625 };
626 
627 } // End namespace asdm
628 
629 #endif /* FlagTable_CLASS */
static const ByteOrder * Machine_Endianity
Definition: Misc.h:119
static const std::vector< std::string > & defaultAttributesNamesInBin()
Return the default sorted list of attributes names in the binary representation of the table...
unsigned int size() const
Return the number of rows in the table.
struct _xmlDoc xmlDoc
Definition: Misc.h:59
Entity getEntity() const
Return this table&#39;s Entity.
void addWithoutCheckingUnique(FlagRow *x)
Brutally append an FlagRow 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.
A class to represent byte order information.
Definition: Misc.h:115
std::vector< FlagRow * > privateRows
A data structure to store the pointers on the table&#39;s rows.
Definition: FlagTable.h:539
void autoIncrement(std::string key, FlagRow *x)
The ASDM class is the container for all tables.
Definition: ASDM.h:273
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a FlagTable as those produced by the toFile me...
FlagRow * newRow()
====&gt; Row creation.
void fromIDL(asdmIDL::FlagTableIDL x)
Populate this table from the content of a FlagTableIDL Corba structure.
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.
static std::string name()
Return the name of this table.
static const std::vector< std::string > & getAttributesNames()
Return the names of the attributes of this table.
FlagRow * lookup(ArrayTime startTime, ArrayTime endTime, std::string reason, int numAntenna, std::vector< Tag > antennaId)
Look up the table for a row whose all attributes except the autoincrementable one are equal to the co...
void setFromXMLFile(const std::string &directory)
FlagRow * add(FlagRow *x)
====&gt; Append a row to its table.
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
asdmIDL::FlagTableIDL * toIDL()
Conversion Methods.
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 fromXML(std::string &xmlDoc)
Populate this table from the content of a XML document that is required to be conform to the XML sche...
FlagTable(ASDM &container)
Create a FlagTable.
void append(FlagRow *x)
Brutally append an FlagRow x to the collection of rows already stored in this table.
The ArrayTime class implements the concept of a point in time, implemented as an Interval of time sin...
Definition: ArrayTime.h:89
FlagRow * getRowByKey(Tag flagId)
Returns a FlagRow* given a key.
std::string getName() const
Return the name of this table.
ASDM & container
Definition: FlagTable.h:489
The Tag class is an implementation of a unique index identifying a row of an ASDM table...
Definition: Tag.h:73
std::map< std::string, int > noAutoIncIds
A map for the autoincrementation algorithm.
Definition: FlagTable.h:503
bool loadInProgress
Load the table in memory if necessary.
Definition: FlagTable.h:606
void checkPresenceInMemory()
Definition: FlagTable.h:607
void toFile(std::string directory)
Stores a representation (binary or XML) of this table into a file.
void setEntity(Entity e)
Set this table&#39;s Entity.
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
FlagRow * checkAndAdd(FlagRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
const Double e
e and functions thereof:
std::string toXML()
Produces an XML representation conform to the schema defined for Flag (FlagTable.xsd).
The FlagRow class is a row of a FlagTable.
Definition: FlagRow.h:123
virtual ~FlagTable()
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
Definition: FlagTable.h:557
ASDM & getContainer() const
Return the container to which this table belongs.
std::string version
Definition: FlagTable.h:494
The FlagTable class is an Alma table.
Definition: FlagTable.h:234
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 getVersion() const
Return the version information about this table.
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 setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59
std::vector< FlagRow * > row
Definition: FlagTable.h:543