00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef _H_SST_CORE_STATISTICS_FIELDINFO
00013 #define _H_SST_CORE_STATISTICS_FIELDINFO
00014
00015 #include "sst/core/sst_types.h"
00016 #include <sst/core/serialization.h>
00017
00018 namespace SST {
00019 namespace Statistics {
00020
00021
00022
00023 template <typename, typename> struct is_type_same { static const bool value = false;};
00024 template <typename T> struct is_type_same<T,T> { static const bool value = true;};
00025
00026
00027
00028
00029
00030
00031
00032
00033 class StatisticFieldInfo
00034 {
00035 public:
00036
00037 enum fieldType_t {UNDEFINED, UINT32, UINT64, INT32, INT64, FLOAT, DOUBLE};
00038 typedef int32_t fieldHandle_t;
00039
00040 public:
00041
00042
00043
00044
00045
00046 StatisticFieldInfo(const char* statName, const char* fieldName, fieldType_t fieldType);
00047
00048
00049
00050 inline const std::string& getStatName() const {return m_statName;}
00051
00052 inline const std::string& getFieldName() const {return m_fieldName;}
00053
00054 fieldType_t getFieldType() const {return m_fieldType;}
00055
00056 std::string getFieldUniqueName() const;
00057
00058
00059
00060
00061
00062 bool operator==(StatisticFieldInfo& FieldInfo1);
00063
00064
00065
00066
00067 void setFieldHandle(fieldHandle_t handle) {m_fieldHandle = handle;}
00068
00069
00070
00071
00072 fieldHandle_t getFieldHandle() {return m_fieldHandle;}
00073
00074 static const char* getFieldTypeShortName(fieldType_t type);
00075 static const char* getFieldTypeFullName(fieldType_t type);
00076
00077 template<typename T>
00078 static const fieldType_t getFieldTypeFromTemplate()
00079 {
00080 if (is_type_same<T, int32_t >::value){return INT32; }
00081 if (is_type_same<T, uint32_t >::value){return UINT32;}
00082 if (is_type_same<T, int64_t >::value){return INT64; }
00083 if (is_type_same<T, uint64_t >::value){return UINT64;}
00084 if (is_type_same<T, float >::value){return FLOAT; }
00085 if (is_type_same<T, double >::value){return DOUBLE;}
00086
00087
00088 return UNDEFINED;
00089 }
00090
00091 protected:
00092 StatisticFieldInfo(){};
00093
00094 private:
00095 std::string m_statName;
00096 std::string m_fieldName;
00097 fieldType_t m_fieldType;
00098 fieldHandle_t m_fieldHandle;
00099
00100 friend class boost::serialization::access;
00101 template<class Archive>
00102 void serialize(Archive & ar, const unsigned int version)
00103 {
00104 ar & BOOST_SERIALIZATION_NVP(m_statName);
00105 ar & BOOST_SERIALIZATION_NVP(m_fieldName);
00106 ar & BOOST_SERIALIZATION_NVP(m_fieldType);
00107 ar & BOOST_SERIALIZATION_NVP(m_fieldHandle);
00108 }
00109 };
00110
00111 }
00112 }
00113
00114 BOOST_CLASS_EXPORT_KEY(SST::Statistics::StatisticFieldInfo)
00115
00116 #endif