casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
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 
00134 namespace asdmbinaries {
00135 
00139   const int SCHEMAVERSION=2;
00140 
00141 
00145   class SDMDataObjectException {
00146     
00147   public:
00151     SDMDataObjectException();
00152 
00157     SDMDataObjectException(const string& m);
00158     
00162     virtual ~SDMDataObjectException();
00163 
00168     string getMessage() const;
00169     
00170   protected:
00171     string message;
00172     
00173   };
00174 
00175   inline SDMDataObjectException::SDMDataObjectException() : message ("SDMDataObjectReaderException") {}
00176   inline SDMDataObjectException::SDMDataObjectException(const string& m) : message(m) {}
00177   inline SDMDataObjectException::~SDMDataObjectException() {}
00178   inline string SDMDataObjectException::getMessage() const {
00179     return "SDMDataObjectException : " + message;
00180   }
00181   
00191   template<class Enum, class EnumHelper> 
00192     class Optional {
00193     private:
00194     bool present_;
00195     Enum literal_;
00196     
00197     public:
00203     Optional() {
00204       present_=false;
00205     }
00206     
00214     Optional(Enum literal) {
00215       literal_ = literal;
00216       present_ = true;
00217     }
00218     
00224     bool present() const { return present_; }
00225 
00234     Enum literal() const { return literal_; }
00235   };
00236 
00242   typedef Optional<SpectralResolutionType, CSpectralResolutionType> OptionalSpectralResolutionType;
00243 
00244 
00249   class ByteOrder {
00250   public:
00251     static const ByteOrder* Little_Endian; /*< A unique object to represent a little endian byte order. */
00252     static const ByteOrder* Big_Endian;    /*< A unique object to represent a big endian byte order. */
00253     static const ByteOrder* Machine_Endianity; /*< A unique object storing the endianity of the machine. */
00254 
00263     string toString() const ;
00264 
00265   private:
00266     string name_;
00267     int endianity_;
00268 
00269     ByteOrder(const string & name, int endianity);
00270     virtual ~ByteOrder();
00271     static const ByteOrder* machineEndianity(); 
00272   };
00273 
00274   // forward declarations.
00275   class SDMDataSubset;
00276   class SDMDataObject;
00277 
00278 
00279   
00280   class SDMDataObjectReader;
00281 
00282   // SDMDataObject:: declarations
00283   //
00284 
00332   class SDMDataObject {
00333     friend class SDMDataObjectStreamReader;
00334     friend class SDMDataObjectReader;
00335     friend class SDMDataObjectWriter;
00336     friend class HeaderParser;
00337     friend class SDMDataSubset;
00338     friend class CorrSubsetHeaderParser;
00339 
00340   public:
00341 
00342     // SDMDataObject::SpectralWindow:: declarations
00343     //
00356     class SpectralWindow {
00357       friend class SDMDataObject;
00358       friend class DataStruct;
00359       friend class Baseband;
00360       friend class HeaderParser;
00361 
00362     private:
00363       vector<StokesParameter> crossPolProducts_;
00364       vector<StokesParameter> sdPolProducts_;
00365       float scaleFactor_;
00366       unsigned int numSpectralPoint_;
00367       unsigned int numBin_;
00368       NetSideband sideband_;
00369       string strSw_;
00370       string strImage_;
00371       void strSw(const string& s);
00372       const string & strSw() const;
00373       void strImage(const string& s);
00374       const string & strImage() const;
00375 
00376       const SDMDataObject* owner_;
00377 
00378       void owner(const SDMDataObject* o);
00379 
00380     public:
00386       SpectralWindow();
00387 
00388 
00392       virtual ~SpectralWindow();
00393 
00397       SpectralWindow(const vector<StokesParameter>& crossPolProducts,
00398                      float scaleFactor,
00399                      unsigned int numSpectralPoint,
00400                      unsigned int numBin,
00401                      NetSideband sideband);
00402 
00406       SpectralWindow(const vector<StokesParameter>& sdPolProducts,
00407                      unsigned int numSpectralPoint,
00408                      unsigned numBin,
00409                      NetSideband sideband);
00410 
00414       SpectralWindow(const vector<StokesParameter>& crossPolProducts,
00415                      const vector<StokesParameter>& sdPolProduct,
00416                      float scaleFactor,
00417                      unsigned int numSpectralPoint,
00418                      unsigned int numBin,
00419                      NetSideband sideband);
00420 
00427       const vector<StokesParameter>& crossPolProducts() const;
00428       //void crossPolProducts(const vector<StokesParameter>& value);
00429 
00436       const vector<StokesParameter>& sdPolProducts() const;
00437       //void sdPolProducts(const vector<StokesParameter>& value);
00438 
00446       float scaleFactor() const;
00447       //void scaleFactor(float value);
00448 
00453       unsigned int numSpectralPoint() const;
00454       //void numSpectralPoint(unsigned int value);
00455 
00462       unsigned int numBin() const;
00463       //void numBin(unsigned int value);
00464 
00470       NetSidebandMod::NetSideband sideband() const;
00471 
00472     }; // SpectralWindow::
00473 
00474 
00475     // SDMDataObject::Baseband:: declarations
00476     //
00487     class Baseband {
00488       friend class SDMDataObject;
00489       friend class DataStruct;
00490       friend class HeaderParser;
00491 
00492     private:
00493       BasebandName name_;
00494       vector<SpectralWindow> spectralWindows_;
00495 
00496       const SDMDataObject* owner_;
00497 
00498       void owner(const SDMDataObject* o);
00499 
00500     public:
00506       Baseband();
00507 
00511       ~Baseband();
00512 
00516       Baseband(BasebandName name, const vector<SpectralWindow>& spectralWindows);
00517 
00522       BasebandName name() const;
00523       //void ref(BasebandName value);
00524 
00529       const vector<SpectralWindow>& spectralWindows() const;
00530       void spectralWindows(const vector<SpectralWindow>& value);
00531     }; // Baseband::
00532 
00533 
00534     // SDMDataObject::BinaryPart:: declarations
00535     //
00553     class BinaryPart {
00554       friend class DataStruct;
00555       friend class SDMDataObject;
00556       friend class HeaderParser;
00557       friend class SDMDataObjectWriter;
00558 
00559     protected:
00560       unsigned int size_;
00561       vector<AxisName> axes_;
00562 
00563       const SDMDataObject* owner_;
00564     
00565       void owner(const SDMDataObject* o);
00566     public:
00567 
00571       BinaryPart();
00572 
00576       virtual ~BinaryPart();
00577 
00581       BinaryPart( unsigned int size,
00582                   const vector<AxisName>& axes);
00583       
00588       virtual unsigned int size() const; 
00589       //      virtual void size (unsigned int value); 
00590       
00597       virtual const vector<AxisName>& axes() const ; 
00598       //      virtual void axes (const vector<AxisName>& axes); 
00599     }; // BinaryPart::
00600 
00608     class AutoDataBinaryPart : public BinaryPart {
00609       friend class DataStruct;
00610       friend class SDMDataObject;
00611       friend class HeaderParser;
00612       friend class SDMDataObjectWriter;
00613       
00614     protected:
00615       bool normalized_;
00616 
00617     public:
00621       AutoDataBinaryPart();
00622       
00626       ~AutoDataBinaryPart();
00627       
00631       AutoDataBinaryPart(unsigned int size,
00632                          const vector<AxisName>& axes,
00633                          bool normalized);
00634       
00639       virtual bool normalized() const;
00640       
00641     }; // AutoDataBinaryPart
00642     
00650     class ZeroLagsBinaryPart : public BinaryPart {
00651       friend class DataStruct;
00652       friend class SDMDataObject;
00653       friend class HeaderParser;
00654       friend class SDMDataObjectWriter;
00655 
00656     protected:
00657       CorrelatorType correlatorType_;
00658       
00659     public:
00660       
00664       ZeroLagsBinaryPart() ;
00665 
00669       ~ZeroLagsBinaryPart();
00670 
00674       ZeroLagsBinaryPart(unsigned int size,
00675                          const vector<AxisName>& axes,
00676                          CorrelatorType correlatorType);
00677 
00682       virtual CorrelatorType correlatorType() const;
00683     };
00684 
00685     // SDMDataObject::DataStruct:: declarations
00686     //
00696     class DataStruct {
00697       friend class SDMDataObject;
00698       friend class HeaderParser;
00699       friend class SDMDataObjectWriter;
00700 
00701     public:
00707       DataStruct();
00708 
00712       virtual ~DataStruct();
00713 
00733       DataStruct(const vector<AtmPhaseCorrection>& apc,
00734                  const vector<Baseband>& basebands,
00735                  const BinaryPart& flags,
00736                  const BinaryPart& actualTimes,
00737                  const BinaryPart& actualDurations,
00738                  const ZeroLagsBinaryPart& zeroLags,
00739                  const BinaryPart& crossData,
00740                  const AutoDataBinaryPart& autoData);
00741       
00742       
00747       const vector<AtmPhaseCorrection>& apc() const;
00748       //      void apc(const vector<AtmPhaseCorrection>& value);
00749 
00754       const vector<Baseband>& basebands() const;
00755       //      void basebands(const vector<Baseband>& value);
00756       
00761       const BinaryPart& flags() const;
00762       //      void flags(const BinaryPart& value);
00763 
00768       const BinaryPart& actualTimes() const;
00769       //      void actualTimes(const BinaryPart& value);
00770  
00771 
00776       const BinaryPart& actualDurations() const;
00777       //      void actualDurations(const BinaryPart& value);
00778 
00779 
00784       const ZeroLagsBinaryPart& zeroLags() const;
00785       //      void zeroLags(const BinaryPart& value);
00786 
00787 
00792       const BinaryPart& crossData() const;
00793       //      void crossData(const BinaryPart& value);
00794 
00795 
00800       const AutoDataBinaryPart& autoData() const;
00801       //      void autoData(const BinaryPart& value);
00802 
00815       void imageSPW(unsigned int ibb,
00816                     unsigned int ispw1,
00817                     unsigned int ispw2);
00818 
00830       const SpectralWindow* imageSPW(unsigned int ibb,
00831                                      unsigned int ispw) const;
00832 
00845       void imageOfSPW(unsigned int ibb,
00846                       unsigned int ispw1,
00847                       unsigned int ispw2);
00848       
00849 
00861       const SpectralWindow* imageOfSPW(unsigned int ibb,
00862                                        unsigned int ispw) const;
00863       
00864 
00865     private:
00866       vector<AtmPhaseCorrection> apc_;
00867       vector<Baseband> basebands_;
00868       BinaryPart flags_;
00869       BinaryPart actualTimes_;
00870       BinaryPart actualDurations_;
00871       ZeroLagsBinaryPart zeroLags_;
00872       BinaryPart crossData_;
00873       AutoDataBinaryPart autoData_;
00874 
00875       const SDMDataObject* owner_;
00876       void owner(const SDMDataObject* o);
00877 
00878       map<string, string> imageSPW_;
00879       map<string, string> imageOfSPW_;
00880 
00881       void checkCoordinate(unsigned int ibb, unsigned int ispw) const;
00882       bool associatedSPW(unsigned int ibb,
00883                          unsigned int ispw1,
00884                          unsigned int ispw2);
00885 
00886       void divorceSPW(unsigned int ibb, unsigned int ispw)   ;
00887 
00888     }; //DataStruct::
00889 
00890     SDMDataObject();
00891     SDMDataObject(unsigned long long startTime,
00892                   const string& dataOID,
00893                   unsigned int dimensionality,
00894                   const string& execBlockUID,
00895                   unsigned int execBlockNum,
00896                   unsigned int scanNum,
00897                   unsigned int subscanNum,
00898                   unsigned int numAntenna,
00899                   CorrelationMode correlatorMode,
00900                   const SDMDataObject::DataStruct& dataStruct);
00901 
00902     SDMDataObject(unsigned long long startTime,
00903                   const string& dataOID,
00904                   unsigned int dimensionality,
00905                   unsigned int numTime,
00906                   const string& execBlockUID,
00907                   unsigned int execBlockNum,
00908                   unsigned int scanNum,
00909                   unsigned int subscanNum,
00910                   unsigned int numAntenna,
00911                   const SDMDataObject::DataStruct& dataStruct);
00912 
00917     string title() const;
00918     void title(const string& value) ;
00919 
00924     const ByteOrder* byteOrder() const;
00925 
00930     unsigned long long startTime() const;
00931     void startTime(unsigned long long value);    
00932 
00938     unsigned int numTime() const;
00939     void numTime(unsigned int value);
00940 
00945     string dataOID() const;
00946     void dataOID(const string& value);
00947 
00948 
00953     string execBlockUID() const;
00954     void execBlockUID(const string& value);
00955 
00960     unsigned int execBlockNum() const;
00961     void execBlockNum (unsigned int value );
00962 
00967     unsigned int scanNum() const;
00968     void scanNum( unsigned int value);
00969 
00974     unsigned int subscanNum() const;
00975     void subscanNum(int value);
00976 
00981     string projectPath() const;
00982 
00988     vector<string> projectPaths() const;
00989 
00994     unsigned int numAntenna() const;
00995     void numAntenna (unsigned int value);
00996 
01001     CorrelationMode correlationMode() const;
01002 
01003 
01012     OptionalSpectralResolutionType spectralResolutionType() const;
01013 
01018     ProcessorType processorType() const;
01019 
01020 
01027     CorrelatorType correlatorType() const;
01028 
01035     bool isTP() const ;
01036 
01037 
01044     bool isCorrelation() const;
01045 
01046 
01047 
01052     const DataStruct& dataStruct() const;
01053     void dataStruct(const DataStruct& dataStruct);
01054 
01055 
01061     const vector<SDMDataSubset>& corrDataSubsets() const;
01062     void corrDataSubsets(const vector<SDMDataSubset>& value);
01063 
01072     const SDMDataSubset& sdmDataSubset(const string& projectPath) const;
01073 
01074 
01083     bool aborted() const ;
01084 
01095     unsigned long long abortTime() const ;
01096 
01097 
01098 
01109     string abortReason() const ;
01110 
01111 
01117     const SDMDataSubset& tpDataSubset() const;
01118     void tpDataSubset(const SDMDataSubset& value);
01119 
01124     string toString() const;
01125 
01130     void done();
01131 
01132   private:
01133 
01134     static vector<string> correlationModeRefs;
01135     static vector<string> axes;
01136     static vector<string> types;
01137     static vector<string> apcs;
01138 
01139     const static bool _init;
01140     static bool init();
01141 
01142     // Is the SDMDataObject actually properly filled with valid data.
01143     bool valid_; 
01144 
01145     // Global header variables.
01146     string title_;
01147 
01148     const ByteOrder* byteOrder_;
01149 
01150     int schemaVersion_;
01151     
01152     long long startTime_;
01153 
01154     string dataOID_;
01155 
01156     unsigned int dimensionality_;
01157 
01158     unsigned int numTime_;
01159 
01160     string execBlockUID_;
01161 
01162     unsigned int execBlockNum_;
01163 
01164     unsigned int scanNum_;
01165 
01166     unsigned int subscanNum_;
01167 
01168     unsigned int numAntenna_;
01169 
01170     CorrelationMode correlationMode_;
01171 
01172     OptionalSpectralResolutionType spectralResolutionType_;
01173 
01174     ProcessorType processorType_;
01175 
01176     DataStruct dataStruct_;
01177 
01178     map<string, unsigned int> str2index_;
01179     
01180     vector<SDMDataSubset> dataSubsets_;
01181 
01182     bool aborted_;
01183 
01184     unsigned long long int abortTime_;
01185     string   abortReason_;
01186 
01187     void append(const SDMDataSubset& value);
01188 
01189 
01198     unsigned int dimensionality() const;
01199     void dimensionality( unsigned int value );
01200 
01201 
01205     void owns();
01206 
01207  
01212     string toXML() ;
01213     void toXML(const BinaryPart& binaryPart, const string& elementName,  ostringstream& oss) const;
01214     void toXML(const AutoDataBinaryPart& autoDataBinaryPart, const string& elementName,  ostringstream& oss) const;
01215     void toXML(const ZeroLagsBinaryPart& zeroLagsBinaryPart, const string& elementName,  ostringstream& oss) const;
01216     void spectralWindowsToXML(const vector<Baseband>& basebands, unsigned int ibb,  ostringstream& oss) const;
01217     void basebandsToXML(ostringstream& oss) const; 
01218     void dataStructToXML(ostringstream& oss) ;
01219 
01220     void updateIdImageSPW();
01221 
01222     const static regex  SPWID;
01223 
01224   };
01225   // SDMDataObject::
01226 
01227   // SDMDataSubset:: declarations
01228   //
01236   class SDMDataSubset {
01237     friend class SDMDataObject;
01238     friend class SDMDataObjectReader;
01239     friend class SDMDataObjectStreamReader;
01240     friend class SDMDataObjectWriter;
01241     friend class CorrSubsetHeaderParser;
01242     friend class TPSubsetHeaderParser;
01243 
01244   public:
01245   
01246     /*
01247      * An empty constructor.
01248      */
01249     SDMDataSubset(SDMDataObject* owner= 0);
01250 
01251     SDMDataSubset(SDMDataObject* owner,
01252                   unsigned long long time,
01253                   unsigned long long interval,
01254                   const vector<float>& autoData);
01255 
01256     /*
01257      * A copy constructor.
01258      */
01259     SDMDataSubset(const SDMDataSubset & sdmDataSubset);
01260 
01261     /*
01262      * Overloading = 
01263      */
01264     SDMDataSubset& operator= (const SDMDataSubset& sdmDataSubset);
01265 
01266     /*
01267      * The destructor.
01268      */
01269     virtual ~SDMDataSubset();
01270 
01271     const SDMDataObject* owner() const;
01272 
01273     unsigned int integrationNum() const;
01274     
01275     unsigned int subintegrationNum() const;    
01276 
01285     string projectPath() const;
01286   
01294     unsigned long long time() const;
01295   
01300     unsigned long long interval() const;
01301 
01302 
01307     string toString(unsigned int N = 10 )const ;
01308 
01309     void binAttachToXML(const string& name, ostringstream& oss);
01310     void tpBinAttachToXML(ostringstream& oss);
01311     void corrBinAttachToXML(ostringstream& oss);
01312 
01313     void toXML(ostringstream& oss) const;
01314 
01319     string toXML();
01320 
01321 
01329     unsigned long int actualDurations(const ACTUALDURATIONSTYPE* & ptr) const;
01330 
01337     uint64_t actualDurationsPosition() const;
01338 
01346     unsigned long int actualTimes(const ACTUALTIMESTYPE* & ptr) const;
01347 
01354     uint64_t actualTimesPosition() const;
01355 
01363     unsigned long int autoData(const AUTODATATYPE* & ptr) const ;
01364 
01371     uint64_t autoDataPosition() const;
01372 
01380     unsigned long int crossData(const SHORTCROSSDATATYPE* & ptr) const;
01381 
01382 
01390     unsigned long int crossData(const INTCROSSDATATYPE* & ptr) const;
01391 
01399     unsigned long int crossData(const FLOATCROSSDATATYPE* & ptr) const;
01400 
01407     uint64_t crossDataPosition() const;
01408 
01414     PrimitiveDataType crossDataType() const;
01415 
01416     void crossDataType(PrimitiveDataType value);
01417 
01425     unsigned long int flags(const FLAGSTYPE* &ptr) const;
01426 
01433     uint64_t flagsPosition() const;
01434 
01442     unsigned long int zeroLags(const ZEROLAGSTYPE* & ptr) const;
01443 
01450     uint64_t zeroLagsPosition() const;
01451 
01456     bool aborted() const ; 
01457 
01463     unsigned long long abortTime() const; 
01464 
01470     string abortReason() const;
01471 
01472 
01473 
01474   private:
01475     SDMDataObject* owner_;
01476     unsigned int integrationNum_;
01477     unsigned int subintegrationNum_;
01478     CorrelationMode ref_;
01479     unsigned long long time_;
01480     unsigned long long interval_;
01481     string dataStruct_;
01482     string flagsREF_;
01483     string actualTimesREF_;
01484     string actualDurationsREF_;
01485     string zeroLagsREF_;
01486     string crossDataREF_;
01487     PrimitiveDataType crossDataType_;
01488     string autoDataREF_;
01489 
01490     const ACTUALTIMESTYPE * actualTimes_;
01491     unsigned long int nActualTimes_;
01492     uint64_t actualTimesPosition_;
01493     const ACTUALDURATIONSTYPE * actualDurations_;
01494     unsigned long int nActualDurations_;
01495     uint64_t actualDurationsPosition_;
01496     const ZEROLAGSTYPE* zeroLags_;
01497     unsigned long int nZeroLags_;
01498     uint64_t zeroLagsPosition_;
01499     const FLAGSTYPE* flags_;    
01500     unsigned long int nFlags_;
01501     uint64_t flagsPosition_;
01502     const INTCROSSDATATYPE* longCrossData_;
01503     const SHORTCROSSDATATYPE* shortCrossData_;
01504     const FLOATCROSSDATATYPE* floatCrossData_;
01505     unsigned long int nCrossData_;
01506     uint64_t crossDataPosition_;
01507     const AUTODATATYPE* autoData_;
01508     unsigned long int nAutoData_;
01509     uint64_t autoDataPosition_;
01510 
01511     string xsiType() const;
01512 
01513     bool aborted_;
01514     unsigned long long int abortTime_;
01515     string   abortReason_;
01516 
01517   };
01518   // SDMDataSubset:: declarations
01519 
01520 
01521   // Utils:: declarations
01522   //
01523   class Utils {
01524   public:
01525     static void invalidCall(const string & methodName, const SDMDataObject* sdmDataObject);
01526     static string quote(const string& s);
01527     static string quote(bool b);
01528     static string quote(int i);
01529     static string quote(unsigned int i);
01530     static string quote(long long l);
01531     static string quote(float f);
01532     static string quote(const set<string>& s);
01533     static string quote(const vector<string>& s);
01534     template<class Enum, class EnumHelper> static string quote(Enum l) {
01535       ostringstream oss;
01536       oss << "\"";
01537       oss << EnumHelper::name(l);
01538       oss << "\"";
01539       return oss.str();
01540     }
01541 
01542     template<class Enum, class EnumHelper> static string quote(const vector<Enum>& v_l) {
01543       ostringstream oss;
01544       oss << "\"";
01545 
01546       if (v_l.size() > 0)
01547         oss << EnumHelper::name(v_l.at(0));
01548 
01549       for (unsigned int i = 1; i < v_l.size(); i++)
01550         oss << " " << EnumHelper::name(v_l.at(i));
01551       oss << "\"";
01552       return oss.str();
01553     }
01554 
01555     template<class Enum, class EnumHelper> static string toString(Enum l) {
01556       ostringstream oss;
01557       oss << EnumHelper::name(l);
01558       return oss.str();
01559     }
01560 
01561     template<class Enum, class EnumHelper> static string toString(const vector<Enum>& v_l) {
01562       ostringstream oss;
01563 
01564       if (v_l.size() > 0)
01565         oss << EnumHelper::name(v_l.at(0));
01566 
01567       for (unsigned int i = 1; i < v_l.size(); i++)
01568         oss << " " << EnumHelper::name(v_l.at(i));
01569       return oss.str();
01570     }
01571 
01575     template<class Enum, class EnumHelper> static vector<Enum> enumvec(const string& strliterals) {
01576       vector<Enum> result;
01577       
01578       string strliteral;
01579       istringstream iss(strliterals);
01580       
01581       while (iss >> strliteral)
01582         result.push_back(EnumHelper::literal(strliteral));
01583       
01584       return result;
01585     }
01586 
01587 
01588     static void toXML(const string& elementName, int value, ostringstream& oss);
01589     static void toXML(const string& elementName, unsigned int value, ostringstream& oss);
01590     static void toXML(const string& elementName, long long value, ostringstream& oss);
01591     static void toXML(const string& elementName, unsigned long long value, ostringstream& oss);
01592     static void oXML(const string& elementName, ostringstream& oss);
01593     static void cXML(const string& elementName, ostringstream& oss);
01594     
01603     template<class Enum, class EnumHelper> static void toXML(const string& elementName, Enum value, ostringstream& oss) {
01604       oss << "<" << elementName << ">" << EnumHelper::name(value) << "</" << elementName << ">" << endl;      
01605     }
01606 
01607 #define QUOTE    Utils::quote
01608 #define TOSTRING Utils::toString
01609 #define TOXML    Utils::toXML
01610 #define OXML     Utils::oXML
01611 #define CXML     Utils::cXML
01612   };
01613 }
01614 #endif // SDMDataObject_CLASS