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