CCAFFEINE
0.8.8
|
00001 #ifndef util_typemap_h_seen 00002 #define util_typemap_h_seen 00003 00004 #include "dc/export/ccafeopq.hh" 00005 00006 namespace gov { 00007 namespace sandia { 00008 namespace util { 00009 00010 typedef ::ccafeopq::TypeMismatchException TypeMismatchException; 00011 00012 typedef ::std::vector< ::std::string > StringVector; 00013 typedef ::std::map< ::std::string, ::std::string > StringMap; 00014 typedef ::std::map< ::std::string, ::ccafeopq::Type > TypeMapFilter; 00015 typedef ::std::map< ::std::string, ::ccafeopq::Type >::const_iterator Filtrator; 00016 00023 class TypeMapImpl; 00024 00033 class TypeMap : public virtual ::ccafeopq::TypeMap_Interface 00034 { 00035 private: 00036 TypeMapImpl *m; 00037 static void copyInData( TypeMap * tmSrc, ::ccafeopq::TypeMap_shared tmDest); 00038 00039 public: 00040 00041 TypeMap(); 00042 00044 virtual ~TypeMap(); 00045 00047 virtual ::ccafeopq::TypeMap_shared cloneData(); 00048 virtual ::ccafeopq::TypeMap_shared cloneTypeMap(); 00049 00051 virtual ::ccafeopq::TypeMap_shared cloneEmpty(); 00052 00055 virtual int32_t getInt(const ::std::string & key, int32_t defaultValue) throw (TypeMismatchException ) ; 00056 00059 virtual int64_t getLong(const ::std::string & key, int64_t defaultValue) throw (TypeMismatchException ); 00060 00063 virtual float getFloat(const ::std::string & key, float defaultValue) throw (TypeMismatchException ); 00064 00067 virtual double getDouble(const ::std::string & key, double defaultValue) throw (TypeMismatchException ); 00068 00071 virtual ::std::complex<float> getFcomplex(const ::std::string & key, ::std::complex<float> defaultValue) throw (TypeMismatchException ); 00072 00075 virtual ::std::complex<double> getDcomplex(const ::std::string & key, ::std::complex<double> defaultValue) throw (TypeMismatchException ); 00076 00079 virtual ::std::string getString(const ::std::string & key, ::std::string defaultValue) throw (TypeMismatchException ); 00080 00083 virtual bool getBool(const ::std::string & key, bool defaultValue) throw (TypeMismatchException ); 00084 00085 // ====================================================== 00086 00089 virtual ::std::vector< int32_t > getIntArray(const ::std::string & key, ::std::vector< int32_t >& defaultValue) throw (TypeMismatchException ); 00090 00091 00094 virtual ::std::vector< int64_t > getLongArray(const ::std::string & key, ::std::vector< int64_t >& defaultValue) throw (TypeMismatchException ); 00095 00096 #if (SIZEOF_LONG_INT != 8) 00097 virtual ::std::vector< long int > getLongArray(const ::std::string & key, ::std::vector< long int >& defaultValue) throw (TypeMismatchException ); 00098 #endif 00099 00102 virtual ::std::vector< float > getFloatArray(const ::std::string & key, ::std::vector< float >& defaultValue) throw (TypeMismatchException ); 00103 00106 virtual ::std::vector< double > getDoubleArray(const ::std::string & key, ::std::vector< double >& defaultValue) throw (TypeMismatchException ); 00107 00110 virtual ::std::vector< ::std::complex<float> > getFcomplexArray(const ::std::string & key, ::std::vector< ::std::complex<float> >& defaultValue) throw (TypeMismatchException ); 00111 00114 virtual ::std::vector< ::std::complex<double> > getDcomplexArray(const ::std::string & key, ::std::vector< ::std::complex<double> >& defaultValue) throw (TypeMismatchException ); 00115 00118 virtual ::std::vector< ::std::string > getStringArray(const ::std::string & key, ::std::vector< ::std::string >& defaultValue) throw (TypeMismatchException ) ; 00119 00122 virtual ::std::vector< bool > getBoolArray(const ::std::string & key, ::std::vector< bool >& defaultValue) throw (TypeMismatchException ); 00123 00124 00125 // ====================================================== 00126 00129 virtual void putInt(const ::std::string & key, int32_t value) throw (TypeMismatchException ); 00130 00133 virtual void putLong(const ::std::string & key, int64_t value) throw (TypeMismatchException ); 00134 00137 virtual void putFloat(const ::std::string & key, float value) throw (TypeMismatchException ); 00138 00141 virtual void putDouble(const ::std::string & key, double value) throw (TypeMismatchException ); 00142 00145 virtual void putFcomplex(const ::std::string & key, ::std::complex<float> value) throw (TypeMismatchException ); 00146 00149 virtual void putDcomplex(const ::std::string & key, ::std::complex<double> value) throw (TypeMismatchException ); 00150 00153 virtual void putString(const ::std::string & key, const ::std::string & value) throw (TypeMismatchException ) ; 00154 00157 virtual void putBool(const ::std::string & key, bool value) throw (TypeMismatchException ) ; 00158 00159 // ====================================================== 00160 00164 virtual void putIntArray(const ::std::string & key, int32_t * value ,int length) throw (TypeMismatchException ); 00165 00167 virtual void putIntArray(const ::std::string & key, ::std::vector< int32_t >& value) throw (TypeMismatchException ); 00168 00172 virtual void putLongArray(const ::std::string & key, int64_t * value ,int length) throw (TypeMismatchException ); 00173 00175 virtual void putLongArray(const ::std::string & key, ::std::vector< int64_t >& value ) throw (TypeMismatchException ); 00176 #if (SIZEOF_LONG_INT != 8) 00177 virtual void putLongArray(const ::std::string & key, ::std::vector< long int >& value ) throw (TypeMismatchException ); 00178 #endif 00179 00183 virtual void putFloatArray(const ::std::string & key, float * value ,int length) throw (TypeMismatchException ) ; 00184 00186 virtual void putFloatArray(const ::std::string & key, ::std::vector< float >& value ) throw (TypeMismatchException ); 00187 00191 virtual void putDoubleArray(const ::std::string & key, double * value ,int length) throw (TypeMismatchException ); 00192 00194 virtual void putDoubleArray(const ::std::string & key, ::std::vector< double >& value) throw (TypeMismatchException ) ; 00195 00198 virtual void putFcomplexArray(const ::std::string & key, ::std::complex<float> * value ,int length) throw (TypeMismatchException ) ; 00199 00201 virtual void putFcomplexArray(const ::std::string & key, ::std::vector< ::std::complex<float> >& value) throw (TypeMismatchException ); 00202 00205 virtual void putDcomplexArray(const ::std::string & key, ::std::complex<double> * value ,int length) throw (TypeMismatchException ); 00206 00208 virtual void putDcomplexArray(const ::std::string & key, ::std::vector< ::std::complex<double> >& value) throw (TypeMismatchException ); 00209 00213 virtual void putStringArray(const ::std::string & key, ::std::vector< ::std::string >& value) throw (TypeMismatchException ) ; 00214 00218 virtual void putBoolArray(const ::std::string & key, bool * value ,int length) throw (TypeMismatchException ); 00219 00221 virtual void putBoolArray(const ::std::string & key, ::std::vector< bool >& value) throw (TypeMismatchException ); 00222 00223 // ====================================================== 00224 00226 virtual void remove (const ::std::string & key); 00227 00234 virtual ::std::vector< ::std::string > getAllKeys( enum ::ccafeopq::Type t); 00235 00237 virtual bool hasKey(const ::std::string & key); 00238 00240 virtual enum ::ccafeopq::Type typeOf(const ::std::string & key); 00241 00242 //=============================================================== 00243 // static util functions for typemaps 00244 //=============================================================== 00245 00246 static ::ccafeopq::TypeMap_shared createTypeMap(); 00247 00249 static void copyInData( ::ccafeopq::TypeMap_shared tmSrc, ::ccafeopq::TypeMap_shared tmDest); 00250 00254 static void copyInData( ::ccafeopq::TypeMap_shared tmSrc, ::ccafeopq::TypeMap_shared tmDest, 00255 TypeMapFilter & ignoreKeys); 00256 00260 static void copyInKeys( ::ccafeopq::TypeMap_shared tmSrc, ::ccafeopq::TypeMap_shared tmDest, 00261 TypeMapFilter & srcKeys); 00262 00268 static StringVector copyInKeysTell( ::ccafeopq::TypeMap_shared tmSrc, ::ccafeopq::TypeMap_shared tmDest, 00269 StringVector & destKeys); 00270 00275 static void props2typemap(char** properties, ::ccafeopq::TypeMap_shared tm); 00276 00277 static ::ccafeopq::TypeMap_shared props2newtypemap(char** properties); 00278 00279 static StringMap props2stringmap(char ** properties); 00280 00282 static void stringmap2typemap( const StringMap & stringmap, ::ccafeopq::TypeMap_shared tm ); 00283 00285 static ::ccafeopq::TypeMap_shared stringmap2newtypemap( const StringMap & stringmap ); 00286 00287 static void pi2typemap( ::ccafeopq::PortInfo * pi, ::ccafeopq::TypeMap_shared tm); 00288 00289 static ::std::vector< ::std::string > typemap2props( ::ccafeopq::TypeMap_shared tm); 00290 00291 static StringMap typemap2stringmap( ::ccafeopq::TypeMap_shared tm); 00292 00293 static ::std::string stringType( ::ccafeopq::TypeMap_shared t, const ::std::string &key); 00294 static ::std::string stringValue( ::ccafeopq::TypeMap_shared t, const ::std::string &key); 00295 static ::ccafeopq::Type typeFromString( const ::std::string & typeName); 00296 00297 static int putValueByStrings( ::ccafeopq::TypeMap_shared t, const ::std::string & key, const ::std::string & valType, const ::std::string & val); 00298 00299 static void dump( ::ccafeopq::TypeMap_shared t ); 00300 00301 }; // end class typemap impl wrapper 00302 00303 } ENDSEMI // end namespace util 00304 } ENDSEMI // end namespace sandia 00305 } ENDSEMI // end namespace gov 00306 00307 #endif // util_typemap_h_seen