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