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     unsigned long long startTime() const;
00925     void startTime(unsigned long long value);    
00926 
00932     unsigned int numTime() const;
00933     void numTime(unsigned int value);
00934 
00939     string dataOID() const;
00940     void dataOID(const string& value);
00941 
00942 
00947     string execBlockUID() const;
00948     void execBlockUID(const string& value);
00949 
00954     unsigned int execBlockNum() const;
00955     void execBlockNum (unsigned int value );
00956 
00961     unsigned int scanNum() const;
00962     void scanNum( unsigned int value);
00963 
00968     unsigned int subscanNum() const;
00969     void subscanNum(int value);
00970 
00975     string projectPath() const;
00976 
00982     vector<string> projectPaths() const;
00983 
00988     unsigned int numAntenna() const;
00989     void numAntenna (unsigned int value);
00990 
00995     CorrelationMode correlationMode() const;
00996 
00997 
01006     OptionalSpectralResolutionType spectralResolutionType() const;
01007 
01012     ProcessorType processorType() const;
01013 
01014 
01021     CorrelatorType correlatorType() const;
01022 
01029     bool isTP() const ;
01030 
01031 
01038     bool isCorrelation() const;
01039 
01040 
01041 
01046     const DataStruct& dataStruct() const;
01047     void dataStruct(const DataStruct& dataStruct);
01048 
01049 
01055     const vector<SDMDataSubset>& corrDataSubsets() const;
01056     void corrDataSubsets(const vector<SDMDataSubset>& value);
01057 
01066     const SDMDataSubset& sdmDataSubset(const string& projectPath) const;
01067 
01068 
01077     bool aborted() const ;
01078 
01089     unsigned long long abortTime() const ;
01090 
01091 
01092 
01103     string abortReason() const ;
01104 
01105 
01111     const SDMDataSubset& tpDataSubset() const;
01112     void tpDataSubset(const SDMDataSubset& value);
01113 
01118     string toString() const;
01119 
01124     void done();
01125 
01126   private:
01127 
01128     static vector<string> correlationModeRefs;
01129     static vector<string> axes;
01130     static vector<string> types;
01131     static vector<string> apcs;
01132 
01133     const static bool _init;
01134     static bool init();
01135 
01136     // Is the SDMDataObject actually properly filled with valid data.
01137     bool valid_; 
01138 
01139     // Global header variables.
01140     string title_;
01141 
01142     const ByteOrder* byteOrder_;
01143 
01144     int schemaVersion_;
01145     
01146     long long startTime_;
01147 
01148     string dataOID_;
01149 
01150     unsigned int dimensionality_;
01151 
01152     unsigned int numTime_;
01153 
01154     string execBlockUID_;
01155 
01156     unsigned int execBlockNum_;
01157 
01158     unsigned int scanNum_;
01159 
01160     unsigned int subscanNum_;
01161 
01162     unsigned int numAntenna_;
01163 
01164     CorrelationMode correlationMode_;
01165 
01166     OptionalSpectralResolutionType spectralResolutionType_;
01167 
01168     ProcessorType processorType_;
01169 
01170     DataStruct dataStruct_;
01171 
01172     map<string, unsigned int> str2index_;
01173     
01174     vector<SDMDataSubset> dataSubsets_;
01175 
01176     bool aborted_;
01177 
01178     unsigned long long int abortTime_;
01179     string   abortReason_;
01180 
01181     void append(const SDMDataSubset& value);
01182 
01183 
01192     unsigned int dimensionality() const;
01193     void dimensionality( unsigned int value );
01194 
01195 
01199     void owns();
01200 
01201  
01206     string toXML() ;
01207     void toXML(const BinaryPart& binaryPart, const string& elementName,  ostringstream& oss) const;
01208     void toXML(const AutoDataBinaryPart& autoDataBinaryPart, const string& elementName,  ostringstream& oss) const;
01209     void toXML(const ZeroLagsBinaryPart& zeroLagsBinaryPart, const string& elementName,  ostringstream& oss) const;
01210     void spectralWindowsToXML(const vector<Baseband>& basebands, unsigned int ibb,  ostringstream& oss) const;
01211     void basebandsToXML(ostringstream& oss) const; 
01212     void dataStructToXML(ostringstream& oss) ;
01213 
01214     void updateIdImageSPW();
01215 
01216     const static regex  SPWID;
01217 
01218   };
01219   // SDMDataObject::
01220 
01221   // SDMDataSubset:: declarations
01222   //
01230   class SDMDataSubset {
01231     friend class SDMDataObject;
01232     friend class SDMDataObjectReader;
01233     friend class SDMDataObjectStreamReader;
01234     friend class SDMDataObjectWriter;
01235     friend class CorrSubsetHeaderParser;
01236     friend class TPSubsetHeaderParser;
01237 
01238   public:
01239   
01240     /*
01241      * An empty constructor.
01242      */
01243     SDMDataSubset(SDMDataObject* owner= 0);
01244 
01245     SDMDataSubset(SDMDataObject* owner,
01246                   unsigned long long time,
01247                   unsigned long long interval,
01248                   const vector<float>& autoData);
01249 
01250     /*
01251      * A copy constructor.
01252      */
01253     SDMDataSubset(const SDMDataSubset & sdmDataSubset);
01254 
01255     /*
01256      * Overloading = 
01257      */
01258     SDMDataSubset& operator= (const SDMDataSubset& sdmDataSubset);
01259 
01260     /*
01261      * The destructor.
01262      */
01263     virtual ~SDMDataSubset();
01264 
01265     const SDMDataObject* owner() const;
01266 
01267     unsigned int integrationNum() const;
01268     
01269     unsigned int subintegrationNum() const;    
01270 
01279     string projectPath() const;
01280   
01288     unsigned long long time() const;
01289   
01294     unsigned long long interval() const;
01295 
01296 
01301     string toString(unsigned int N = 10 )const ;
01302 
01303     void binAttachToXML(const string& name, ostringstream& oss);
01304     void tpBinAttachToXML(ostringstream& oss);
01305     void corrBinAttachToXML(ostringstream& oss);
01306 
01307     void toXML(ostringstream& oss) const;
01308 
01313     string toXML();
01314 
01315 
01323     unsigned long int actualDurations(const ACTUALDURATIONSTYPE* & ptr) const;
01324 
01332     unsigned long int actualTimes(const ACTUALTIMESTYPE* & ptr) const;
01333 
01341     unsigned long int autoData(const AUTODATATYPE* & ptr) const ;
01342 
01350     unsigned long int crossData(const SHORTCROSSDATATYPE* & ptr) const;
01351 
01352 
01360     unsigned long int crossData(const INTCROSSDATATYPE* & ptr) const;
01361 
01369     unsigned long int crossData(const FLOATCROSSDATATYPE* & ptr) const;
01370 
01376     PrimitiveDataType crossDataType() const;
01377 
01378     void crossDataType(PrimitiveDataType value);
01379 
01387     unsigned long int flags(const FLAGSTYPE* &ptr) const;
01388 
01396     unsigned long int zeroLags(const ZEROLAGSTYPE* & ptr) const;
01397 
01402     bool aborted() const ; 
01403 
01409     unsigned long long abortTime() const; 
01410 
01416     string abortReason() const;
01417 
01418 
01419 
01420   private:
01421     SDMDataObject* owner_;
01422     unsigned int integrationNum_;
01423     unsigned int subintegrationNum_;
01424     CorrelationMode ref_;
01425     unsigned long long time_;
01426     unsigned long long interval_;
01427     string dataStruct_;
01428     string flagsREF_;
01429     string actualTimesREF_;
01430     string actualDurationsREF_;
01431     string zeroLagsREF_;
01432     string crossDataREF_;
01433     PrimitiveDataType crossDataType_;
01434     string autoDataREF_;
01435 
01436     const ACTUALTIMESTYPE * actualTimes_;
01437     unsigned long int nActualTimes_;
01438     const ACTUALDURATIONSTYPE * actualDurations_;
01439     unsigned long int nActualDurations_;
01440     const ZEROLAGSTYPE* zeroLags_;
01441     unsigned long int nZeroLags_;
01442     const FLAGSTYPE* flags_;    
01443     unsigned long int nFlags_;
01444     const INTCROSSDATATYPE* longCrossData_;
01445     const SHORTCROSSDATATYPE* shortCrossData_;
01446     const FLOATCROSSDATATYPE* floatCrossData_;
01447     unsigned long int nCrossData_;
01448     const AUTODATATYPE* autoData_;
01449     unsigned long int nAutoData_;
01450 
01451     string xsiType() const;
01452 
01453     bool aborted_;
01454     unsigned long long int abortTime_;
01455     string   abortReason_;
01456 
01457   };
01458   // SDMDataSubset:: declarations
01459 
01460 
01461   // Utils:: declarations
01462   //
01463   class Utils {
01464   public:
01465     static void invalidCall(const string & methodName, const SDMDataObject* sdmDataObject);
01466     static string quote(const string& s);
01467     static string quote(bool b);
01468     static string quote(int i);
01469     static string quote(unsigned int i);
01470     static string quote(long long l);
01471     static string quote(float f);
01472     static string quote(const set<string>& s);
01473     static string quote(const vector<string>& s);
01474     template<class Enum, class EnumHelper> static string quote(Enum l) {
01475       ostringstream oss;
01476       oss << "\"";
01477       oss << EnumHelper::name(l);
01478       oss << "\"";
01479       return oss.str();
01480     }
01481 
01482     template<class Enum, class EnumHelper> static string quote(const vector<Enum>& v_l) {
01483       ostringstream oss;
01484       oss << "\"";
01485 
01486       if (v_l.size() > 0)
01487         oss << EnumHelper::name(v_l.at(0));
01488 
01489       for (unsigned int i = 1; i < v_l.size(); i++)
01490         oss << " " << EnumHelper::name(v_l.at(i));
01491       oss << "\"";
01492       return oss.str();
01493     }
01494 
01495     template<class Enum, class EnumHelper> static string toString(Enum l) {
01496       ostringstream oss;
01497       oss << EnumHelper::name(l);
01498       return oss.str();
01499     }
01500 
01501     template<class Enum, class EnumHelper> static string toString(const vector<Enum>& v_l) {
01502       ostringstream oss;
01503 
01504       if (v_l.size() > 0)
01505         oss << EnumHelper::name(v_l.at(0));
01506 
01507       for (unsigned int i = 1; i < v_l.size(); i++)
01508         oss << " " << EnumHelper::name(v_l.at(i));
01509       return oss.str();
01510     }
01511 
01515     template<class Enum, class EnumHelper> static vector<Enum> enumvec(const string& strliterals) {
01516       vector<Enum> result;
01517       
01518       string strliteral;
01519       istringstream iss(strliterals);
01520       
01521       while (iss >> strliteral)
01522         result.push_back(EnumHelper::literal(strliteral));
01523       
01524       return result;
01525     }
01526 
01527 
01528     static void toXML(const string& elementName, int value, ostringstream& oss);
01529     static void toXML(const string& elementName, unsigned int value, ostringstream& oss);
01530     static void toXML(const string& elementName, long long value, ostringstream& oss);
01531     static void toXML(const string& elementName, unsigned long long value, ostringstream& oss);
01532     static void oXML(const string& elementName, ostringstream& oss);
01533     static void cXML(const string& elementName, ostringstream& oss);
01534     
01543     template<class Enum, class EnumHelper> static void toXML(const string& elementName, Enum value, ostringstream& oss) {
01544       oss << "<" << elementName << ">" << EnumHelper::name(value) << "</" << elementName << ">" << endl;      
01545     }
01546 
01547 #define QUOTE    Utils::quote
01548 #define TOSTRING Utils::toString
01549 #define TOXML    Utils::toXML
01550 #define OXML     Utils::oXML
01551 #define CXML     Utils::cXML
01552   };
01553 }
01554 #endif // SDMDataObject_CLASS