casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AnnotationTable.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 AnnotationTable.h
32  */
33 
34 #ifndef AnnotationTable_CLASS
35 #define AnnotationTable_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 #include <alma/ASDM/Interval.h>
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
70 
71 
72 
73 
74 
75 
76 
77 
78 
79 
80 
81 
82 
83 
84 
85 
86 
87 
88 
89 
90 
91 
93 #include <alma/ASDM/DuplicateKey.h>
95 #include <alma/ASDM/NoSuchRow.h>
96 #include <alma/ASDM/DuplicateKey.h>
97 
98 
99 #ifndef WITHOUT_ACS
100 #include <asdmIDLC.h>
101 #endif
102 
103 #include <alma/ASDM/Representable.h>
104 
105 #include <pthread.h>
106 
107 namespace asdm {
108 
109 //class asdm::ASDM;
110 //class asdm::AnnotationRow;
111 
112 class ASDM;
113 class AnnotationRow;
256  friend class ASDM;
257 
258 public:
259 
260 
266  static const std::vector<std::string>& getKeyName();
267 
268 
269  virtual ~AnnotationTable();
270 
276  ASDM &getContainer() const;
277 
283  unsigned int size() const;
284 
292  std::string getName() const;
293 
301  static std::string name() ;
302 
307  std::string getVersion() const ;
308 
314  static const std::vector<std::string>& getAttributesNames();
315 
321  static const std::vector<std::string>& defaultAttributesNamesInBin();
322 
326  Entity getEntity() const;
327 
332  void setEntity(Entity e);
333 
341  std::string toXML() ;
342 
343 #ifndef WITHOUT_ACS
344  // Conversion Methods
350  asdmIDL::AnnotationTableIDL *toIDL() ;
351 
359  void toIDL(asdmIDL::AnnotationTableIDL& x) const;
360 
361 #endif
362 
363 #ifndef WITHOUT_ACS
364 
370  void fromIDL(asdmIDL::AnnotationTableIDL x) ;
371 #endif
372 
373  //
374  // ====> Row creation.
375  //
376 
382 
383 
395  AnnotationRow *newRow(ArrayTime time, std::string issue, std::string details);
396 
397 
398 
412 
413  //
414  // ====> Append a row to its table.
415  //
416 
417 
418 
419 
430 
431 
432 
433  //
434  // ====> Methods returning rows.
435  //
436 
442  std::vector<AnnotationRow *> get() ;
443 
450  const std::vector<AnnotationRow *>& get() const ;
451 
452 
453 
454 
455 
465  AnnotationRow* getRowByKey(Tag annotationId);
466 
467 
468 
469 
470 
484  AnnotationRow* lookup(ArrayTime time, std::string issue, std::string details);
485 
486 
487  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
488  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
489 
490 private:
491 
501 
503 
504  bool archiveAsBin; // If true archive binary else archive XML
505  bool fileAsBin ; // If true file binary else file XML
506 
507  std::string version ;
508 
510 
511 
512 
513 
514 
515  // A map for the autoincrementation algorithm
516  std::map<std::string,int> noAutoIncIds;
517  void autoIncrement(std::string key, AnnotationRow* x);
518 
519 
529  AnnotationRow* checkAndAdd(AnnotationRow* x, bool skipCheckUniqueness=false) ;
530 
536  void append(AnnotationRow* x) ;
537 
544 
545 
546 
547 
548 
549 // A data structure to store the pointers on the table's rows.
550 
551 // In all cases we maintain a private vector of AnnotationRow s.
552  std::vector<AnnotationRow * > privateRows;
553 
554 
555 
556  std::vector<AnnotationRow *> row;
557 
558 
559  void error() ; //throw(ConversionException);
560 
561 
568  void fromXML(std::string& xmlDoc) ;
569 
570  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
571 
576  void setFromMIMEFile(const std::string& directory);
577  /*
578  void openMIMEFile(const std::string& directory);
579  */
580  void setFromXMLFile(const std::string& directory);
581 
589  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
590 
591 
598  void setFromMIME(const std::string & mimeMsg);
599 
603  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
604 
614  void toFile(std::string directory);
615 
621  if (!presentInMemory && !loadInProgress) {
622  loadInProgress = true;
623  setFromFile(getContainer().getDirectory());
624  presentInMemory = true;
625  loadInProgress = false;
626  }
627  }
636  void setFromFile(const std::string& directory);
637 
638 };
639 
640 } // End namespace asdm
641 
642 #endif /* AnnotationTable_CLASS */
static const std::vector< std::string > & getKeyName()
Return the list of field names that make up key key as an array of strings.
std::vector< AnnotationRow * > row
static const ByteOrder * Machine_Endianity
Definition: Misc.h:119
AnnotationTable(ASDM &container)
Create a AnnotationTable.
static const std::vector< std::string > & getAttributesNames()
Return the names of the attributes of this table.
struct _xmlDoc xmlDoc
Definition: Misc.h:59
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
void setEntity(Entity e)
Set this table&#39;s Entity.
std::string getName() const
Return the name of this table.
A class to represent byte order information.
Definition: Misc.h:115
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...
void setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
virtual ~AnnotationTable()
static std::string name()
Return the name of this table.
void append(AnnotationRow *x)
Brutally append an AnnotationRow x to the collection of rows already stored in this table...
asdmIDL::AnnotationTableIDL * toIDL()
Conversion Methods.
ABSTRACT TOOL CLASSES A PlotTool is a higher level event handler for a PlotCanvas The idea is to take common tasks which may require multiple events and put them in one place PlotTools also provide additional functionality in that they can be active and blocking non blocking The PlotCanvas will only send events to active and will not send events to later tools or event handlers if the latest tool was blocking In this way a single tool can be used to handle ALL user interaction via the GUI at one time
Definition: PlotTool.h:43
The ASDM class is the container for all tables.
Definition: ASDM.h:273
void toFile(std::string directory)
Stores a representation (binary or XML) of this table into a file.
std::map< std::string, int > noAutoIncIds
A map for the autoincrementation algorithm.
bool loadInProgress
Load the table in memory if necessary.
void autoIncrement(std::string key, AnnotationRow *x)
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 setFromXMLFile(const std::string &directory)
Entity getEntity() const
Return this table&#39;s Entity.
AnnotationRow * add(AnnotationRow *x)
====&gt; Append a row to its table.
static const std::vector< std::string > & defaultAttributesNamesInBin()
Return the default sorted list of attributes names in the binary representation of the table...
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
AnnotationRow * checkAndAdd(AnnotationRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
std::string getVersion() const
Return the version information about this table.
AnnotationRow * lookup(ArrayTime time, std::string issue, std::string details)
Look up the table for a row whose all attributes except the autoincrementable one are equal to the co...
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...
The AnnotationRow class is a row of a AnnotationTable.
The ArrayTime class implements the concept of a point in time, implemented as an Interval of time sin...
Definition: ArrayTime.h:89
AnnotationRow * getRowByKey(Tag annotationId)
Returns a AnnotationRow* given a key.
The Tag class is an implementation of a unique index identifying a row of an ASDM table...
Definition: Tag.h:73
void addWithoutCheckingUnique(AnnotationRow *x)
Brutally append an AnnotationRow x to the collection of rows already stored in 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
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.
std::string toXML()
Produces an XML representation conform to the schema defined for Annotation (AnnotationTable.xsd).
const Double e
e and functions thereof:
void fromIDL(asdmIDL::AnnotationTableIDL x)
Populate this table from the content of a AnnotationTableIDL Corba structure.
AnnotationRow * newRow()
====&gt; Row creation.
ASDM & getContainer() const
Return the container to which this table belongs.
unsigned int size() const
Return the number of rows in the table.
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a AnnotationTable as those produced by the toF...
The AnnotationTable class is an Alma table.
std::vector< AnnotationRow * > privateRows
A data structure to store the pointers on the table&#39;s rows.
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 Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59