casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ProcessorTable.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 ProcessorTable.h
32  */
33 
34 #ifndef ProcessorTable_CLASS
35 #define ProcessorTable_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 
53 
54 
56 
57 
58 
60 
61 
62 
63 
65 #include <alma/ASDM/DuplicateKey.h>
67 #include <alma/ASDM/NoSuchRow.h>
68 #include <alma/ASDM/DuplicateKey.h>
69 
70 
71 #ifndef WITHOUT_ACS
72 #include <asdmIDLC.h>
73 #endif
74 
76 
77 #include <pthread.h>
78 
79 namespace asdm {
80 
81 //class asdm::ASDM;
82 //class asdm::ProcessorRow;
83 
84 class ASDM;
85 class ProcessorRow;
141  friend class ASDM;
142 
143 public:
144 
145 
151  static const std::vector<std::string>& getKeyName();
152 
153 
154  virtual ~ProcessorTable();
155 
161  ASDM &getContainer() const;
162 
168  unsigned int size() const;
169 
177  std::string getName() const;
178 
186  static std::string name() ;
187 
192  std::string getVersion() const ;
193 
199  static const std::vector<std::string>& getAttributesNames();
200 
206  static const std::vector<std::string>& defaultAttributesNamesInBin();
207 
211  Entity getEntity() const;
212 
217  void setEntity(Entity e);
218 
226  std::string toXML() ;
227 
228 #ifndef WITHOUT_ACS
229  // Conversion Methods
235  asdmIDL::ProcessorTableIDL *toIDL() ;
236 
244  void toIDL(asdmIDL::ProcessorTableIDL& x) const;
245 
246 #endif
247 
248 #ifndef WITHOUT_ACS
249 
255  void fromIDL(asdmIDL::ProcessorTableIDL x) ;
256 #endif
257 
258  //
259  // ====> Row creation.
260  //
261 
266  ProcessorRow *newRow();
267 
268 
280  ProcessorRow *newRow(Tag modeId, ProcessorTypeMod::ProcessorType processorType, ProcessorSubTypeMod::ProcessorSubType processorSubType);
281 
282 
283 
297 
298  //
299  // ====> Append a row to its table.
300  //
301 
302 
303 
304 
315 
316 
317 
318  //
319  // ====> Methods returning rows.
320  //
321 
327  std::vector<ProcessorRow *> get() ;
328 
335  const std::vector<ProcessorRow *>& get() const ;
336 
337 
338 
339 
340 
350  ProcessorRow* getRowByKey(Tag processorId);
351 
352 
353 
354 
355 
369  ProcessorRow* lookup(Tag modeId, ProcessorTypeMod::ProcessorType processorType, ProcessorSubTypeMod::ProcessorSubType processorSubType);
370 
371 
372  void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
373  BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
374 
375 private:
376 
386 
388 
389  bool archiveAsBin; // If true archive binary else archive XML
390  bool fileAsBin ; // If true file binary else file XML
391 
392  std::string version ;
393 
395 
396 
397 
398 
399 
400  // A map for the autoincrementation algorithm
401  std::map<std::string,int> noAutoIncIds;
402  void autoIncrement(std::string key, ProcessorRow* x);
403 
404 
414  ProcessorRow* checkAndAdd(ProcessorRow* x, bool skipCheckUniqueness=false) ;
415 
421  void append(ProcessorRow* x) ;
422 
429 
430 
431 
432 
433 
434 // A data structure to store the pointers on the table's rows.
435 
436 // In all cases we maintain a private vector of ProcessorRow s.
437  std::vector<ProcessorRow * > privateRows;
438 
439 
440 
441  std::vector<ProcessorRow *> row;
442 
443 
444  void error() ; //throw(ConversionException);
445 
446 
453  void fromXML(std::string& xmlDoc) ;
454 
455  std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
456 
461  void setFromMIMEFile(const std::string& directory);
462  /*
463  void openMIMEFile(const std::string& directory);
464  */
465  void setFromXMLFile(const std::string& directory);
466 
474  std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
475 
476 
483  void setFromMIME(const std::string & mimeMsg);
484 
488  std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
489 
499  void toFile(std::string directory);
500 
506  if (!presentInMemory && !loadInProgress) {
507  loadInProgress = true;
508  setFromFile(getContainer().getDirectory());
509  presentInMemory = true;
510  loadInProgress = false;
511  }
512  }
521  void setFromFile(const std::string& directory);
522 
523 };
524 
525 } // End namespace asdm
526 
527 #endif /* ProcessorTable_CLASS */
static const ByteOrder * Machine_Endianity
Definition: Misc.h:119
ProcessorRow * checkAndAdd(ProcessorRow *x, bool skipCheckUniqueness=false)
If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and...
std::vector< ProcessorRow * > 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 toFile(std::string directory)
Stores a representation (binary or XML) of this table into a file.
struct _xmlDoc xmlDoc
Definition: Misc.h:59
virtual ~ProcessorTable()
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
std::vector< ProcessorRow * > row
void append(ProcessorRow *x)
Brutally append an ProcessorRow x to the collection of rows already stored in this table...
std::string getName() const
Return the name of this table.
void fromIDL(asdmIDL::ProcessorTableIDL x)
Populate this table from the content of a ProcessorTableIDL Corba structure.
bool loadInProgress
Load the table in memory if necessary.
The ASDM class is the container for all tables.
Definition: ASDM.h:273
void setEntity(Entity e)
Set this table&#39;s Entity.
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...
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 > & defaultAttributesNamesInBin()
Return the default sorted list of attributes names in the binary representation of the table...
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.
std::string getVersion() const
Return the version information about 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...
ProcessorRow * lookup(Tag modeId, ProcessorTypeMod::ProcessorType processorType, ProcessorSubTypeMod::ProcessorSubType processorSubType)
Look up the table for a row whose all attributes except the autoincrementable one are equal to the co...
ProcessorRow * newRow()
====&gt; Row creation.
void autoIncrement(std::string key, ProcessorRow *x)
The ProcessorTable class is an Alma table.
std::string toXML()
Produces an XML representation conform to the schema defined for Processor (ProcessorTable.xsd).
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...
void setFromFile(const std::string &directory)
Reads and parses a file containing a representation of a ProcessorTable as those produced by the toFi...
void setFromXMLFile(const std::string &directory)
BinaryAttributeReaderFunctor * getUnknownAttributeBinaryReader(const std::string &attributeName) const
asdmIDL::ProcessorTableIDL * toIDL()
Conversion Methods.
static std::string name()
Return the name of this 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).
Entity getEntity() const
Return this table&#39;s Entity.
The Tag class is an implementation of a unique index identifying a row of an ASDM table...
Definition: Tag.h:73
ProcessorRow * add(ProcessorRow *x)
====&gt; Append a row to its table.
ProcessorTable(ASDM &container)
Create a ProcessorTable.
std::map< std::string, BinaryAttributeReaderFunctor * > unknownAttributes2Functors
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:
ProcessorRow * getRowByKey(Tag processorId)
Returns a ProcessorRow* given a key.
unsigned int size() const
Return the number of rows in the table.
void setUnknownAttributeBinaryReader(const std::string &attributeName, BinaryAttributeReaderFunctor *barFctr)
The ProcessorRow class is a row of a ProcessorTable.
Definition: ProcessorRow.h:98
void addWithoutCheckingUnique(ProcessorRow *x)
Brutally append an ProcessorRow x to the collection of rows already stored in this table...
std::map< std::string, int > noAutoIncIds
A map for the autoincrementation algorithm.
The Entity class is an identification of a persistant entity in the ALMA archive. ...
Definition: Entity.h:59