casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SysPowerTable.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 SysPowerTable.h
32  */
33 
34 #ifndef SysPowerTable_CLASS
35 #define SysPowerTable_CLASS
36 
37 #include <string>
38 #include <vector>
39 #include <map>
40 
41 
42 
43 
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 
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::SysPowerRow;
85 
86 class ASDM;
87 class SysPowerRow;
184 class SysPowerTable : public Representable {
185  friend class ASDM;
186 
187 public:
188 
189 
195  static const std::vector<std::string>& getKeyName();
196 
197 
198  virtual ~SysPowerTable();
199 
205  ASDM &getContainer() const;
206 
212  unsigned int size() const;
213 
221  std::string getName() const;
222 
230  static std::string name() ;
231 
236  std::string getVersion() const ;
237 
243  static const std::vector<std::string>& getAttributesNames();
244 
250  static const std::vector<std::string>& defaultAttributesNamesInBin();
251 
255  Entity getEntity() const;
256 
261  void setEntity(Entity e);
262 
270  std::string toXML() ;
271 
272 #ifndef WITHOUT_ACS
273  // Conversion Methods
279  asdmIDL::SysPowerTableIDL *toIDL() ;
280 
288  void toIDL(asdmIDL::SysPowerTableIDL& x) const;
289 
290 #endif
291 
292 #ifndef WITHOUT_ACS
293 
299  void fromIDL(asdmIDL::SysPowerTableIDL x) ;
300 #endif
301 
302  //
303  // ====> Row creation.
304  //
305 
310  SysPowerRow *newRow();
311 
312 
328  SysPowerRow *newRow(Tag antennaId, Tag spectralWindowId, int feedId, ArrayTimeInterval timeInterval, int numReceptor);
329 
330 
331 
345 
346  //
347  // ====> Append a row to its table.
348  //
349 
350 
367  SysPowerRow* add(SysPowerRow* x) ;
368 
369 
370 
371 
372 
373  //
374  // ====> Methods returning rows.
375  //
376 
382  std::vector<SysPowerRow *> get() ;
383 
390  const std::vector<SysPowerRow *>& get() const ;
391 
392 
403  std::vector <SysPowerRow*> *getByContext(Tag antennaId, Tag spectralWindowId, int feedId);
404 
405 
406 
407 
408 
424  SysPowerRow* getRowByKey(Tag antennaId, Tag spectralWindowId, int feedId, ArrayTimeInterval timeInterval);
425 
426 
427 
428 
429 
447  SysPowerRow* lookup(Tag antennaId, Tag spectralWindowId, int feedId, ArrayTimeInterval timeInterval, int numReceptor);
448 
449 
450  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
451  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
452 
453 private:
454 
464 
466 
467  bool archiveAsBin; // If true archive binary else archive XML
468  bool fileAsBin ; // If true file binary else file XML
469 
470  std::string version ;
471 
473 
474 
475 
476 
477 
478 
486  SysPowerRow* checkAndAdd(SysPowerRow* x, bool skipCheckUniqueness=false) ;
487 
493  void append(SysPowerRow* x) ;
494 
501 
502 
503 
504 
505 
506 
514  SysPowerRow * insertByStartTime(SysPowerRow* x, std::vector<SysPowerRow* >& row);
515 
516 
517 
518 // A data structure to store the pointers on the table's rows.
519 
520 // In all cases we maintain a private vector of SysPowerRow s.
521  std::vector<SysPowerRow * > privateRows;
522 
523 
524 
525 
526 
527 
528 
529 
530  typedef std::vector <SysPowerRow* > TIME_ROWS;
531  std::map<std::string, TIME_ROWS > context;
532 
537  std::string Key(Tag antennaId, Tag spectralWindowId, int feedId) ;
538 
539 
540 
541 
547  void getByKeyNoAutoIncNoTime(std::vector <SysPowerRow*>& vin, std::vector <SysPowerRow*>& vout, Tag antennaId, Tag spectralWindowId, int feedId);
548 
549 
550 
551  void error() ; //throw(ConversionException);
552 
553 
560  void fromXML(std::string& xmlDoc) ;
561 
562  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
563 
568  void setFromMIMEFile(const std::string& directory);
569  /*
570  void openMIMEFile(const std::string& directory);
571  */
572  void setFromXMLFile(const std::string& directory);
573 
581  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
582 
583 
590  void setFromMIME(const std::string & mimeMsg);
591 
595  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
596 
606  void toFile(std::string directory);
607 
613  if (!presentInMemory && !loadInProgress) {
614  loadInProgress = true;
615  setFromFile(getContainer().getDirectory());
616  presentInMemory = true;
617  loadInProgress = false;
618  }
619  }
628  void setFromFile(const std::string& directory);
629 
630 };
631 
632 } // End namespace asdm
633 
634 #endif /* SysPowerTable_CLASS */
std::string getVersion() const
Return the version information about this table.
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
static const ByteOrder * Machine_Endianity
Definition: Misc.h:119
std::string getName() const
Return the name of this table.
std::map< std::string, TIME_ROWS > context
SysPowerRow * newRow()
====&gt; Row creation.
SysPowerRow * insertByStartTime(SysPowerRow *x, std::vector< SysPowerRow * > &row)
Insert a SysPowerRow* in a vector of SysPowerRow* so that it&#39;s ordered by ascending time...
void getByKeyNoAutoIncNoTime(std::vector< SysPowerRow * > &vin, std::vector< SysPowerRow * > &vout, Tag antennaId, Tag spectralWindowId, int feedId)
Fills the vector vout (passed by reference) with pointers on elements of vin whose attributes are equ...
void append(SysPowerRow *x)
Brutally append an SysPowerRow x to the collection of rows already stored in this table...
struct _xmlDoc xmlDoc
Definition: Misc.h:59
The ArrayTimeInterval class aggregates an instance of ArrayTime and an instance of Interval...
A class to represent byte order information.
Definition: Misc.h:115
void setEntity(Entity e)
Set this table&#39;s Entity.
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.
The SysPowerRow class is a row of a SysPowerTable.
Definition: SysPowerRow.h:109
SysPowerRow * add(SysPowerRow *x)
====&gt; Append a row to its table.
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a SysPowerTable as those produced by the toFil...
The ASDM class is the container for all tables.
Definition: ASDM.h:273
unsigned int size() const
Return the number of rows in the table.
void setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
SysPowerRow * checkAndAdd(SysPowerRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
SysPowerRow * getRowByKey(Tag antennaId, Tag spectralWindowId, int feedId, ArrayTimeInterval timeInterval)
Returns a SysPowerRow* given a key.
void fromIDL(asdmIDL::SysPowerTableIDL x)
Populate this table from the content of a SysPowerTableIDL Corba structure.
std::vector< SysPowerRow * > * getByContext(Tag antennaId, Tag spectralWindowId, int feedId)
Returns all the rows sorted by ascending startTime for a given context.
static std::string name()
Return the name of this table.
Entity getEntity() const
Return this table&#39;s Entity.
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 setFromXMLFile(const std::string &directory)
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...
SysPowerTable(ASDM &container)
Create a SysPowerTable.
bool loadInProgress
Load the table in memory if necessary.
The Tag class is an implementation of a unique index identifying a row of an ASDM table...
Definition: Tag.h:73
void toFile(std::string directory)
Stores a representation (binary or XML) of this table into a file.
static const std::vector< std::string > & getKeyName()
Return the list of field names that make up key key as an array of strings.
The SysPowerTable class is an Alma table.
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
virtual ~SysPowerTable()
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::vector< SysPowerRow * > privateRows
A data structure to store the pointers on the table&#39;s rows.
ASDM & getContainer() const
Return the container to which this table belongs.
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...
static const std::vector< std::string > & defaultAttributesNamesInBin()
Return the default sorted list of attributes names in the binary representation of the table...
std::string Key(Tag antennaId, Tag spectralWindowId, int feedId)
Returns a string built by concatenating the ascii representation of the parameters values suffixed wi...
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 toXML()
Produces an XML representation conform to the schema defined for SysPower (SysPowerTable.xsd).
SysPowerRow * lookup(Tag antennaId, Tag spectralWindowId, int feedId, ArrayTimeInterval timeInterval, int numReceptor)
Look up the table for a row whose all attributes are equal to the corresponding parameters of the met...
std::vector< SysPowerRow * > TIME_ROWS
static const std::vector< std::string > & getAttributesNames()
Return the names of the attributes of this table.
asdmIDL::SysPowerTableIDL * toIDL()
Conversion Methods.
void addWithoutCheckingUnique(SysPowerRow *x)
Brutally append an SysPowerRow x to the collection of rows already stored in this table...
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59