00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020 #ifndef SHTYPEINFO_HPP
00021 #define SHTYPEINFO_HPP
00022
00023 #include <string>
00024 #include <vector>
00025 #include "ShHashMap.hpp"
00026 #include "ShVariableType.hpp"
00027 #include "ShDataType.hpp"
00028 #include "ShRefCount.hpp"
00029 #include "ShFraction.hpp"
00030 #include "ShHalf.hpp"
00031
00032 namespace SH {
00033
00035 struct ShVariantFactory;
00036
00037
00041 struct
00042 SH_DLLEXPORT
00043 ShTypeInfo {
00044 virtual ~ShTypeInfo() {}
00045
00047 virtual const char* name() const = 0;
00048
00050 virtual int datasize() const = 0;
00051
00053 virtual const ShVariantFactory* variantFactory() const = 0;
00054
00058 static void init();
00059
00061 static const ShTypeInfo* get(ShValueType valueType, ShDataType dataType);
00062
00063 typedef ShPairHashMap<ShValueType, ShDataType, const ShTypeInfo*> TypeInfoMap;
00064 private:
00066 static TypeInfoMap* m_valueTypes;
00067
00069 static void addCasts();
00070
00072 static void addOps();
00073 };
00074
00075
00076
00077 template<typename T, ShDataType DT>
00078 struct ShDataTypeInfo: public ShTypeInfo {
00079 public:
00080 typedef typename ShDataTypeCppType<T, DT>::type type;
00081 static const type Zero;
00082 static const type One;
00083
00084 const char* name() const;
00085 int datasize() const;
00086 const ShVariantFactory* variantFactory() const;
00087
00088 static const ShDataTypeInfo* instance();
00089
00090 protected:
00091 static ShDataTypeInfo *m_instance;
00092 ShDataTypeInfo() {}
00093 };
00094
00095
00096 SH_DLLEXPORT
00097 extern const ShTypeInfo* shTypeInfo(ShValueType valueType, ShDataType dataType = SH_HOST);
00098
00099 SH_DLLEXPORT
00100 extern const ShVariantFactory* shVariantFactory(ShValueType valueType, ShDataType dataType = SH_HOST);
00101
00102 SH_DLLEXPORT
00103 extern const char* shValueTypeName(ShValueType valueType);
00104 }
00105
00106 #include "ShTypeInfoImpl.hpp"
00107
00108 #endif