MainTable.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 MainTable.h
00032  */
00033  
00034 #ifndef MainTable_CLASS
00035 #define MainTable_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 <Interval.h>
00051 using  asdm::Interval;
00052 
00053 #include <Tag.h>
00054 using  asdm::Tag;
00055 
00056 #include <EntityRef.h>
00057 using  asdm::EntityRef;
00058 
00059 
00060 
00061 
00062         
00063 
00064         
00065 
00066         
00067 #include "CTimeSampling.h"
00068 using namespace TimeSamplingMod;
00069         
00070 
00071         
00072 
00073         
00074 
00075         
00076 
00077         
00078 
00079         
00080 
00081         
00082 
00083         
00084 
00085 
00086 
00087 #include <ConversionException.h>
00088 #include <DuplicateKey.h>
00089 #include <UniquenessViolationException.h>
00090 #include <NoSuchRow.h>
00091 #include <DuplicateKey.h>
00092 using asdm::DuplicateKey;
00093 using asdm::ConversionException;
00094 using asdm::NoSuchRow;
00095 using asdm::DuplicateKey;
00096 
00097 #ifndef WITHOUT_ACS
00098 #include <asdmIDLC.h>
00099 using asdmIDL::MainTableIDL;
00100 #endif
00101 
00102 #include <Representable.h>
00103 
00104 namespace asdm {
00105 
00106 //class asdm::ASDM;
00107 //class asdm::MainRow;
00108 
00109 class ASDM;
00110 class MainRow;
00243 class MainTable : public Representable {
00244         friend class ASDM;
00245 
00246 public:
00247 
00248 
00254         static vector<string> getKeyName();
00255 
00256 
00257         virtual ~MainTable();
00258         
00264         ASDM &getContainer() const;
00265         
00271         unsigned int size() ;
00272         
00278         string getName() const;
00279         
00285          static const vector<string>& getAttributesNames();
00286 
00290         Entity getEntity() const;
00291 
00296         void setEntity(Entity e);
00297                 
00305         string toXML()  ;
00306 
00307 #ifndef WITHOUT_ACS
00308         // Conversion Methods
00314         MainTableIDL *toIDL() ;
00315 #endif
00316 
00317 #ifndef WITHOUT_ACS
00318 
00324         void fromIDL(MainTableIDL x) ;
00325 #endif
00326         
00327         //
00328         // ====> Row creation.
00329         //
00330         
00335         MainRow *newRow();
00336         
00337         
00369         MainRow *newRow(ArrayTime time, Tag configDescriptionId, Tag fieldId, int numAntenna, TimeSamplingMod::TimeSampling timeSampling, Interval interval, int numIntegration, int scanNumber, int subscanNumber, int dataSize, EntityRef dataOid, vector<Tag>  stateId, Tag execBlockId);
00370         
00371 
00372 
00385          MainRow *newRow(MainRow *row); 
00386 
00387         //
00388         // ====> Append a row to its table.
00389         //
00390  
00391         
00408         MainRow* add(MainRow* x) ; 
00409 
00410  
00411 
00412 
00413 
00414         //
00415         // ====> Methods returning rows.
00416         //
00417                 
00423         vector<MainRow *> get() ;
00424         
00425 
00433          vector <MainRow*> *getByContext(Tag configDescriptionId, Tag fieldId);
00434          
00435 
00436 
00437  
00438         
00452         MainRow* getRowByKey(ArrayTime time, Tag configDescriptionId, Tag fieldId);
00453 
00454                 
00455 
00456 
00457 
00491         MainRow* lookup(ArrayTime time, Tag configDescriptionId, Tag fieldId, int numAntenna, TimeSamplingMod::TimeSampling timeSampling, Interval interval, int numIntegration, int scanNumber, int subscanNumber, int dataSize, EntityRef dataOid, vector<Tag>  stateId, Tag execBlockId); 
00492 
00493 
00494 private:
00495 
00504         MainTable (ASDM & container);
00505 
00506         ASDM & container;
00507         
00508         bool archiveAsBin; // If true archive binary else archive XML
00509         bool fileAsBin ; // If true file binary else file XML   
00510         
00511         Entity entity;
00512         
00513 
00514 
00518         static string tableName;
00519         
00523         static const vector<string> attributesNames;
00524         
00528         static vector<string> initAttributesNames();
00529 
00530 
00534         static vector<string> key;
00535 
00536 
00544         MainRow* checkAndAdd(MainRow* x) ;
00545 
00546 
00547         
00548         
00556         MainRow * insertByTime(MainRow* x, vector<MainRow *>&row );
00557          
00558 
00559 
00560 // A data structure to store the pointers on the table's rows.
00561 
00562 // In all cases we maintain a private vector of MainRow s.
00563    vector<MainRow * > privateRows;
00564    
00565 
00566         
00567 
00568         
00569         
00570                 
00571                                 
00572         typedef vector <MainRow* > TIME_ROWS;
00573         map<string, TIME_ROWS > context;
00574                 
00579          string Key(Tag configDescriptionId, Tag fieldId) ;
00580                  
00581                 
00582         
00583         
00589         void getByKeyNoAutoIncNoTime(vector <MainRow*>& vin, vector <MainRow*>& vout,  Tag configDescriptionId, Tag fieldId);
00590         
00591 
00592         
00593         void error() ; //throw(ConversionException);
00594 
00595         
00602         void fromXML(string xmlDoc) ;
00603                 
00608         void setFromMIMEFile(const string& directory);
00609         void setFromXMLFile(const string& directory);
00610         
00618         string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00619   
00620         
00627          void setFromMIME(const string & mimeMsg);
00628         
00632         string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00633         
00643           void toFile(string directory);
00644           
00653          void setFromFile(const string& directory);     
00654  
00655 };
00656 
00657 } // End namespace asdm
00658 
00659 #endif /* MainTable_CLASS */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines