casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FlagCmdTable.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 FlagCmdTable.h
32  */
33 
34 #ifndef FlagCmdTable_CLASS
35 #define FlagCmdTable_CLASS
36 
37 #include <string>
38 #include <vector>
39 #include <map>
40 
41 
42 
43 
45 
46 
47 
48 
49 
50 
51 
52 
53 
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::FlagCmdRow;
85 
86 class ASDM;
87 class FlagCmdRow;
163 class FlagCmdTable : public Representable {
164  friend class ASDM;
165 
166 public:
167 
168 
174  static const std::vector<std::string>& getKeyName();
175 
176 
177  virtual ~FlagCmdTable();
178 
184  ASDM &getContainer() const;
185 
191  unsigned int size() const;
192 
200  std::string getName() const;
201 
209  static std::string name() ;
210 
215  std::string getVersion() const ;
216 
222  static const std::vector<std::string>& getAttributesNames();
223 
229  static const std::vector<std::string>& defaultAttributesNamesInBin();
230 
234  Entity getEntity() const;
235 
240  void setEntity(Entity e);
241 
249  std::string toXML() ;
250 
251 #ifndef WITHOUT_ACS
252  // Conversion Methods
258  asdmIDL::FlagCmdTableIDL *toIDL() ;
259 
267  void toIDL(asdmIDL::FlagCmdTableIDL& x) const;
268 
269 #endif
270 
271 #ifndef WITHOUT_ACS
272 
278  void fromIDL(asdmIDL::FlagCmdTableIDL x) ;
279 #endif
280 
281  //
282  // ====> Row creation.
283  //
284 
289  FlagCmdRow *newRow();
290 
291 
311  FlagCmdRow *newRow(ArrayTimeInterval timeInterval, std::string type, std::string reason, int level, int severity, bool applied, std::string command);
312 
313 
314 
328 
329  //
330  // ====> Append a row to its table.
331  //
332 
333 
350  FlagCmdRow* add(FlagCmdRow* x) ;
351 
352 
353 
354 
355 
356  //
357  // ====> Methods returning rows.
358  //
359 
365  std::vector<FlagCmdRow *> get() ;
366 
373  const std::vector<FlagCmdRow *>& get() const ;
374 
375 
386  std::vector <FlagCmdRow*> *getByContext();
387 
388 
389 
390 
391 
402 
403 
404 
405 
406 
428  FlagCmdRow* lookup(ArrayTimeInterval timeInterval, std::string type, std::string reason, int level, int severity, bool applied, std::string command);
429 
430 
431  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
432  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
433 
434 private:
435 
445 
447 
448  bool archiveAsBin; // If true archive binary else archive XML
449  bool fileAsBin ; // If true file binary else file XML
450 
451  std::string version ;
452 
454 
455 
456 
457 
458 
459 
467  FlagCmdRow* checkAndAdd(FlagCmdRow* x, bool skipCheckUniqueness=false) ;
468 
474  void append(FlagCmdRow* x) ;
475 
482 
483 
484 
485 
486 
487 
495  FlagCmdRow * insertByStartTime(FlagCmdRow* x, std::vector<FlagCmdRow* >& row);
496 
497 
498 
499 // A data structure to store the pointers on the table's rows.
500 
501 // In all cases we maintain a private vector of FlagCmdRow s.
502  std::vector<FlagCmdRow * > privateRows;
503 
504 
505 
506 
507 
508 
509 
510 
511  std::vector <FlagCmdRow *> row;
512 
513 
514 
515 
516 
517 
518  void error() ; //throw(ConversionException);
519 
520 
527  void fromXML(std::string& xmlDoc) ;
528 
529  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
530 
535  void setFromMIMEFile(const std::string& directory);
536  /*
537  void openMIMEFile(const std::string& directory);
538  */
539  void setFromXMLFile(const std::string& directory);
540 
548  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
549 
550 
557  void setFromMIME(const std::string & mimeMsg);
558 
562  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
563 
573  void toFile(std::string directory);
574 
580  if (!presentInMemory && !loadInProgress) {
581  loadInProgress = true;
582  setFromFile(getContainer().getDirectory());
583  presentInMemory = true;
584  loadInProgress = false;
585  }
586  }
595  void setFromFile(const std::string& directory);
596 
597 };
598 
599 } // End namespace asdm
600 
601 #endif /* FlagCmdTable_CLASS */
static const std::vector< std::string > & defaultAttributesNamesInBin()
Return the default sorted list of attributes names in the binary representation of the table...
static const ByteOrder * Machine_Endianity
Definition: Misc.h:119
std::string toXML()
Produces an XML representation conform to the schema defined for FlagCmd (FlagCmdTable.xsd).
FlagCmdRow * lookup(ArrayTimeInterval timeInterval, std::string type, std::string reason, int level, int severity, bool applied, std::string command)
Look up the table for a row whose all attributes are equal to the corresponding parameters of the met...
struct _xmlDoc xmlDoc
Definition: Misc.h:59
The ArrayTimeInterval class aggregates an instance of ArrayTime and an instance of Interval...
FlagCmdTable(ASDM &container)
Create a FlagCmdTable.
A class to represent byte order information.
Definition: Misc.h:115
ASDM & getContainer() const
Return the container to which this table belongs.
void fromIDL(asdmIDL::FlagCmdTableIDL x)
Populate this table from the content of a FlagCmdTableIDL Corba structure.
static const std::vector< std::string > & getAttributesNames()
Return the names of the attributes of this table.
The ASDM class is the container for all tables.
Definition: ASDM.h:273
The FlagCmdTable class is an Alma table.
Definition: FlagCmdTable.h:163
static std::string name()
Return the name of this table.
FlagCmdRow * getRowByKey(ArrayTimeInterval timeInterval)
Returns a FlagCmdRow* given a key.
virtual casacore::String type() const
Implements RegionShape::type.
Definition: RegionShapes.h:548
asdmIDL::FlagCmdTableIDL * toIDL()
Conversion Methods.
std::vector< FlagCmdRow * > row
Definition: FlagCmdTable.h:511
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
FlagCmdRow * newRow()
====&gt; Row creation.
FlagCmdRow * checkAndAdd(FlagCmdRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
Entity getEntity() const
Return this table&#39;s Entity.
void setFromXMLFile(const std::string &directory)
FlagCmdRow * add(FlagCmdRow *x)
====&gt; Append a row to its table.
std::vector< FlagCmdRow * > privateRows
A data structure to store the pointers on the table&#39;s rows.
Definition: FlagCmdTable.h:502
virtual ~FlagCmdTable()
void toFile(std::string directory)
Stores a representation (binary or XML) of this table into a file.
The FlagCmdRow class is a row of a FlagCmdTable.
Definition: FlagCmdRow.h:100
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 version
Definition: FlagCmdTable.h:451
std::string getName() const
Return the name of 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.
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
Definition: FlagCmdTable.h:529
void setEntity(Entity e)
Set this table&#39;s Entity.
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...
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:
bool loadInProgress
Load the table in memory if necessary.
Definition: FlagCmdTable.h:578
void append(FlagCmdRow *x)
Brutally append an FlagCmdRow x to the collection of rows already stored in this table.
std::vector< FlagCmdRow * > * getByContext()
Returns all the rows sorted by ascending startTime for a given context.
FlagCmdRow * insertByStartTime(FlagCmdRow *x, std::vector< FlagCmdRow * > &row)
Insert a FlagCmdRow* in a vector of FlagCmdRow* so that it&#39;s ordered by ascending time...
void addWithoutCheckingUnique(FlagCmdRow *x)
Brutally append an FlagCmdRow 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 FlagCmdTable as those produced by the toFile...
void checkPresenceInMemory()
Definition: FlagCmdTable.h:579
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 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 getVersion() const
Return the version information about this table.
unsigned int size() const
Return the number of rows in the table.
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59
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)