casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SwitchCycleTable.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 SwitchCycleTable.h
32  */
33 
34 #ifndef SwitchCycleTable_CLASS
35 #define SwitchCycleTable_CLASS
36 
37 #include <string>
38 #include <vector>
39 #include <map>
40 
41 
42 
43 
44 #include <alma/ASDM/Angle.h>
45 
46 
47 
48 #include <alma/ASDM/ArrayTime.h>
49 
50 
51 
52 #include <alma/ASDM/Frequency.h>
53 
54 
55 
56 #include <alma/ASDM/Tag.h>
57 
58 
59 
60 #include <alma/ASDM/Interval.h>
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
76 
77 
78 
80 
81 
82 
83 
84 
85 
87 #include <alma/ASDM/DuplicateKey.h>
89 #include <alma/ASDM/NoSuchRow.h>
90 #include <alma/ASDM/DuplicateKey.h>
91 
92 
93 #ifndef WITHOUT_ACS
94 #include <asdmIDLC.h>
95 #endif
96 
98 
99 #include <pthread.h>
100 
101 namespace asdm {
102 
103 //class asdm::ASDM;
104 //class asdm::SwitchCycleRow;
105 
106 class ASDM;
107 class SwitchCycleRow;
194  friend class ASDM;
195 
196 public:
197 
198 
204  static const std::vector<std::string>& getKeyName();
205 
206 
207  virtual ~SwitchCycleTable();
208 
214  ASDM &getContainer() const;
215 
221  unsigned int size() const;
222 
230  std::string getName() const;
231 
239  static std::string name() ;
240 
245  std::string getVersion() const ;
246 
252  static const std::vector<std::string>& getAttributesNames();
253 
259  static const std::vector<std::string>& defaultAttributesNamesInBin();
260 
264  Entity getEntity() const;
265 
270  void setEntity(Entity e);
271 
279  std::string toXML() ;
280 
281 #ifndef WITHOUT_ACS
282  // Conversion Methods
288  asdmIDL::SwitchCycleTableIDL *toIDL() ;
289 
297  void toIDL(asdmIDL::SwitchCycleTableIDL& x) const;
298 
299 #endif
300 
301 #ifndef WITHOUT_ACS
302 
308  void fromIDL(asdmIDL::SwitchCycleTableIDL x) ;
309 #endif
310 
311  //
312  // ====> Row creation.
313  //
314 
320 
321 
337  SwitchCycleRow *newRow(int numStep, std::vector<float > weightArray, std::vector<std::vector<Angle > > dirOffsetArray, std::vector<Frequency > freqOffsetArray, std::vector<Interval > stepDurationArray);
338 
339 
340 
354 
355  //
356  // ====> Append a row to its table.
357  //
358 
359 
360 
361 
372 
373 
374 
375  //
376  // ====> Methods returning rows.
377  //
378 
384  std::vector<SwitchCycleRow *> get() ;
385 
392  const std::vector<SwitchCycleRow *>& get() const ;
393 
394 
395 
396 
397 
407  SwitchCycleRow* getRowByKey(Tag switchCycleId);
408 
409 
410 
411 
412 
430  SwitchCycleRow* lookup(int numStep, std::vector<float > weightArray, std::vector<std::vector<Angle > > dirOffsetArray, std::vector<Frequency > freqOffsetArray, std::vector<Interval > stepDurationArray);
431 
432 
433  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
434  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
435 
436 private:
437 
447 
449 
450  bool archiveAsBin; // If true archive binary else archive XML
451  bool fileAsBin ; // If true file binary else file XML
452 
453  std::string version ;
454 
456 
457 
458 
459 
460 
461  // A map for the autoincrementation algorithm
462  std::map<std::string,int> noAutoIncIds;
463  void autoIncrement(std::string key, SwitchCycleRow* x);
464 
465 
475  SwitchCycleRow* checkAndAdd(SwitchCycleRow* x, bool skipCheckUniqueness=false) ;
476 
482  void append(SwitchCycleRow* x) ;
483 
490 
491 
492 
493 
494 
495 // A data structure to store the pointers on the table's rows.
496 
497 // In all cases we maintain a private vector of SwitchCycleRow s.
498  std::vector<SwitchCycleRow * > privateRows;
499 
500 
501 
502  std::vector<SwitchCycleRow *> row;
503 
504 
505  void error() ; //throw(ConversionException);
506 
507 
514  void fromXML(std::string& xmlDoc) ;
515 
516  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
517 
522  void setFromMIMEFile(const std::string& directory);
523  /*
524  void openMIMEFile(const std::string& directory);
525  */
526  void setFromXMLFile(const std::string& directory);
527 
535  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
536 
537 
544  void setFromMIME(const std::string & mimeMsg);
545 
549  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
550 
560  void toFile(std::string directory);
561 
567  if (!presentInMemory && !loadInProgress) {
568  loadInProgress = true;
569  setFromFile(getContainer().getDirectory());
570  presentInMemory = true;
571  loadInProgress = false;
572  }
573  }
582  void setFromFile(const std::string& directory);
583 
584 };
585 
586 } // End namespace asdm
587 
588 #endif /* SwitchCycleTable_CLASS */
static const ByteOrder * Machine_Endianity
Definition: Misc.h:119
std::vector< SwitchCycleRow * > privateRows
A data structure to store the pointers on the table&#39;s rows.
static std::string name()
Return the name of this table.
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 autoIncrement(std::string key, SwitchCycleRow *x)
std::string getVersion() const
Return the version information about this table.
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a SwitchCycleTable as those produced by the to...
SwitchCycleRow * lookup(int numStep, std::vector< float > weightArray, std::vector< std::vector< Angle > > dirOffsetArray, std::vector< Frequency > freqOffsetArray, std::vector< Interval > stepDurationArray)
Look up the table for a row whose all attributes except the autoincrementable one are equal to the co...
void fromIDL(asdmIDL::SwitchCycleTableIDL x)
Populate this table from the content of a SwitchCycleTableIDL Corba structure.
void setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
std::string MIMEXMLPart(const asdm::ByteOrder *byteOrder=asdm::ByteOrder::Machine_Endianity)
Private methods involved during the export of this table into disk file(s).
struct _xmlDoc xmlDoc
Definition: Misc.h:59
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.
A class to represent byte order information.
Definition: Misc.h:115
asdmIDL::SwitchCycleTableIDL * toIDL()
Conversion Methods.
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...
The ASDM class is the container for all tables.
Definition: ASDM.h:273
std::vector< SwitchCycleRow * > row
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
std::map< std::string, int > noAutoIncIds
A map for the autoincrementation algorithm.
The SwitchCycleRow class is a row of a SwitchCycleTable.
bool loadInProgress
Load the table in memory if necessary.
static const std::vector< std::string > & defaultAttributesNamesInBin()
Return the default sorted list of attributes names in the binary representation of the table...
void setEntity(Entity e)
Set this table&#39;s Entity.
SwitchCycleRow * checkAndAdd(SwitchCycleRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
void toFile(std::string directory)
Stores a representation (binary or XML) of this table into a file.
The SwitchCycleTable class is an Alma table.
ASDM & getContainer() const
Return the container to which this table belongs.
SwitchCycleRow * newRow()
====&gt; Row creation.
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...
The Tag class is an implementation of a unique index identifying a row of an ASDM table...
Definition: Tag.h:73
std::string getName() const
Return the name of this table.
void append(SwitchCycleRow *x)
Brutally append an SwitchCycleRow x to the collection of rows already stored in this table...
SwitchCycleRow * add(SwitchCycleRow *x)
====&gt; Append a row to its table.
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
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 std::vector< std::string > & getAttributesNames()
Return the names of the attributes of this table.
const Double e
e and functions thereof:
Entity getEntity() const
Return this table&#39;s Entity.
std::string toXML()
Produces an XML representation conform to the schema defined for SwitchCycle (SwitchCycleTable.xsd).
void addWithoutCheckingUnique(SwitchCycleRow *x)
Brutally append an SwitchCycleRow x to the collection of rows already stored in this table...
SwitchCycleTable(ASDM &container)
Create a SwitchCycleTable.
SwitchCycleRow * getRowByKey(Tag switchCycleId)
Returns a SwitchCycleRow* given a key.
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59