00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00024 #ifndef SHVARIANTCAST_HPP
00025 #define SHVARIANTCAST_HPP
00026
00027 #include "ShDllExport.hpp"
00028 #include "ShVariableType.hpp"
00029 #include "ShDataType.hpp"
00030 #include "ShVariant.hpp"
00031
00032 namespace SH {
00033
00034
00035 class ShVariant;
00036
00039
00040 struct
00041 SH_DLLEXPORT
00042 ShVariantCast {
00043 public:
00044 virtual ~ShVariantCast() {}
00045
00051 virtual void doCast(ShVariant* dest, const ShVariant* src) const = 0;
00052
00053
00054 virtual void getCastTypes(ShValueType &dest, ShDataType &destDT,
00055 ShValueType &src, ShDataType &srcDT) const = 0;
00056
00059 virtual void getDestTypes(ShValueType &valueType, ShDataType &dataType) const = 0;
00060 };
00061
00068 template<typename Dest, ShDataType DestDT,
00069 typename Src, ShDataType SrcDT>
00070 struct ShDataVariantCast: public ShVariantCast {
00071 public:
00072 static const ShValueType DestValueType = ShStorageTypeInfo<Dest>::value_type;
00073 static const ShValueType SrcValueType = ShStorageTypeInfo<Src>::value_type;
00074 typedef typename ShDataTypeCppType<Dest, DestDT>::type D;
00075 typedef typename ShDataTypeCppType<Src, SrcDT>::type S;
00076
00077 typedef ShDataVariant<Dest, DestDT> DestVariant;
00078 typedef const ShDataVariant<Src, SrcDT> SrcVariant;
00079
00080 void doCast(ShVariant* dest, const ShVariant* src) const;
00081
00082 void getCastTypes(ShValueType &dest, ShDataType &destDT,
00083 ShValueType &src, ShDataType &srcDT) const;
00084
00085 void getDestTypes(ShValueType &valueType, ShDataType &dataType) const;
00086
00087 void doCast(D &dest, const S &src) const;
00088
00089 static const ShDataVariantCast *instance();
00090 private:
00091 static ShDataVariantCast *m_instance;
00092 ShDataVariantCast() {}
00093 };
00094
00095
00096 }
00097
00098 #include "ShVariantCastImpl.hpp"
00099
00100 #endif