casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ScaleTable.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 ScaleTable.h
32  */
33 
34 #ifndef ScaleTable_CLASS
35 #define ScaleTable_CLASS
36 
37 #include <string>
38 #include <vector>
39 #include <map>
40 
41 
42 
43 
44 #include <alma/ASDM/Tag.h>
45 
46 
47 
48 
49 
50 
51 
52 
54 
55 
56 
58 
59 
60 
62 
63 
64 
66 
67 
68 
69 
71 #include <alma/ASDM/DuplicateKey.h>
73 #include <alma/ASDM/NoSuchRow.h>
74 #include <alma/ASDM/DuplicateKey.h>
75 
76 
77 #ifndef WITHOUT_ACS
78 #include <asdmIDLC.h>
79 #endif
80 
82 
83 #include <pthread.h>
84 
85 namespace asdm {
86 
87 //class asdm::ASDM;
88 //class asdm::ScaleRow;
89 
90 class ASDM;
91 class ScaleRow;
153 class ScaleTable : public Representable {
154  friend class ASDM;
155 
156 public:
157 
158 
164  static const std::vector<std::string>& getKeyName();
165 
166 
167  virtual ~ScaleTable();
168 
174  ASDM &getContainer() const;
175 
181  unsigned int size() const;
182 
190  std::string getName() const;
191 
199  static std::string name() ;
200 
205  std::string getVersion() const ;
206 
212  static const std::vector<std::string>& getAttributesNames();
213 
219  static const std::vector<std::string>& defaultAttributesNamesInBin();
220 
224  Entity getEntity() const;
225 
230  void setEntity(Entity e);
231 
239  std::string toXML() ;
240 
241 #ifndef WITHOUT_ACS
242  // Conversion Methods
248  asdmIDL::ScaleTableIDL *toIDL() ;
249 
257  void toIDL(asdmIDL::ScaleTableIDL& x) const;
258 
259 #endif
260 
261 #ifndef WITHOUT_ACS
262 
268  void fromIDL(asdmIDL::ScaleTableIDL x) ;
269 #endif
270 
271  //
272  // ====> Row creation.
273  //
274 
279  ScaleRow *newRow();
280 
281 
295  ScaleRow *newRow(TimeScaleMod::TimeScale timeScale, DataScaleMod::DataScale crossDataScale, DataScaleMod::DataScale autoDataScale, WeightTypeMod::WeightType weightType);
296 
297 
298 
312 
313  //
314  // ====> Append a row to its table.
315  //
316 
317 
318 
319 
329  ScaleRow* add(ScaleRow* x) ;
330 
331 
332 
333  //
334  // ====> Methods returning rows.
335  //
336 
342  std::vector<ScaleRow *> get() ;
343 
350  const std::vector<ScaleRow *>& get() const ;
351 
352 
353 
354 
355 
365  ScaleRow* getRowByKey(Tag scaleId);
366 
367 
368 
369 
370 
386  ScaleRow* lookup(TimeScaleMod::TimeScale timeScale, DataScaleMod::DataScale crossDataScale, DataScaleMod::DataScale autoDataScale, WeightTypeMod::WeightType weightType);
387 
388 
389  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
390  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
391 
392 private:
393 
403 
405 
406  bool archiveAsBin; // If true archive binary else archive XML
407  bool fileAsBin ; // If true file binary else file XML
408 
409  std::string version ;
410 
412 
413 
414 
415 
416 
417  // A map for the autoincrementation algorithm
418  std::map<std::string,int> noAutoIncIds;
419  void autoIncrement(std::string key, ScaleRow* x);
420 
421 
431  ScaleRow* checkAndAdd(ScaleRow* x, bool skipCheckUniqueness=false) ;
432 
438  void append(ScaleRow* x) ;
439 
446 
447 
448 
449 
450 
451 // A data structure to store the pointers on the table's rows.
452 
453 // In all cases we maintain a private vector of ScaleRow s.
454  std::vector<ScaleRow * > privateRows;
455 
456 
457 
458  std::vector<ScaleRow *> row;
459 
460 
461  void error() ; //throw(ConversionException);
462 
463 
470  void fromXML(std::string& xmlDoc) ;
471 
472  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
473 
478  void setFromMIMEFile(const std::string& directory);
479  /*
480  void openMIMEFile(const std::string& directory);
481  */
482  void setFromXMLFile(const std::string& directory);
483 
491  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
492 
493 
500  void setFromMIME(const std::string & mimeMsg);
501 
505  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
506 
516  void toFile(std::string directory);
517 
523  if (!presentInMemory && !loadInProgress) {
524  loadInProgress = true;
525  setFromFile(getContainer().getDirectory());
526  presentInMemory = true;
527  loadInProgress = false;
528  }
529  }
538  void setFromFile(const std::string& directory);
539 
540 };
541 
542 } // End namespace asdm
543 
544 #endif /* ScaleTable_CLASS */
void setEntity(Entity e)
Set this table&#39;s Entity.
std::vector< ScaleRow * > row
Definition: ScaleTable.h:458
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
ScaleRow * newRow()
====&gt; Row creation.
static const ByteOrder * Machine_Endianity
Definition: Misc.h:119
ScaleRow * getRowByKey(Tag scaleId)
Returns a ScaleRow* given a key.
void autoIncrement(std::string key, ScaleRow *x)
std::string getVersion() const
Return the version information about this table.
void setFromXMLFile(const std::string &directory)
void fromIDL(asdmIDL::ScaleTableIDL x)
Populate this table from the content of a ScaleTableIDL Corba structure.
virtual ~ScaleTable()
struct _xmlDoc xmlDoc
Definition: Misc.h:59
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
Definition: ScaleTable.h:472
A class to represent byte order information.
Definition: Misc.h:115
The ScaleTable class is an Alma table.
Definition: ScaleTable.h:153
The ScaleRow class is a row of a ScaleTable.
Definition: ScaleRow.h:104
void checkPresenceInMemory()
Definition: ScaleTable.h:522
ScaleRow * checkAndAdd(ScaleRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
The ASDM class is the container for all tables.
Definition: ASDM.h:273
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.
void addWithoutCheckingUnique(ScaleRow *x)
Brutally append an ScaleRow x to the collection of rows already stored in 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.
ScaleRow * add(ScaleRow *x)
====&gt; Append a row to its table.
bool loadInProgress
Load the table in memory if necessary.
Definition: ScaleTable.h:521
std::map< std::string, int > noAutoIncIds
A map for the autoincrementation algorithm.
Definition: ScaleTable.h:418
std::string version
Definition: ScaleTable.h:409
ScaleRow * lookup(TimeScaleMod::TimeScale timeScale, DataScaleMod::DataScale crossDataScale, DataScaleMod::DataScale autoDataScale, WeightTypeMod::WeightType weightType)
Look up the table for a row whose all attributes except the autoincrementable one are equal to the co...
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...
ScaleTable(ASDM &container)
Create a ScaleTable.
static const std::vector< std::string > & getAttributesNames()
Return the names of the attributes of this table.
static const std::vector< std::string > & defaultAttributesNamesInBin()
Return the default sorted list of attributes names in the binary representation of 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 Tag class is an implementation of a unique index identifying a row of an ASDM table...
Definition: Tag.h:73
asdmIDL::ScaleTableIDL * toIDL()
Conversion Methods.
void append(ScaleRow *x)
Brutally append an ScaleRow x to the collection of rows already stored in this table.
void setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
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
unsigned int size() const
Return the number of rows in the table.
std::string MIMEXMLPart(const asdm::ByteOrder *byteOrder=asdm::ByteOrder::Machine_Endianity)
Private methods involved during the export of this table into disk file(s).
const Double e
e and functions thereof:
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.
static std::string name()
Return the name of this table.
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a ScaleTable as those produced by the toFile m...
ASDM & getContainer() const
Return the container to which this table belongs.
std::vector< ScaleRow * > privateRows
A data structure to store the pointers on the table&#39;s rows.
Definition: ScaleTable.h:454
std::string toXML()
Produces an XML representation conform to the schema defined for Scale (ScaleTable.xsd).
Entity getEntity() const
Return this table&#39;s Entity.
std::string getName() const
Return the name of this table.
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59