FieldTable.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 FieldTable.h
00032  */
00033  
00034 #ifndef FieldTable_CLASS
00035 #define FieldTable_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 <ArrayTime.h>
00048 using  asdm::ArrayTime;
00049 
00050 #include <Angle.h>
00051 using  asdm::Angle;
00052 
00053 #include <Tag.h>
00054 using  asdm::Tag;
00055 
00056 
00057 
00058 
00059         
00060 
00061         
00062 
00063         
00064 
00065         
00066 
00067         
00068 
00069         
00070 
00071         
00072 
00073         
00074 
00075         
00076 #include "CDirectionReferenceCode.h"
00077 using namespace DirectionReferenceCodeMod;
00078         
00079 
00080         
00081 
00082         
00083 
00084 
00085 
00086 #include <ConversionException.h>
00087 #include <DuplicateKey.h>
00088 #include <UniquenessViolationException.h>
00089 #include <NoSuchRow.h>
00090 #include <DuplicateKey.h>
00091 using asdm::DuplicateKey;
00092 using asdm::ConversionException;
00093 using asdm::NoSuchRow;
00094 using asdm::DuplicateKey;
00095 
00096 #ifndef WITHOUT_ACS
00097 #include <asdmIDLC.h>
00098 using asdmIDL::FieldTableIDL;
00099 #endif
00100 
00101 #include <Representable.h>
00102 
00103 namespace asdm {
00104 
00105 //class asdm::ASDM;
00106 //class asdm::FieldRow;
00107 
00108 class ASDM;
00109 class FieldRow;
00237 class FieldTable : public Representable {
00238         friend class ASDM;
00239 
00240 public:
00241 
00242 
00248         static vector<string> getKeyName();
00249 
00250 
00251         virtual ~FieldTable();
00252         
00258         ASDM &getContainer() const;
00259         
00265         unsigned int size() ;
00266         
00272         string getName() const;
00273         
00279          static const vector<string>& getAttributesNames();
00280 
00284         Entity getEntity() const;
00285 
00290         void setEntity(Entity e);
00291                 
00299         string toXML()  ;
00300 
00301 #ifndef WITHOUT_ACS
00302         // Conversion Methods
00308         FieldTableIDL *toIDL() ;
00309 #endif
00310 
00311 #ifndef WITHOUT_ACS
00312 
00318         void fromIDL(FieldTableIDL x) ;
00319 #endif
00320         
00321         //
00322         // ====> Row creation.
00323         //
00324         
00329         FieldRow *newRow();
00330         
00331         
00349         FieldRow *newRow(string fieldName, string code, int numPoly, vector<vector<Angle > > delayDir, vector<vector<Angle > > phaseDir, vector<vector<Angle > > referenceDir);
00350         
00351 
00352 
00365          FieldRow *newRow(FieldRow *row); 
00366 
00367         //
00368         // ====> Append a row to its table.
00369         //
00370 
00371         
00372         
00373         
00383          FieldRow* add(FieldRow* x) ;
00384 
00385 
00386 
00387         //
00388         // ====> Methods returning rows.
00389         //
00390                 
00396         vector<FieldRow *> get() ;
00397         
00398 
00399 
00400  
00401         
00411         FieldRow* getRowByKey(Tag fieldId);
00412 
00413                 
00414 
00415 
00416 
00436         FieldRow* lookup(string fieldName, string code, int numPoly, vector<vector<Angle > > delayDir, vector<vector<Angle > > phaseDir, vector<vector<Angle > > referenceDir); 
00437 
00438 
00439 private:
00440 
00449         FieldTable (ASDM & container);
00450 
00451         ASDM & container;
00452         
00453         bool archiveAsBin; // If true archive binary else archive XML
00454         bool fileAsBin ; // If true file binary else file XML   
00455         
00456         Entity entity;
00457         
00458 
00459         // A map for the autoincrementation algorithm
00460         map<string,int>  noAutoIncIds;
00461         void autoIncrement(string key, FieldRow* x);
00462 
00463 
00467         static string tableName;
00468         
00472         static const vector<string> attributesNames;
00473         
00477         static vector<string> initAttributesNames();
00478 
00479 
00483         static vector<string> key;
00484 
00485 
00495         FieldRow* checkAndAdd(FieldRow* x) ;
00496 
00497 
00498 
00499 // A data structure to store the pointers on the table's rows.
00500 
00501 // In all cases we maintain a private vector of FieldRow s.
00502    vector<FieldRow * > privateRows;
00503    
00504 
00505                         
00506         vector<FieldRow *> row;
00507 
00508         
00509         void error() ; //throw(ConversionException);
00510 
00511         
00518         void fromXML(string xmlDoc) ;
00519                 
00524         void setFromMIMEFile(const string& directory);
00525         void setFromXMLFile(const string& directory);
00526         
00534         string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00535   
00536         
00543          void setFromMIME(const string & mimeMsg);
00544         
00548         string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00549         
00559           void toFile(string directory);
00560           
00569          void setFromFile(const string& directory);     
00570  
00571 };
00572 
00573 } // End namespace asdm
00574 
00575 #endif /* FieldTable_CLASS */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines