HolographyTable.h
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033  
00034 #ifndef HolographyTable_CLASS
00035 #define HolographyTable_CLASS
00036 
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 
00041 
00042 
00043         
00044 #include <Tag.h>
00045         
00046 
00047         
00048 #include <Length.h>
00049         
00050 
00051 
00052 
00053 
00054         
00055 
00056         
00057 
00058         
00059 
00060         
00061 
00062         
00063 #include "CHolographyChannelType.h"
00064         
00065 
00066 
00067 
00068 #include <ConversionException.h>
00069 #include <DuplicateKey.h>
00070 #include <UniquenessViolationException.h>
00071 #include <NoSuchRow.h>
00072 #include <DuplicateKey.h>
00073 
00074 
00075 #ifndef WITHOUT_ACS
00076 #include <asdmIDLC.h>
00077 #endif
00078 
00079 #include <Representable.h>
00080 
00081 #include <pthread.h>
00082 
00083 namespace asdm {
00084 
00085 
00086 
00087 
00088 class ASDM;
00089 class HolographyRow;
00151 class HolographyTable : public Representable {
00152         friend class ASDM;
00153 
00154 public:
00155 
00156 
00162         static const std::vector<std::string>& getKeyName();
00163 
00164 
00165         virtual ~HolographyTable();
00166         
00172         ASDM &getContainer() const;
00173         
00179         unsigned int size() const;
00180         
00188         std::string getName() const;
00189         
00197         static std::string name() ;     
00198         
00203          std::string getVersion() const ;
00204         
00210          static const std::vector<std::string>& getAttributesNames();
00211 
00217          static const std::vector<std::string>& defaultAttributesNamesInBin();
00218          
00222         Entity getEntity() const;
00223 
00228         void setEntity(Entity e);
00229                 
00237         std::string toXML()  ;
00238 
00239 #ifndef WITHOUT_ACS
00240         
00246         asdmIDL::HolographyTableIDL *toIDL() ;
00247         
00255          void toIDL(asdmIDL::HolographyTableIDL& x) const;
00256          
00257 #endif
00258 
00259 #ifndef WITHOUT_ACS
00260 
00266         void fromIDL(asdmIDL::HolographyTableIDL x) ;
00267 #endif
00268         
00269         
00270         
00271         
00272         
00277         HolographyRow *newRow();
00278         
00279         
00293         HolographyRow *newRow(Length distance, Length focus, int numCorr, vector<HolographyChannelTypeMod::HolographyChannelType > type);
00294         
00295 
00296 
00309          HolographyRow *newRow(HolographyRow *row); 
00310 
00311         
00312         
00313         
00314 
00315         
00316         
00317         
00327          HolographyRow* add(HolographyRow* x) ;
00328 
00329 
00330 
00331         
00332         
00333         
00334                 
00340         std::vector<HolographyRow *> get() ;
00341         
00348          const std::vector<HolographyRow *>& get() const ;
00349         
00350 
00351 
00352  
00353         
00363         HolographyRow* getRowByKey(Tag holographyId);
00364 
00365                 
00366 
00367 
00368 
00384         HolographyRow* lookup(Length distance, Length focus, int numCorr, vector<HolographyChannelTypeMod::HolographyChannelType > type); 
00385 
00386 
00387         void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00388         BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00389 
00390 private:
00391 
00400         HolographyTable (ASDM & container);
00401 
00402         ASDM & container;
00403         
00404         bool archiveAsBin; 
00405         bool fileAsBin ; 
00406         
00407         std::string version ; 
00408         
00409         Entity entity;
00410         
00411 
00412         
00413         std::map<std::string,int>  noAutoIncIds;
00414         void autoIncrement(std::string key, HolographyRow* x);
00415 
00416 
00426         HolographyRow* checkAndAdd(HolographyRow* x, bool skipCheckUniqueness=false) ;
00427         
00433          void append(HolographyRow* x) ;
00434          
00440          void addWithoutCheckingUnique(HolographyRow* x) ;
00441          
00442          
00443 
00444 
00445 
00446 
00447 
00448 
00449    std::vector<HolographyRow * > privateRows;
00450    
00451 
00452                         
00453         std::vector<HolographyRow *> row;
00454 
00455         
00456         void error() ; 
00457 
00458         
00465         void fromXML(std::string& xmlDoc) ;
00466                 
00467         std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00468 
00473         void setFromMIMEFile(const std::string& directory);
00474         
00475 
00476 
00477         void setFromXMLFile(const std::string& directory);
00478         
00486         std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00487   
00488         
00495          void setFromMIME(const std::string & mimeMsg);
00496         
00500         std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00501         
00511           void toFile(std::string directory);
00512           
00516           bool loadInProgress;
00517           void checkPresenceInMemory() {
00518                 if (!presentInMemory && !loadInProgress) {
00519                         loadInProgress = true;
00520                         setFromFile(getContainer().getDirectory());
00521                         presentInMemory = true;
00522                         loadInProgress = false;
00523                 }
00524           }
00533          void setFromFile(const std::string& directory);        
00534  
00535 };
00536 
00537 } 
00538 
00539 #endif