casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FocusTable.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 FocusTable.h
32  */
33 
34 #ifndef FocusTable_CLASS
35 #define FocusTable_CLASS
36 
37 #include <string>
38 #include <vector>
39 #include <map>
40 
41 
42 
43 
45 
46 
47 
48 #include <alma/ASDM/Angle.h>
49 
50 
51 
52 #include <alma/ASDM/Length.h>
53 
54 
55 
56 #include <alma/ASDM/Tag.h>
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
77 #include <alma/ASDM/DuplicateKey.h>
79 #include <alma/ASDM/NoSuchRow.h>
80 #include <alma/ASDM/DuplicateKey.h>
81 
82 
83 #ifndef WITHOUT_ACS
84 #include <asdmIDLC.h>
85 #endif
86 
88 
89 #include <pthread.h>
90 
91 namespace asdm {
92 
93 //class asdm::ASDM;
94 //class asdm::FocusRow;
95 
96 class ASDM;
97 class FocusRow;
185 class FocusTable : public Representable {
186  friend class ASDM;
187 
188 public:
189 
190 
196  static const std::vector<std::string>& getKeyName();
197 
198 
199  virtual ~FocusTable();
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::FocusTableIDL *toIDL() ;
281 
289  void toIDL(asdmIDL::FocusTableIDL& x) const;
290 
291 #endif
292 
293 #ifndef WITHOUT_ACS
294 
300  void fromIDL(asdmIDL::FocusTableIDL x) ;
301 #endif
302 
303  //
304  // ====> Row creation.
305  //
306 
311  FocusRow *newRow();
312 
313 
331  FocusRow *newRow(Tag antennaId, ArrayTimeInterval timeInterval, bool focusTracking, std::vector<Length > focusOffset, std::vector<Angle > focusRotationOffset, int focusModelId);
332 
333 
334 
347  FocusRow *newRow(FocusRow *row);
348 
349  //
350  // ====> Append a row to its table.
351  //
352 
353 
370  FocusRow* add(FocusRow* x) ;
371 
372 
373 
374 
375 
376  //
377  // ====> Methods returning rows.
378  //
379 
385  std::vector<FocusRow *> get() ;
386 
393  const std::vector<FocusRow *>& get() const ;
394 
395 
406  std::vector <FocusRow*> *getByContext(Tag antennaId);
407 
408 
409 
410 
411 
423  FocusRow* getRowByKey(Tag antennaId, ArrayTimeInterval timeInterval);
424 
425 
426 
427 
428 
448  FocusRow* lookup(Tag antennaId, ArrayTimeInterval timeInterval, bool focusTracking, std::vector<Length > focusOffset, std::vector<Angle > focusRotationOffset, int focusModelId);
449 
450 
451  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
452  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
453 
454 private:
455 
465 
467 
468  bool archiveAsBin; // If true archive binary else archive XML
469  bool fileAsBin ; // If true file binary else file XML
470 
471  std::string version ;
472 
474 
475 
476 
477 
478 
479 
487  FocusRow* checkAndAdd(FocusRow* x, bool skipCheckUniqueness=false) ;
488 
494  void append(FocusRow* x) ;
495 
502 
503 
504 
505 
506 
507 
515  FocusRow * insertByStartTime(FocusRow* x, std::vector<FocusRow* >& row);
516 
517 
518 
519 // A data structure to store the pointers on the table's rows.
520 
521 // In all cases we maintain a private vector of FocusRow s.
522  std::vector<FocusRow * > privateRows;
523 
524 
525 
526 
527 
528 
529 
530 
531  typedef std::vector <FocusRow* > TIME_ROWS;
532  std::map<std::string, TIME_ROWS > context;
533 
538  std::string Key(Tag antennaId) ;
539 
540 
541 
542 
548  void getByKeyNoAutoIncNoTime(std::vector <FocusRow*>& vin, std::vector <FocusRow*>& vout, Tag antennaId);
549 
550 
551 
552  void error() ; //throw(ConversionException);
553 
554 
561  void fromXML(std::string& xmlDoc) ;
562 
563  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
564 
569  void setFromMIMEFile(const std::string& directory);
570  /*
571  void openMIMEFile(const std::string& directory);
572  */
573  void setFromXMLFile(const std::string& directory);
574 
582  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
583 
584 
591  void setFromMIME(const std::string & mimeMsg);
592 
596  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
597 
607  void toFile(std::string directory);
608 
614  if (!presentInMemory && !loadInProgress) {
615  loadInProgress = true;
616  setFromFile(getContainer().getDirectory());
617  presentInMemory = true;
618  loadInProgress = false;
619  }
620  }
629  void setFromFile(const std::string& directory);
630 
631 };
632 
633 } // End namespace asdm
634 
635 #endif /* FocusTable_CLASS */
virtual ~FocusTable()
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 > & defaultAttributesNamesInBin()
Return the default sorted list of attributes names in the binary representation of the table...
ASDM & getContainer() const
Return the container to which this table belongs.
static const ByteOrder * Machine_Endianity
Definition: Misc.h:119
std::string toXML()
Produces an XML representation conform to the schema defined for Focus (FocusTable.xsd).
Entity getEntity() const
Return this table&#39;s Entity.
The FocusTable class is an Alma table.
Definition: FocusTable.h:185
struct _xmlDoc xmlDoc
Definition: Misc.h:59
The ArrayTimeInterval class aggregates an instance of ArrayTime and an instance of Interval...
FocusRow * add(FocusRow *x)
====&gt; Append a row to its table.
std::string getName() const
Return the name of this table.
static const std::vector< std::string > & getAttributesNames()
Return the names of the attributes of this table.
A class to represent byte order information.
Definition: Misc.h:115
FocusRow * lookup(Tag antennaId, ArrayTimeInterval timeInterval, bool focusTracking, std::vector< Length > focusOffset, std::vector< Angle > focusRotationOffset, int focusModelId)
Look up the table for a row whose all attributes are equal to the corresponding parameters of the met...
static std::string name()
Return the name of this table.
The ASDM class is the container for all tables.
Definition: ASDM.h:273
The FocusRow class is a row of a FocusTable.
Definition: FocusRow.h:116
std::string getVersion() const
Return the version information about this table.
asdmIDL::FocusTableIDL * toIDL()
Conversion Methods.
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 addWithoutCheckingUnique(FocusRow *x)
Brutally append an FocusRow x to the collection of rows already stored in this table.
void getByKeyNoAutoIncNoTime(std::vector< FocusRow * > &vin, std::vector< FocusRow * > &vout, Tag antennaId)
Fills the vector vout (passed by reference) with pointers on elements of vin whose attributes are equ...
std::string version
Definition: FocusTable.h:471
void setEntity(Entity e)
Set this table&#39;s Entity.
std::map< std::string, TIME_ROWS > context
Definition: FocusTable.h:532
FocusRow * getRowByKey(Tag antennaId, ArrayTimeInterval timeInterval)
Returns a FocusRow* given a key.
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a FocusTable as those produced by the toFile m...
std::vector< FocusRow * > * getByContext(Tag antennaId)
Returns all the rows sorted by ascending startTime for a given context.
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 toFile(std::string directory)
Stores a representation (binary or XML) of this table into a file.
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
Definition: FocusTable.h:563
void setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
void fromIDL(asdmIDL::FocusTableIDL x)
Populate this table from the content of a FocusTableIDL Corba structure.
std::vector< FocusRow * > privateRows
A data structure to store the pointers on the table&#39;s rows.
Definition: FocusTable.h:522
FocusRow * checkAndAdd(FocusRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
unsigned int size() const
Return the number of rows in the 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...
FocusRow * insertByStartTime(FocusRow *x, std::vector< FocusRow * > &row)
Insert a FocusRow* in a vector of FocusRow* so that it&#39;s ordered by ascending time.
FocusTable(ASDM &container)
Create a FocusTable.
The Tag class is an implementation of a unique index identifying a row of an ASDM table...
Definition: Tag.h:73
void setFromXMLFile(const std::string &directory)
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 MIMEXMLPart(const asdm::ByteOrder *byteOrder=asdm::ByteOrder::Machine_Endianity)
Private methods involved during the export of this table into disk file(s).
bool loadInProgress
Load the table in memory if necessary.
Definition: FocusTable.h:612
const Double e
e and functions thereof:
static const std::vector< std::string > & getKeyName()
Return the list of field names that make up key key as an array of strings.
void append(FocusRow *x)
Brutally append an FocusRow x to the collection of rows already stored in this table.
std::vector< FocusRow * > TIME_ROWS
Definition: FocusTable.h:531
std::string Key(Tag antennaId)
Returns a string built by concatenating the ascii representation of the parameters values suffixed wi...
FocusRow * newRow()
====&gt; Row creation.
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59
void checkPresenceInMemory()
Definition: FocusTable.h:613