HistoryTable.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 HistoryTable.h
00032  */
00033  
00034 #ifndef HistoryTable_CLASS
00035 #define HistoryTable_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 <Tag.h>
00051 using  asdm::Tag;
00052 
00053 
00054 
00055 
00056         
00057 
00058         
00059 
00060         
00061 
00062         
00063 
00064         
00065 
00066         
00067 
00068         
00069 
00070         
00071 
00072 
00073 
00074 #include <ConversionException.h>
00075 #include <DuplicateKey.h>
00076 #include <UniquenessViolationException.h>
00077 #include <NoSuchRow.h>
00078 #include <DuplicateKey.h>
00079 using asdm::DuplicateKey;
00080 using asdm::ConversionException;
00081 using asdm::NoSuchRow;
00082 using asdm::DuplicateKey;
00083 
00084 #ifndef WITHOUT_ACS
00085 #include <asdmIDLC.h>
00086 using asdmIDL::HistoryTableIDL;
00087 #endif
00088 
00089 #include <Representable.h>
00090 
00091 namespace asdm {
00092 
00093 //class asdm::ASDM;
00094 //class asdm::HistoryRow;
00095 
00096 class ASDM;
00097 class HistoryRow;
00189 class HistoryTable : public Representable {
00190         friend class ASDM;
00191 
00192 public:
00193 
00194 
00200         static vector<string> getKeyName();
00201 
00202 
00203         virtual ~HistoryTable();
00204         
00210         ASDM &getContainer() const;
00211         
00217         unsigned int size() ;
00218         
00224         string getName() const;
00225         
00231          static const vector<string>& getAttributesNames();
00232 
00236         Entity getEntity() const;
00237 
00242         void setEntity(Entity e);
00243                 
00251         string toXML()  ;
00252 
00253 #ifndef WITHOUT_ACS
00254         // Conversion Methods
00260         HistoryTableIDL *toIDL() ;
00261 #endif
00262 
00263 #ifndef WITHOUT_ACS
00264 
00270         void fromIDL(HistoryTableIDL x) ;
00271 #endif
00272         
00273         //
00274         // ====> Row creation.
00275         //
00276         
00281         HistoryRow *newRow();
00282         
00283         
00307         HistoryRow *newRow(Tag execBlockId, ArrayTime time, string message, string priority, string origin, string objectId, string application, string cliCommand, string appParms);
00308         
00309 
00310 
00323          HistoryRow *newRow(HistoryRow *row); 
00324 
00325         //
00326         // ====> Append a row to its table.
00327         //
00328  
00329         
00346         HistoryRow* add(HistoryRow* x) ; 
00347 
00348  
00349 
00350 
00351 
00352         //
00353         // ====> Methods returning rows.
00354         //
00355                 
00361         vector<HistoryRow *> get() ;
00362         
00363 
00371          vector <HistoryRow*> *getByContext(Tag execBlockId);
00372          
00373 
00374 
00375  
00376         
00388         HistoryRow* getRowByKey(Tag execBlockId, ArrayTime time);
00389 
00390                 
00391 
00392 
00393 
00419         HistoryRow* lookup(Tag execBlockId, ArrayTime time, string message, string priority, string origin, string objectId, string application, string cliCommand, string appParms); 
00420 
00421 
00422 private:
00423 
00432         HistoryTable (ASDM & container);
00433 
00434         ASDM & container;
00435         
00436         bool archiveAsBin; // If true archive binary else archive XML
00437         bool fileAsBin ; // If true file binary else file XML   
00438         
00439         Entity entity;
00440         
00441 
00442 
00446         static string tableName;
00447         
00451         static const vector<string> attributesNames;
00452         
00456         static vector<string> initAttributesNames();
00457 
00458 
00462         static vector<string> key;
00463 
00464 
00472         HistoryRow* checkAndAdd(HistoryRow* x) ;
00473 
00474 
00475         
00476         
00484         HistoryRow * insertByTime(HistoryRow* x, vector<HistoryRow *>&row );
00485          
00486 
00487 
00488 // A data structure to store the pointers on the table's rows.
00489 
00490 // In all cases we maintain a private vector of HistoryRow s.
00491    vector<HistoryRow * > privateRows;
00492    
00493 
00494         
00495 
00496         
00497         
00498                 
00499                                 
00500         typedef vector <HistoryRow* > TIME_ROWS;
00501         map<string, TIME_ROWS > context;
00502                 
00507          string Key(Tag execBlockId) ;
00508                  
00509                 
00510         
00511         
00517         void getByKeyNoAutoIncNoTime(vector <HistoryRow*>& vin, vector <HistoryRow*>& vout,  Tag execBlockId);
00518         
00519 
00520         
00521         void error() ; //throw(ConversionException);
00522 
00523         
00530         void fromXML(string xmlDoc) ;
00531                 
00536         void setFromMIMEFile(const string& directory);
00537         void setFromXMLFile(const string& directory);
00538         
00546         string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00547   
00548         
00555          void setFromMIME(const string & mimeMsg);
00556         
00560         string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00561         
00571           void toFile(string directory);
00572           
00581          void setFromFile(const string& directory);     
00582  
00583 };
00584 
00585 } // End namespace asdm
00586 
00587 #endif /* HistoryTable_CLASS */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines