casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PulsarTable.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 PulsarTable.h
32  */
33 
34 #ifndef PulsarTable_CLASS
35 #define PulsarTable_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/Frequency.h>
49 
50 
51 
52 #include <alma/ASDM/Tag.h>
53 
54 
55 
56 #include <alma/ASDM/Interval.h>
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
76 
77 
78 
79 
80 
81 
82 
83 
84 
85 
86 
87 
89 #include <alma/ASDM/DuplicateKey.h>
91 #include <alma/ASDM/NoSuchRow.h>
92 #include <alma/ASDM/DuplicateKey.h>
93 
94 
95 #ifndef WITHOUT_ACS
96 #include <asdmIDLC.h>
97 #endif
98 
100 
101 #include <pthread.h>
102 
103 namespace asdm {
104 
105 //class asdm::ASDM;
106 //class asdm::PulsarRow;
107 
108 class ASDM;
109 class PulsarRow;
224 class PulsarTable : public Representable {
225  friend class ASDM;
226 
227 public:
228 
229 
235  static const std::vector<std::string>& getKeyName();
236 
237 
238  virtual ~PulsarTable();
239 
245  ASDM &getContainer() const;
246 
252  unsigned int size() const;
253 
261  std::string getName() const;
262 
270  static std::string name() ;
271 
276  std::string getVersion() const ;
277 
283  static const std::vector<std::string>& getAttributesNames();
284 
290  static const std::vector<std::string>& defaultAttributesNamesInBin();
291 
295  Entity getEntity() const;
296 
301  void setEntity(Entity e);
302 
310  std::string toXML() ;
311 
312 #ifndef WITHOUT_ACS
313  // Conversion Methods
319  asdmIDL::PulsarTableIDL *toIDL() ;
320 
328  void toIDL(asdmIDL::PulsarTableIDL& x) const;
329 
330 #endif
331 
332 #ifndef WITHOUT_ACS
333 
339  void fromIDL(asdmIDL::PulsarTableIDL x) ;
340 #endif
341 
342  //
343  // ====> Row creation.
344  //
345 
350  PulsarRow *newRow();
351 
352 
366  PulsarRow *newRow(ArrayTime refTime, Frequency refPulseFreq, double refPhase, int numBin);
367 
368 
369 
383 
384  //
385  // ====> Append a row to its table.
386  //
387 
388 
389 
390 
400  PulsarRow* add(PulsarRow* x) ;
401 
402 
403 
404  //
405  // ====> Methods returning rows.
406  //
407 
413  std::vector<PulsarRow *> get() ;
414 
421  const std::vector<PulsarRow *>& get() const ;
422 
423 
424 
425 
426 
436  PulsarRow* getRowByKey(Tag pulsarId);
437 
438 
439 
440 
441 
457  PulsarRow* lookup(ArrayTime refTime, Frequency refPulseFreq, double refPhase, int numBin);
458 
459 
460  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
461  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
462 
463 private:
464 
474 
476 
477  bool archiveAsBin; // If true archive binary else archive XML
478  bool fileAsBin ; // If true file binary else file XML
479 
480  std::string version ;
481 
483 
484 
485 
486 
487 
488  // A map for the autoincrementation algorithm
489  std::map<std::string,int> noAutoIncIds;
490  void autoIncrement(std::string key, PulsarRow* x);
491 
492 
502  PulsarRow* checkAndAdd(PulsarRow* x, bool skipCheckUniqueness=false) ;
503 
509  void append(PulsarRow* x) ;
510 
517 
518 
519 
520 
521 
522 // A data structure to store the pointers on the table's rows.
523 
524 // In all cases we maintain a private vector of PulsarRow s.
525  std::vector<PulsarRow * > privateRows;
526 
527 
528 
529  std::vector<PulsarRow *> row;
530 
531 
532  void error() ; //throw(ConversionException);
533 
534 
541  void fromXML(std::string& xmlDoc) ;
542 
543  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
544 
549  void setFromMIMEFile(const std::string& directory);
550  /*
551  void openMIMEFile(const std::string& directory);
552  */
553  void setFromXMLFile(const std::string& directory);
554 
562  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
563 
564 
571  void setFromMIME(const std::string & mimeMsg);
572 
576  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
577 
587  void toFile(std::string directory);
588 
594  if (!presentInMemory && !loadInProgress) {
595  loadInProgress = true;
596  setFromFile(getContainer().getDirectory());
597  presentInMemory = true;
598  loadInProgress = false;
599  }
600  }
609  void setFromFile(const std::string& directory);
610 
611 };
612 
613 } // End namespace asdm
614 
615 #endif /* PulsarTable_CLASS */
PulsarTable(ASDM &container)
Create a PulsarTable.
static const ByteOrder * Machine_Endianity
Definition: Misc.h:119
PulsarRow * lookup(ArrayTime refTime, Frequency refPulseFreq, double refPhase, int numBin)
Look up the table for a row whose all attributes except the autoincrementable one are equal to the co...
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a PulsarTable as those produced by the toFile ...
PulsarRow * getRowByKey(Tag pulsarId)
Returns a PulsarRow* given a key.
void autoIncrement(std::string key, PulsarRow *x)
struct _xmlDoc xmlDoc
Definition: Misc.h:59
A class to represent byte order information.
Definition: Misc.h:115
static const std::vector< std::string > & defaultAttributesNamesInBin()
Return the default sorted list of attributes names in the binary representation of the table...
The ASDM class is the container for all tables.
Definition: ASDM.h:273
std::vector< PulsarRow * > row
Definition: PulsarTable.h:529
unsigned int size() const
Return the number of rows in the table.
PulsarRow * checkAndAdd(PulsarRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
static const std::vector< std::string > & getAttributesNames()
Return the names of the attributes of this table.
void toFile(std::string directory)
Stores a representation (binary or XML) of this table into a file.
void checkPresenceInMemory()
Definition: PulsarTable.h:593
void append(PulsarRow *x)
Brutally append an PulsarRow x to the collection of rows already stored in this table.
std::string getVersion() const
Return the version information about this table.
std::string getName() const
Return the name of this table.
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
The PulsarTable class is an Alma table.
Definition: PulsarTable.h:224
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...
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 toMIME(const asdm::ByteOrder *byteOrder=asdm::ByteOrder::Machine_Endianity)
Serialize this into a stream of bytes and encapsulates that stream into a MIME message.
bool loadInProgress
Load the table in memory if necessary.
Definition: PulsarTable.h:592
std::string toXML()
Produces an XML representation conform to the schema defined for Pulsar (PulsarTable.xsd).
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...
PulsarRow * newRow()
====&gt; Row creation.
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
Definition: PulsarTable.h:543
void fromIDL(asdmIDL::PulsarTableIDL x)
Populate this table from the content of a PulsarTableIDL Corba structure.
static std::string name()
Return the name of this table.
The ArrayTime class implements the concept of a point in time, implemented as an Interval of time sin...
Definition: ArrayTime.h:89
void setFromXMLFile(const std::string &directory)
The PulsarRow class is a row of a PulsarTable.
Definition: PulsarRow.h:122
The Tag class is an implementation of a unique index identifying a row of an ASDM table...
Definition: Tag.h:73
asdmIDL::PulsarTableIDL * toIDL()
Conversion Methods.
std::vector< PulsarRow * > privateRows
A data structure to store the pointers on the table&#39;s rows.
Definition: PulsarTable.h:525
static const std::vector< std::string > & getKeyName()
Return the list of field names that make up key key as an array of strings.
std::string version
Definition: PulsarTable.h:480
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:
void addWithoutCheckingUnique(PulsarRow *x)
Brutally append an PulsarRow x to the collection of rows already stored in this table.
ASDM & getContainer() const
Return the container to which this table belongs.
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 ~PulsarTable()
The Frequency class implements a quantity of frequency in hertz.
Definition: Frequency.h:53
Entity getEntity() const
Return this table&#39;s Entity.
void setEntity(Entity e)
Set this table&#39;s Entity.
std::map< std::string, int > noAutoIncIds
A map for the autoincrementation algorithm.
Definition: PulsarTable.h:489
void setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59
PulsarRow * add(PulsarRow *x)
====&gt; Append a row to its table.