casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HistoryTable.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 HistoryTable.h
32  */
33 
34 #ifndef HistoryTable_CLASS
35 #define HistoryTable_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 
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::HistoryRow;
91 
92 class ASDM;
93 class HistoryRow;
185 class HistoryTable : public Representable {
186  friend class ASDM;
187 
188 public:
189 
190 
196  static const std::vector<std::string>& getKeyName();
197 
198 
199  virtual ~HistoryTable();
200 
206  ASDM &getContainer() const;
207 
213  unsigned int size() const;
214 
222  std::string getName() const;
223 
231  static std::string name() ;
232 
237  std::string getVersion() const ;
238 
244  static const std::vector<std::string>& getAttributesNames();
245 
251  static const std::vector<std::string>& defaultAttributesNamesInBin();
252 
256  Entity getEntity() const;
257 
262  void setEntity(Entity e);
263 
271  std::string toXML() ;
272 
273 #ifndef WITHOUT_ACS
274  // Conversion Methods
280  asdmIDL::HistoryTableIDL *toIDL() ;
281 
289  void toIDL(asdmIDL::HistoryTableIDL& x) const;
290 
291 #endif
292 
293 #ifndef WITHOUT_ACS
294 
300  void fromIDL(asdmIDL::HistoryTableIDL x) ;
301 #endif
302 
303  //
304  // ====> Row creation.
305  //
306 
311  HistoryRow *newRow();
312 
313 
337  HistoryRow *newRow(Tag execBlockId, ArrayTime time, std::string message, std::string priority, std::string origin, std::string objectId, std::string application, std::string cliCommand, std::string appParms);
338 
339 
340 
353  HistoryRow *newRow(HistoryRow *row);
354 
355  //
356  // ====> Append a row to its table.
357  //
358 
359 
376  HistoryRow* add(HistoryRow* x) ;
377 
378 
379 
380 
381 
382  //
383  // ====> Methods returning rows.
384  //
385 
391  std::vector<HistoryRow *> get() ;
392 
399  const std::vector<HistoryRow *>& get() const ;
400 
401 
412  std::vector <HistoryRow*> *getByContext(Tag execBlockId);
413 
414 
415 
416 
417 
429  HistoryRow* getRowByKey(Tag execBlockId, ArrayTime time);
430 
431 
432 
433 
434 
460  HistoryRow* lookup(Tag execBlockId, ArrayTime time, std::string message, std::string priority, std::string origin, std::string objectId, std::string application, std::string cliCommand, std::string appParms);
461 
462 
463  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
464  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
465 
466 private:
467 
477 
479 
480  bool archiveAsBin; // If true archive binary else archive XML
481  bool fileAsBin ; // If true file binary else file XML
482 
483  std::string version ;
484 
486 
487 
488 
489 
490 
491 
499  HistoryRow* checkAndAdd(HistoryRow* x, bool skipCheckUniqueness=false) ;
500 
506  void append(HistoryRow* x) ;
507 
514 
515 
516 
517 
518 
519 
527  HistoryRow * insertByTime(HistoryRow* x, std::vector<HistoryRow *>&row );
528 
529 
530 
531 // A data structure to store the pointers on the table's rows.
532 
533 // In all cases we maintain a private vector of HistoryRow s.
534  std::vector<HistoryRow * > privateRows;
535 
536 
537 
538 
539 
540 
541 
542 
543  typedef std::vector <HistoryRow* > TIME_ROWS;
544  std::map<std::string, TIME_ROWS > context;
545 
550  std::string Key(Tag execBlockId) ;
551 
552 
553 
554 
560  void getByKeyNoAutoIncNoTime(std::vector <HistoryRow*>& vin, std::vector <HistoryRow*>& vout, Tag execBlockId);
561 
562 
563 
564  void error() ; //throw(ConversionException);
565 
566 
573  void fromXML(std::string& xmlDoc) ;
574 
575  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
576 
581  void setFromMIMEFile(const std::string& directory);
582  /*
583  void openMIMEFile(const std::string& directory);
584  */
585  void setFromXMLFile(const std::string& directory);
586 
594  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
595 
596 
603  void setFromMIME(const std::string & mimeMsg);
604 
608  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
609 
619  void toFile(std::string directory);
620 
626  if (!presentInMemory && !loadInProgress) {
627  loadInProgress = true;
628  setFromFile(getContainer().getDirectory());
629  presentInMemory = true;
630  loadInProgress = false;
631  }
632  }
641  void setFromFile(const std::string& directory);
642 
643 };
644 
645 } // End namespace asdm
646 
647 #endif /* HistoryTable_CLASS */
void append(HistoryRow *x)
Brutally append an HistoryRow 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.
static const ByteOrder * Machine_Endianity
Definition: Misc.h:119
std::string toXML()
Produces an XML representation conform to the schema defined for History (HistoryTable.xsd).
struct _xmlDoc xmlDoc
Definition: Misc.h:59
void fromIDL(asdmIDL::HistoryTableIDL x)
Populate this table from the content of a HistoryTableIDL Corba structure.
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
std::map< std::string, TIME_ROWS > context
Definition: HistoryTable.h:544
std::vector< HistoryRow * > privateRows
A data structure to store the pointers on the table&#39;s rows.
Definition: HistoryTable.h:534
std::vector< HistoryRow * > TIME_ROWS
Definition: HistoryTable.h:543
HistoryTable(ASDM &container)
Create a HistoryTable.
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
HistoryRow * checkAndAdd(HistoryRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
ASDM & getContainer() const
Return the container to which this table belongs.
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
Definition: HistoryTable.h:575
std::string Key(Tag execBlockId)
Returns a string built by concatenating the ascii representation of the parameters values suffixed wi...
std::vector< HistoryRow * > * getByContext(Tag execBlockId)
Returns all the rows sorted by ascending startTime for a given context.
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 const std::vector< std::string > & getAttributesNames()
Return the names of the attributes of this table.
void checkPresenceInMemory()
Definition: HistoryTable.h:625
HistoryRow * add(HistoryRow *x)
====&gt; Append a row to its table.
static std::string name()
Return the name of 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).
std::string getVersion() const
Return the version information about this table.
virtual ~HistoryTable()
HistoryRow * newRow()
====&gt; Row creation.
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a HistoryTable as those produced by the toFile...
void addWithoutCheckingUnique(HistoryRow *x)
Brutally append an HistoryRow x to the collection of rows already stored in this table.
The HistoryRow class is a row of a HistoryTable.
Definition: HistoryRow.h:109
The ArrayTime class implements the concept of a point in time, implemented as an Interval of time sin...
Definition: ArrayTime.h:89
unsigned int size() const
Return the number of rows in the table.
void toFile(std::string directory)
Stores a representation (binary or XML) of this table into a file.
The Tag class is an implementation of a unique index identifying a row of an ASDM table...
Definition: Tag.h:73
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...
virtual Origin origin() const =0
ABSTRACT METHODS //.
void getByKeyNoAutoIncNoTime(std::vector< HistoryRow * > &vin, std::vector< HistoryRow * > &vout, Tag execBlockId)
Fills the vector vout (passed by reference) with pointers on elements of vin whose attributes are equ...
HistoryRow * lookup(Tag execBlockId, ArrayTime time, std::string message, std::string priority, std::string origin, std::string objectId, std::string application, std::string cliCommand, std::string appParms)
Look up the table for a row whose all attributes are equal to the corresponding parameters of the met...
HistoryRow * getRowByKey(Tag execBlockId, ArrayTime time)
Returns a HistoryRow* given a key.
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
void setFromXMLFile(const std::string &directory)
const Double e
e and functions thereof:
Entity getEntity() const
Return this table&#39;s Entity.
std::string version
Definition: HistoryTable.h:483
HistoryRow * insertByTime(HistoryRow *x, std::vector< HistoryRow * > &row)
Insert a HistoryRow* in a vector of HistoryRow* so that it&#39;s ordered by ascending time...
The HistoryTable class is an Alma table.
Definition: HistoryTable.h:185
asdmIDL::HistoryTableIDL * toIDL()
Conversion Methods.
void setEntity(Entity e)
Set this table&#39;s Entity.
void setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
std::string getName() const
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...
bool loadInProgress
Load the table in memory if necessary.
Definition: HistoryTable.h:624
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59
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...