SDMDataObject.h

Go to the documentation of this file.
00001 #ifndef SDMDataObject_CLASS
00002 #define SDMDataObject_CLASS
00003 
00004 #include <string>
00005 #include <set>
00006 #include <vector>
00007 #include <map>
00008 #include <sstream>
00009 
00010 #ifdef WITHOUT_ACS
00011 #else
00012 #include "almaEnumerations_IFC.h"
00013 #endif
00014 
00015 #include "SDMDataObjectPartTypes.h"
00016 
00017 #include "CAtmPhaseCorrection.h"
00018 #include "CAxisName.h"
00019 #include "CBasebandName.h"
00020 #include "CCorrelationMode.h"
00021 #include "CPrimitiveDataType.h"
00022 #include "CSpectralResolutionType.h"
00023 #include "CProcessorType.h"
00024 #include "CCorrelatorType.h"
00025 #include "CStokesParameter.h"
00026 #include "CNetSideband.h"
00027 
00028 using namespace AtmPhaseCorrectionMod;
00029 using namespace AxisNameMod;
00030 using namespace BasebandNameMod;
00031 using namespace CorrelationModeMod;
00032 using namespace PrimitiveDataTypeMod;
00033 using namespace SpectralResolutionTypeMod;
00034 using namespace ProcessorTypeMod;
00035 using namespace CorrelatorTypeMod;
00036 using namespace StokesParameterMod;
00037 using namespace NetSidebandMod;
00038 
00039 using namespace std;
00040 
00041 
00042 
00043 #ifdef REG_BASIC
00044 #undef REG_BASIC
00045 #endif
00046 
00047 #ifdef REG_EXTENDED 
00048 #undef REG_EXTENDED
00049 #endif 
00050 
00051 #ifdef REG_ICASE
00052 #undef REG_ICASE
00053 #endif
00054 
00055 #ifdef REG_NOSUB
00056 #undef REG_NOSUB
00057 #endif
00058 
00059 #ifdef REG_NEWLINE
00060 #undef REG_NEWLINE
00061 #endif
00062 
00063 #ifdef REG_NOTBOL
00064 #undef REG_NOTBOL
00065 #endif
00066 
00067 #ifdef REG_NOTEOL
00068 #undef REG_NOTEOL
00069 #endif
00070 
00071 #ifdef REG_STARTEND
00072 #undef REG_STARTEND
00073 #endif
00074 
00075 #ifdef REG_NOERROR
00076 #undef REG_NOERROR
00077 #endif
00078 
00079 #ifdef REG_NOMATCH
00080 #undef REG_NOMATCH
00081 #endif
00082 
00083 #ifdef REG_BADPAT
00084 #undef REG_BADPAT
00085 #endif
00086 
00087 #ifdef REG_ECOLLATE
00088 #undef REG_ECOLLATE
00089 #endif
00090 
00091 #include <boost/regex.hpp> 
00092 using namespace boost;
00093 
00094 #if defined(__APPLE__)
00095 #include <machine/endian.h>
00096 #else 
00097 #include <endian.h>
00098 #endif
00099 
00100 /*
00101 #include <boost/date_time/posix_time/posix_time.hpp>
00102 #include <boost/date_time/posix_time/posix_time_duration.hpp>
00103 
00104 #include <boost/date_time/gregorian/gregorian.hpp>
00105 
00106 using namespace boost::posix_time;
00107 using namespace boost::gregorian;
00108 */
00109 
00135 namespace asdmbinaries {
00136 
00140   const int SCHEMAVERSION=2;
00141 
00142 
00146   class SDMDataObjectException {
00147     
00148   public:
00152     SDMDataObjectException();
00153 
00158     SDMDataObjectException(const string& m);
00159     
00163     virtual ~SDMDataObjectException();
00164 
00169     string getMessage() const;
00170     
00171   protected:
00172     string message;
00173     
00174   };
00175 
00176   inline SDMDataObjectException::SDMDataObjectException() : message ("SDMDataObjectReaderException") {}
00177   inline SDMDataObjectException::SDMDataObjectException(const string& m) : message(m) {}
00178   inline SDMDataObjectException::~SDMDataObjectException() {}
00179   inline string SDMDataObjectException::getMessage() const {
00180     return "SDMDataObjectException : " + message;
00181   }
00182   
00192   template<class Enum, class EnumHelper> 
00193     class Optional {
00194     private:
00195     bool present_;
00196     Enum literal_;
00197     
00198     public:
00204     Optional() {
00205       present_=false;
00206     }
00207     
00215     Optional(Enum literal) {
00216       literal_ = literal;
00217       present_ = true;
00218     }
00219     
00225     bool present() const { return present_; }
00226 
00235     Enum literal() const { return literal_; }
00236   };
00237 
00243   typedef Optional<SpectralResolutionType, CSpectralResolutionType> OptionalSpectralResolutionType;
00244 
00245 
00250   class ByteOrder {
00251   public:
00252     static const ByteOrder* Little_Endian; /*< A unique object to represent a little endian byte order. */
00253     static const ByteOrder* Big_Endian;    /*< A unique object to represent a big endian byte order. */
00254     static const ByteOrder* Machine_Endianity; /*< A unique object storing the endianity of the machine. */
00255 
00264     string toString() const ;
00265 
00266   private:
00267     string name_;
00268     int endianity_;
00269 
00270     ByteOrder(const string & name, int endianity);
00271     virtual ~ByteOrder();
00272     static const ByteOrder* machineEndianity(); 
00273   };
00274 
00275   // forward declarations.
00276   class SDMDataSubset;
00277   class SDMDataObject;
00278 
00279 
00280   
00281   class SDMDataObjectReader;
00282 
00283   // SDMDataObject:: declarations
00284   //
00285 
00346   class SDMDataObject {
00347     friend class SDMDataObjectStreamReader;
00348     friend class SDMDataObjectReader;
00349     friend class SDMDataObjectWriter;
00350     friend class HeaderParser;
00351     friend class SDMDataSubset;
00352     friend class CorrSubsetHeaderParser;
00353 
00354   public:
00355 
00356     // SDMDataObject::SpectralWindow:: declarations
00357     //
00370     class SpectralWindow {
00371       friend class SDMDataObject;
00372       friend class DataStruct;
00373       friend class Baseband;
00374       friend class HeaderParser;
00375 
00376     private:
00377       vector<StokesParameter> crossPolProducts_;
00378       vector<StokesParameter> sdPolProducts_;
00379       float scaleFactor_;
00380       unsigned int numSpectralPoint_;
00381       unsigned int numBin_;
00382       NetSideband sideband_;
00383       string strSw_;
00384       string strImage_;
00385       void strSw(const string& s);
00386       const string & strSw() const;
00387       void strImage(const string& s);
00388       const string & strImage() const;
00389 
00390       const SDMDataObject* owner_;
00391 
00392       void owner(const SDMDataObject* o);
00393 
00394     public:
00400       SpectralWindow();
00401 
00402 
00406       virtual ~SpectralWindow();
00407 
00411       SpectralWindow(const vector<StokesParameter>& crossPolProducts,
00412                      float scaleFactor,
00413                      unsigned int numSpectralPoint,
00414                      unsigned int numBin,
00415                      NetSideband sideband);
00416 
00420       SpectralWindow(const vector<StokesParameter>& sdPolProducts,
00421                      unsigned int numSpectralPoint,
00422                      unsigned numBin,
00423                      NetSideband sideband);
00424 
00428       SpectralWindow(const vector<StokesParameter>& crossPolProducts,
00429                      const vector<StokesParameter>& sdPolProduct,
00430                      float scaleFactor,
00431                      unsigned int numSpectralPoint,
00432                      unsigned int numBin,
00433                      NetSideband sideband);
00434 
00441       const vector<StokesParameter>& crossPolProducts() const;
00442       //void crossPolProducts(const vector<StokesParameter>& value);
00443 
00450       const vector<StokesParameter>& sdPolProducts() const;
00451       //void sdPolProducts(const vector<StokesParameter>& value);
00452 
00460       float scaleFactor() const;
00461       //void scaleFactor(float value);
00462 
00467       unsigned int numSpectralPoint() const;
00468       //void numSpectralPoint(unsigned int value);
00469 
00476       unsigned int numBin() const;
00477       //void numBin(unsigned int value);
00478 
00484       NetSidebandMod::NetSideband sideband() const;
00485 
00486     }; // SpectralWindow::
00487 
00488 
00489     // SDMDataObject::Baseband:: declarations
00490     //
00501     class Baseband {
00502       friend class SDMDataObject;
00503       friend class DataStruct;
00504       friend class HeaderParser;
00505 
00506     private:
00507       BasebandName name_;
00508       vector<SpectralWindow> spectralWindows_;
00509 
00510       const SDMDataObject* owner_;
00511 
00512       void owner(const SDMDataObject* o);
00513 
00514     public:
00520       Baseband();
00521 
00525       ~Baseband();
00526 
00530       Baseband(BasebandName name, const vector<SpectralWindow>& spectralWindows);
00531 
00536       BasebandName name() const;
00537       //void ref(BasebandName value);
00538 
00543       const vector<SpectralWindow>& spectralWindows() const;
00544       void spectralWindows(const vector<SpectralWindow>& value);
00545     }; // Baseband::
00546 
00547 
00548     // SDMDataObject::BinaryPart:: declarations
00549     //
00567     class BinaryPart {
00568       friend class DataStruct;
00569       friend class SDMDataObject;
00570       friend class HeaderParser;
00571       friend class SDMDataObjectWriter;
00572 
00573     protected:
00574       unsigned int size_;
00575       vector<AxisName> axes_;
00576 
00577       const SDMDataObject* owner_;
00578     
00579       void owner(const SDMDataObject* o);
00580     public:
00581 
00585       BinaryPart();
00586 
00590       virtual ~BinaryPart();
00591 
00595       BinaryPart( unsigned int size,
00596                   const vector<AxisName>& axes);
00597       
00602       virtual unsigned int size() const; 
00603       //      virtual void size (unsigned int value); 
00604       
00611       virtual const vector<AxisName>& axes() const ; 
00612       //      virtual void axes (const vector<AxisName>& axes); 
00613     }; // BinaryPart::
00614 
00622     class AutoDataBinaryPart : public BinaryPart {
00623       friend class DataStruct;
00624       friend class SDMDataObject;
00625       friend class HeaderParser;
00626       friend class SDMDataObjectWriter;
00627       
00628     protected:
00629       bool normalized_;
00630 
00631     public:
00635       AutoDataBinaryPart();
00636       
00640       ~AutoDataBinaryPart();
00641       
00645       AutoDataBinaryPart(unsigned int size,
00646                          const vector<AxisName>& axes,
00647                          bool normalized);
00648       
00653       virtual bool normalized() const;
00654       
00655     }; // AutoDataBinaryPart
00656     
00664     class ZeroLagsBinaryPart : public BinaryPart {
00665       friend class DataStruct;
00666       friend class SDMDataObject;
00667       friend class HeaderParser;
00668       friend class SDMDataObjectWriter;
00669 
00670     protected:
00671       CorrelatorType correlatorType_;
00672       
00673     public:
00674       
00678       ZeroLagsBinaryPart() ;
00679 
00683       ~ZeroLagsBinaryPart();
00684 
00688       ZeroLagsBinaryPart(unsigned int size,
00689                          const vector<AxisName>& axes,
00690                          CorrelatorType correlatorType);
00691 
00696       virtual CorrelatorType correlatorType() const;
00697     };
00698 
00699     // SDMDataObject::DataStruct:: declarations
00700     //
00710     class DataStruct {
00711       friend class SDMDataObject;
00712       friend class HeaderParser;
00713       friend class SDMDataObjectWriter;
00714 
00715     public:
00721       DataStruct();
00722 
00726       virtual ~DataStruct();
00727 
00747       DataStruct(const vector<AtmPhaseCorrection>& apc,
00748                  const vector<Baseband>& basebands,
00749                  const BinaryPart& flags,
00750                  const BinaryPart& actualTimes,
00751                  const BinaryPart& actualDurations,
00752                  const ZeroLagsBinaryPart& zeroLags,
00753                  const BinaryPart& crossData,
00754                  const AutoDataBinaryPart& autoData);
00755       
00756       
00761       const vector<AtmPhaseCorrection>& apc() const;
00762       //      void apc(const vector<AtmPhaseCorrection>& value);
00763 
00768       const vector<Baseband>& basebands() const;
00769       //      void basebands(const vector<Baseband>& value);
00770       
00775       const BinaryPart& flags() const;
00776       //      void flags(const BinaryPart& value);
00777 
00782       const BinaryPart& actualTimes() const;
00783       //      void actualTimes(const BinaryPart& value);
00784  
00785 
00790       const BinaryPart& actualDurations() const;
00791       //      void actualDurations(const BinaryPart& value);
00792 
00793 
00798       const ZeroLagsBinaryPart& zeroLags() const;
00799       //      void zeroLags(const BinaryPart& value);
00800 
00801 
00806       const BinaryPart& crossData() const;
00807       //      void crossData(const BinaryPart& value);
00808 
00809 
00814       const AutoDataBinaryPart& autoData() const;
00815       //      void autoData(const BinaryPart& value);
00816 
00829       void imageSPW(unsigned int ibb,
00830                     unsigned int ispw1,
00831                     unsigned int ispw2);
00832 
00844       const SpectralWindow* imageSPW(unsigned int ibb,
00845                                      unsigned int ispw) const;
00846 
00859       void imageOfSPW(unsigned int ibb,
00860                       unsigned int ispw1,
00861                       unsigned int ispw2);
00862       
00863 
00875       const SpectralWindow* imageOfSPW(unsigned int ibb,
00876                                        unsigned int ispw) const;
00877       
00878 
00879     private:
00880       vector<AtmPhaseCorrection> apc_;
00881       vector<Baseband> basebands_;
00882       BinaryPart flags_;
00883       BinaryPart actualTimes_;
00884       BinaryPart actualDurations_;
00885       ZeroLagsBinaryPart zeroLags_;
00886       BinaryPart crossData_;
00887       AutoDataBinaryPart autoData_;
00888 
00889       const SDMDataObject* owner_;
00890       void owner(const SDMDataObject* o);
00891 
00892       map<string, string> imageSPW_;
00893       map<string, string> imageOfSPW_;
00894 
00895       void checkCoordinate(unsigned int ibb, unsigned int ispw) const;
00896       bool associatedSPW(unsigned int ibb,
00897                          unsigned int ispw1,
00898                          unsigned int ispw2);
00899 
00900       void divorceSPW(unsigned int ibb, unsigned int ispw)   ;
00901 
00902     }; //DataStruct::
00903 
00904     SDMDataObject();
00905     SDMDataObject(unsigned long long startTime,
00906                   const string& dataOID,
00907                   unsigned int dimensionality,
00908                   const string& execBlockUID,
00909                   unsigned int execBlockNum,
00910                   unsigned int scanNum,
00911                   unsigned int subscanNum,
00912                   unsigned int numAntenna,
00913                   CorrelationMode correlatorMode,
00914                   const SDMDataObject::DataStruct& dataStruct);
00915 
00916     SDMDataObject(unsigned long long startTime,
00917                   const string& dataOID,
00918                   unsigned int dimensionality,
00919                   unsigned int numTime,
00920                   const string& execBlockUID,
00921                   unsigned int execBlockNum,
00922                   unsigned int scanNum,
00923                   unsigned int subscanNum,
00924                   unsigned int numAntenna,
00925                   const SDMDataObject::DataStruct& dataStruct);
00926 
00931     string title() const;
00932     void title(const string& value) ;
00933 
00938     const ByteOrder* byteOrder() const;
00939 
00944     unsigned long long startTime() const;
00945     void startTime(unsigned long long value);    
00946 
00952     unsigned int numTime() const;
00953     void numTime(unsigned int value);
00954 
00959     string dataOID() const;
00960     void dataOID(const string& value);
00961 
00962 
00967     string execBlockUID() const;
00968     void execBlockUID(const string& value);
00969 
00974     unsigned int execBlockNum() const;
00975     void execBlockNum (unsigned int value );
00976 
00981     unsigned int scanNum() const;
00982     void scanNum( unsigned int value);
00983 
00988     unsigned int subscanNum() const;
00989     void subscanNum(int value);
00990 
00995     string projectPath() const;
00996 
01002     vector<string> projectPaths() const;
01003 
01008     unsigned int numAntenna() const;
01009     void numAntenna (unsigned int value);
01010 
01015     CorrelationMode correlationMode() const;
01016 
01017 
01026     OptionalSpectralResolutionType spectralResolutionType() const;
01027 
01032     ProcessorType processorType() const;
01033 
01034 
01041     CorrelatorType correlatorType() const;
01042 
01049     bool isTP() const ;
01050 
01057     bool isWVR() const ;
01058 
01065     bool isCorrelation() const;
01066 
01072     bool hasPackedData() const;
01073        
01078     const DataStruct& dataStruct() const;
01079     void dataStruct(const DataStruct& dataStruct);
01080 
01081 
01091     const vector<SDMDataSubset>& sdmDataSubsets() const;
01092 
01098     const vector<SDMDataSubset>& corrDataSubsets() const;
01099     void corrDataSubsets(const vector<SDMDataSubset>& value);
01100 
01109     const SDMDataSubset& sdmDataSubset(const string& projectPath) const;
01110 
01111 
01120     bool aborted() const ;
01121 
01132     unsigned long long abortTime() const ;
01133 
01134 
01135 
01146     string abortReason() const ;
01147 
01148 
01154     const SDMDataSubset& tpDataSubset() const;
01155     void tpDataSubset(const SDMDataSubset& value);
01156 
01161     string toString() const;
01162 
01167     void done();
01168 
01175     unsigned int dimensionality() const;
01176 
01177   private:
01178 
01179     static vector<string> correlationModeRefs;
01180     static vector<string> axes;
01181     static vector<string> types;
01182     static vector<string> apcs;
01183 
01184     const static bool _init;
01185     static bool init();
01186 
01187     // Is the SDMDataObject actually properly filled with valid data.
01188     bool valid_; 
01189 
01190     // Global header variables.
01191     string title_;
01192 
01193     const ByteOrder* byteOrder_;
01194 
01195     int schemaVersion_;
01196     
01197     long long startTime_;
01198 
01199     string dataOID_;
01200 
01201     unsigned int dimensionality_;
01202 
01203     unsigned int numTime_;
01204 
01205     string execBlockUID_;
01206 
01207     unsigned int execBlockNum_;
01208 
01209     unsigned int scanNum_;
01210 
01211     unsigned int subscanNum_;
01212 
01213     unsigned int numAntenna_;
01214 
01215     CorrelationMode correlationMode_;
01216 
01217     OptionalSpectralResolutionType spectralResolutionType_;
01218 
01219     ProcessorType processorType_;
01220 
01221     DataStruct dataStruct_;
01222 
01223     map<string, unsigned int> str2index_;
01224     
01225     vector<SDMDataSubset> dataSubsets_;
01226 
01227     bool aborted_;
01228 
01229     unsigned long long int abortTime_;
01230     string   abortReason_;
01231 
01232     void append(const SDMDataSubset& value);
01233 
01234 
01243     void dimensionality( unsigned int value );
01244 
01251     bool inTitle(const std::string& what) const;
01252 
01256     void owns();
01257 
01258  
01263     string toXML() ;
01264     void toXML(const BinaryPart& binaryPart, const string& elementName,  ostringstream& oss) const;
01265     void toXML(const AutoDataBinaryPart& autoDataBinaryPart, const string& elementName,  ostringstream& oss) const;
01266     void toXML(const ZeroLagsBinaryPart& zeroLagsBinaryPart, const string& elementName,  ostringstream& oss) const;
01267     void spectralWindowsToXML(const vector<Baseband>& basebands, unsigned int ibb,  ostringstream& oss) const;
01268     void basebandsToXML(ostringstream& oss) const; 
01269     void dataStructToXML(ostringstream& oss) ;
01270 
01271     void updateIdImageSPW();
01272 
01273     const static regex  SPWID;
01274 
01275   };
01276   // SDMDataObject::
01277 
01278   // SDMDataSubset:: declarations
01279   //
01287   class SDMDataSubset {
01288     friend class SDMDataObject;
01289     friend class SDMDataObjectReader;
01290     friend class SDMDataObjectStreamReader;
01291     friend class SDMDataObjectWriter;
01292     friend class CorrSubsetHeaderParser;
01293     friend class TPSubsetHeaderParser;
01294 
01295   public:
01296   
01297     /*
01298      * An empty constructor.
01299      */
01300     SDMDataSubset(SDMDataObject* owner= 0);
01301 
01302     SDMDataSubset(SDMDataObject* owner,
01303                   unsigned long long time,
01304                   unsigned long long interval,
01305                   const vector<float>& autoData);
01306 
01307     /*
01308      * A copy constructor.
01309      */
01310     SDMDataSubset(const SDMDataSubset & sdmDataSubset);
01311 
01312     /*
01313      * Overloading = 
01314      */
01315     SDMDataSubset& operator= (const SDMDataSubset& sdmDataSubset);
01316 
01317     /*
01318      * The destructor.
01319      */
01320     virtual ~SDMDataSubset();
01321 
01322     const SDMDataObject* owner() const;
01323 
01324     unsigned int integrationNum() const;
01325     
01326     unsigned int subintegrationNum() const;    
01327 
01336     string projectPath() const;
01337   
01345     unsigned long long time() const;
01346   
01351     unsigned long long interval() const;
01352 
01353 
01358     string toString(unsigned int N = 10 )const ;
01359 
01360     void binAttachToXML(const string& name, ostringstream& oss);
01361     void tpBinAttachToXML(ostringstream& oss);
01362     void corrBinAttachToXML(ostringstream& oss);
01363 
01364     void toXML(ostringstream& oss) const;
01365 
01370     string toXML();
01371 
01372 
01380     unsigned long int actualDurations(const ACTUALDURATIONSTYPE* & ptr) const;
01381 
01388     uint64_t actualDurationsPosition() const;
01389 
01397     unsigned long int actualTimes(const ACTUALTIMESTYPE* & ptr) const;
01398 
01405     uint64_t actualTimesPosition() const;
01406 
01414     unsigned long int autoData(const AUTODATATYPE* & ptr) const ;
01415 
01422     uint64_t autoDataPosition() const;
01423 
01431     unsigned long int crossData(const SHORTCROSSDATATYPE* & ptr) const;
01432 
01433 
01441     unsigned long int crossData(const INTCROSSDATATYPE* & ptr) const;
01442 
01450     unsigned long int crossData(const FLOATCROSSDATATYPE* & ptr) const;
01451 
01458     uint64_t crossDataPosition() const;
01459 
01465     PrimitiveDataType crossDataType() const;
01466 
01467     void crossDataType(PrimitiveDataType value);
01468 
01476     unsigned long int flags(const FLAGSTYPE* &ptr) const;
01477 
01484     uint64_t flagsPosition() const;
01485 
01493     unsigned long int zeroLags(const ZEROLAGSTYPE* & ptr) const;
01494 
01501     uint64_t zeroLagsPosition() const;
01502 
01507     bool aborted() const ; 
01508 
01514     unsigned long long abortTime() const; 
01515 
01521     string abortReason() const;
01522 
01523 
01524 
01525   private:
01526     SDMDataObject* owner_;
01527     unsigned int integrationNum_;
01528     unsigned int subintegrationNum_;
01529     CorrelationMode ref_;
01530     unsigned long long time_;
01531     unsigned long long interval_;
01532     string dataStruct_;
01533     string flagsREF_;
01534     string actualTimesREF_;
01535     string actualDurationsREF_;
01536     string zeroLagsREF_;
01537     string crossDataREF_;
01538     PrimitiveDataType crossDataType_;
01539     string autoDataREF_;
01540 
01541     const ACTUALTIMESTYPE * actualTimes_;
01542     unsigned long int nActualTimes_;
01543     uint64_t actualTimesPosition_;
01544     const ACTUALDURATIONSTYPE * actualDurations_;
01545     unsigned long int nActualDurations_;
01546     uint64_t actualDurationsPosition_;
01547     const ZEROLAGSTYPE* zeroLags_;
01548     unsigned long int nZeroLags_;
01549     uint64_t zeroLagsPosition_;
01550     const FLAGSTYPE* flags_;    
01551     unsigned long int nFlags_;
01552     uint64_t flagsPosition_;
01553     const INTCROSSDATATYPE* longCrossData_;
01554     const SHORTCROSSDATATYPE* shortCrossData_;
01555     const FLOATCROSSDATATYPE* floatCrossData_;
01556     unsigned long int nCrossData_;
01557     uint64_t crossDataPosition_;
01558     const AUTODATATYPE* autoData_;
01559     unsigned long int nAutoData_;
01560     uint64_t autoDataPosition_;
01561 
01562     string xsiType() const;
01563 
01564     bool aborted_;
01565     unsigned long long int abortTime_;
01566     string   abortReason_;
01567 
01568   };
01569   // SDMDataSubset:: declarations
01570 
01571 
01572   // Utils:: declarations
01573   //
01574   class Utils {
01575   public:
01576     static void invalidCall(const string & methodName, const SDMDataObject* sdmDataObject);
01577     static string quote(const string& s);
01578     static string quote(bool b);
01579     static string quote(int i);
01580     static string quote(unsigned int i);
01581     static string quote(long long l);
01582     static string quote(float f);
01583     static string quote(const set<string>& s);
01584     static string quote(const vector<string>& s);
01585     template<class Enum, class EnumHelper> static string quote(Enum l) {
01586       ostringstream oss;
01587       oss << "\"";
01588       oss << EnumHelper::name(l);
01589       oss << "\"";
01590       return oss.str();
01591     }
01592 
01593     template<class Enum, class EnumHelper> static string quote(const vector<Enum>& v_l) {
01594       ostringstream oss;
01595       oss << "\"";
01596 
01597       if (v_l.size() > 0)
01598         oss << EnumHelper::name(v_l.at(0));
01599 
01600       for (unsigned int i = 1; i < v_l.size(); i++)
01601         oss << " " << EnumHelper::name(v_l.at(i));
01602       oss << "\"";
01603       return oss.str();
01604     }
01605 
01606     template<class Enum, class EnumHelper> static string toString(Enum l) {
01607       ostringstream oss;
01608       oss << EnumHelper::name(l);
01609       return oss.str();
01610     }
01611 
01612     template<class Enum, class EnumHelper> static string toString(const vector<Enum>& v_l) {
01613       ostringstream oss;
01614 
01615       if (v_l.size() > 0)
01616         oss << EnumHelper::name(v_l.at(0));
01617 
01618       for (unsigned int i = 1; i < v_l.size(); i++)
01619         oss << " " << EnumHelper::name(v_l.at(i));
01620       return oss.str();
01621     }
01622 
01626     template<class Enum, class EnumHelper> static vector<Enum> enumvec(const string& strliterals) {
01627       vector<Enum> result;
01628       
01629       string strliteral;
01630       istringstream iss(strliterals);
01631       
01632       while (iss >> strliteral)
01633         result.push_back(EnumHelper::literal(strliteral));
01634       
01635       return result;
01636     }
01637 
01638 
01639     static void toXML(const string& elementName, int value, ostringstream& oss);
01640     static void toXML(const string& elementName, unsigned int value, ostringstream& oss);
01641     static void toXML(const string& elementName, long long value, ostringstream& oss);
01642     static void toXML(const string& elementName, unsigned long long value, ostringstream& oss);
01643     static void oXML(const string& elementName, ostringstream& oss);
01644     static void cXML(const string& elementName, ostringstream& oss);
01645     
01654     template<class Enum, class EnumHelper> static void toXML(const string& elementName, Enum value, ostringstream& oss) {
01655       oss << "<" << elementName << ">" << EnumHelper::name(value) << "</" << elementName << ">" << endl;      
01656     }
01657 
01658 #define QUOTE    Utils::quote
01659 #define TOSTRING Utils::toString
01660 #define TOXML    Utils::toXML
01661 #define OXML     Utils::oXML
01662 #define CXML     Utils::cXML
01663   };
01664 }
01665 #endif // SDMDataObject_CLASS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1