casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SquareLawDetectorTable.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 SquareLawDetectorTable.h
00032  */
00033  
00034 #ifndef SquareLawDetectorTable_CLASS
00035 #define SquareLawDetectorTable_CLASS
00036 
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 
00041 
00042 
00043         
00044 #include <Tag.h>
00045         
00046 
00047 
00048 
00049 
00050         
00051 
00052         
00053 
00054         
00055 #include "CDetectorBandType.h"
00056         
00057 
00058 
00059 
00060 #include <ConversionException.h>
00061 #include <DuplicateKey.h>
00062 #include <UniquenessViolationException.h>
00063 #include <NoSuchRow.h>
00064 #include <DuplicateKey.h>
00065 
00066 
00067 #ifndef WITHOUT_ACS
00068 #include <asdmIDLC.h>
00069 #endif
00070 
00071 #include <Representable.h>
00072 
00073 #include <pthread.h>
00074 
00075 namespace asdm {
00076 
00077 //class asdm::ASDM;
00078 //class asdm::SquareLawDetectorRow;
00079 
00080 class ASDM;
00081 class SquareLawDetectorRow;
00129 class SquareLawDetectorTable : public Representable {
00130         friend class ASDM;
00131 
00132 public:
00133 
00134 
00140         static const std::vector<std::string>& getKeyName();
00141 
00142 
00143         virtual ~SquareLawDetectorTable();
00144         
00150         ASDM &getContainer() const;
00151         
00157         unsigned int size() const;
00158         
00166         std::string getName() const;
00167         
00175         static std::string name() ;     
00176         
00181          std::string getVersion() const ;
00182         
00188          static const std::vector<std::string>& getAttributesNames();
00189 
00195          static const std::vector<std::string>& defaultAttributesNamesInBin();
00196          
00200         Entity getEntity() const;
00201 
00206         void setEntity(Entity e);
00207                 
00215         std::string toXML()  ;
00216 
00217 #ifndef WITHOUT_ACS
00218         // Conversion Methods
00224         asdmIDL::SquareLawDetectorTableIDL *toIDL() ;
00225         
00233          void toIDL(asdmIDL::SquareLawDetectorTableIDL& x) const;
00234          
00235 #endif
00236 
00237 #ifndef WITHOUT_ACS
00238 
00244         void fromIDL(asdmIDL::SquareLawDetectorTableIDL x) ;
00245 #endif
00246         
00247         //
00248         // ====> Row creation.
00249         //
00250         
00255         SquareLawDetectorRow *newRow();
00256         
00257         
00267         SquareLawDetectorRow *newRow(int numBand, DetectorBandTypeMod::DetectorBandType bandType);
00268         
00269 
00270 
00283          SquareLawDetectorRow *newRow(SquareLawDetectorRow *row); 
00284 
00285         //
00286         // ====> Append a row to its table.
00287         //
00288 
00289         
00290         
00291         
00301          SquareLawDetectorRow* add(SquareLawDetectorRow* x) ;
00302 
00303 
00304 
00305         //
00306         // ====> Methods returning rows.
00307         //
00308                 
00314         std::vector<SquareLawDetectorRow *> get() ;
00315         
00322          const std::vector<SquareLawDetectorRow *>& get() const ;
00323         
00324 
00325 
00326  
00327         
00337         SquareLawDetectorRow* getRowByKey(Tag squareLawDetectorId);
00338 
00339                 
00340 
00341 
00342 
00354         SquareLawDetectorRow* lookup(int numBand, DetectorBandTypeMod::DetectorBandType bandType); 
00355 
00356 
00357         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00358         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00359 
00360 private:
00361 
00370         SquareLawDetectorTable (ASDM & container);
00371 
00372         ASDM & container;
00373         
00374         bool archiveAsBin; // If true archive binary else archive XML
00375         bool fileAsBin ; // If true file binary else file XML   
00376         
00377         std::string version ; 
00378         
00379         Entity entity;
00380         
00381 
00382         // A map for the autoincrementation algorithm
00383         std::map<std::string,int>  noAutoIncIds;
00384         void autoIncrement(std::string key, SquareLawDetectorRow* x);
00385 
00386 
00396         SquareLawDetectorRow* checkAndAdd(SquareLawDetectorRow* x, bool skipCheckUniqueness=false) ;
00397         
00403          void append(SquareLawDetectorRow* x) ;
00404          
00410          void addWithoutCheckingUnique(SquareLawDetectorRow* x) ;
00411          
00412          
00413 
00414 
00415 
00416 // A data structure to store the pointers on the table's rows.
00417 
00418 // In all cases we maintain a private vector of SquareLawDetectorRow s.
00419    std::vector<SquareLawDetectorRow * > privateRows;
00420    
00421 
00422                         
00423         std::vector<SquareLawDetectorRow *> row;
00424 
00425         
00426         void error() ; //throw(ConversionException);
00427 
00428         
00435         void fromXML(std::string& xmlDoc) ;
00436                 
00437         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00438 
00443         void setFromMIMEFile(const std::string& directory);
00444         /*
00445         void openMIMEFile(const std::string& directory);
00446         */
00447         void setFromXMLFile(const std::string& directory);
00448         
00456         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00457   
00458         
00465          void setFromMIME(const std::string & mimeMsg);
00466         
00470         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00471         
00481           void toFile(std::string directory);
00482           
00486           bool loadInProgress;
00487           void checkPresenceInMemory() {
00488                 if (!presentInMemory && !loadInProgress) {
00489                         loadInProgress = true;
00490                         setFromFile(getContainer().getDirectory());
00491                         presentInMemory = true;
00492                         loadInProgress = false;
00493                 }
00494           }
00503          void setFromFile(const std::string& directory);        
00504  
00505 };
00506 
00507 } // End namespace asdm
00508 
00509 #endif /* SquareLawDetectorTable_CLASS */