StateTable.h

Go to the documentation of this file.
00001 
00002 /*
00003  * ALMA - Atacama Large Millimeter Array
00004  * (c) European Southern Observatory, 2002
00005  * (c) Associated Universities Inc., 2002
00006  * Copyright by ESO (in the framework of the ALMA collaboration),
00007  * Copyright by AUI (in the framework of the ALMA collaboration),
00008  * All rights reserved.
00009  * 
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public
00012  * License as published by the Free software Foundation; either
00013  * version 2.1 of the License, or (at your option) any later version.
00014  * 
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY, without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Lesser General Public License for more details.
00019  * 
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this library; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00023  * MA 02111-1307  USA
00024  *
00025  * Warning!
00026  *  -------------------------------------------------------------------- 
00027  * | This is generated code!  Do not modify this file.                  |
00028  * | If you do, all changes will be lost when the file is re-generated. |
00029  *  --------------------------------------------------------------------
00030  *
00031  * File StateTable.h
00032  */
00033  
00034 #ifndef StateTable_CLASS
00035 #define StateTable_CLASS
00036 
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 #include <set>
00041 using std::string;
00042 using std::vector;
00043 using std::map;
00044 
00045 
00046 
00047 #include <Tag.h>
00048 using  asdm::Tag;
00049 
00050 
00051 
00052 
00053         
00054 
00055         
00056 #include "CCalibrationDevice.h"
00057 using namespace CalibrationDeviceMod;
00058         
00059 
00060         
00061 
00062         
00063 
00064         
00065 
00066         
00067 
00068 
00069 
00070 #include <ConversionException.h>
00071 #include <DuplicateKey.h>
00072 #include <UniquenessViolationException.h>
00073 #include <NoSuchRow.h>
00074 #include <DuplicateKey.h>
00075 using asdm::DuplicateKey;
00076 using asdm::ConversionException;
00077 using asdm::NoSuchRow;
00078 using asdm::DuplicateKey;
00079 
00080 #ifndef WITHOUT_ACS
00081 #include <asdmIDLC.h>
00082 using asdmIDL::StateTableIDL;
00083 #endif
00084 
00085 #include <Representable.h>
00086 
00087 namespace asdm {
00088 
00089 //class asdm::ASDM;
00090 //class asdm::StateRow;
00091 
00092 class ASDM;
00093 class StateRow;
00165 class StateTable : public Representable {
00166         friend class ASDM;
00167 
00168 public:
00169 
00170 
00176         static vector<string> getKeyName();
00177 
00178 
00179         virtual ~StateTable();
00180         
00186         ASDM &getContainer() const;
00187         
00193         unsigned int size() ;
00194         
00200         string getName() const;
00201         
00207          static const vector<string>& getAttributesNames();
00208 
00212         Entity getEntity() const;
00213 
00218         void setEntity(Entity e);
00219                 
00227         string toXML()  ;
00228 
00229 #ifndef WITHOUT_ACS
00230         // Conversion Methods
00236         StateTableIDL *toIDL() ;
00237 #endif
00238 
00239 #ifndef WITHOUT_ACS
00240 
00246         void fromIDL(StateTableIDL x) ;
00247 #endif
00248         
00249         //
00250         // ====> Row creation.
00251         //
00252         
00257         StateRow *newRow();
00258         
00259         
00273         StateRow *newRow(CalibrationDeviceMod::CalibrationDevice calDeviceName, bool sig, bool ref, bool onSky);
00274         
00275 
00276 
00289          StateRow *newRow(StateRow *row); 
00290 
00291         //
00292         // ====> Append a row to its table.
00293         //
00294 
00295         
00296         
00297         
00307          StateRow* add(StateRow* x) ;
00308 
00309 
00310 
00311         //
00312         // ====> Methods returning rows.
00313         //
00314                 
00320         vector<StateRow *> get() ;
00321         
00322 
00323 
00324  
00325         
00335         StateRow* getRowByKey(Tag stateId);
00336 
00337                 
00338 
00339 
00340 
00356         StateRow* lookup(CalibrationDeviceMod::CalibrationDevice calDeviceName, bool sig, bool ref, bool onSky); 
00357 
00358 
00359 private:
00360 
00369         StateTable (ASDM & container);
00370 
00371         ASDM & container;
00372         
00373         bool archiveAsBin; // If true archive binary else archive XML
00374         bool fileAsBin ; // If true file binary else file XML   
00375         
00376         Entity entity;
00377         
00378 
00379         // A map for the autoincrementation algorithm
00380         map<string,int>  noAutoIncIds;
00381         void autoIncrement(string key, StateRow* x);
00382 
00383 
00387         static string tableName;
00388         
00392         static const vector<string> attributesNames;
00393         
00397         static vector<string> initAttributesNames();
00398 
00399 
00403         static vector<string> key;
00404 
00405 
00415         StateRow* checkAndAdd(StateRow* x) ;
00416 
00417 
00418 
00419 // A data structure to store the pointers on the table's rows.
00420 
00421 // In all cases we maintain a private vector of StateRow s.
00422    vector<StateRow * > privateRows;
00423    
00424 
00425                         
00426         vector<StateRow *> row;
00427 
00428         
00429         void error() ; //throw(ConversionException);
00430 
00431         
00438         void fromXML(string xmlDoc) ;
00439                 
00444         void setFromMIMEFile(const string& directory);
00445         void setFromXMLFile(const string& directory);
00446         
00454         string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00455   
00456         
00463          void setFromMIME(const string & mimeMsg);
00464         
00468         string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00469         
00479           void toFile(string directory);
00480           
00489          void setFromFile(const string& directory);     
00490  
00491 };
00492 
00493 } // End namespace asdm
00494 
00495 #endif /* StateTable_CLASS */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines