50 #ifndef ZOLTAN2_BASEMETRICVALUES_HPP 51 #define ZOLTAN2_BASEMETRICVALUES_HPP 55 #define UNKNOWN_METRICS_TYPE_NAME "UnknownMetricClass" // this is an error - I kept the base class non virtual so we could work with stl maps for example 56 #define IMBALANCE_METRICS_TYPE_NAME "ImbalanceMetrics" // For the ImbalanceMetrics class 57 #define GRAPH_METRICS_TYPE_NAME "GraphMetrics" // For the GraphMetrics class 59 #define METRICS_UNSET_STRING "unset" 64 template <
typename scalar_t>
69 void resetValues(
int memCount ){
70 scalar_t *tmp =
new scalar_t [memCount];
71 memset(tmp, 0,
sizeof(scalar_t) * memCount);
72 values_ = arcp(tmp, 0, memCount,
true);
76 std::string metricName_;
79 ArrayRCP<scalar_t> values_;
84 scalar_t
getValue(
int enumIndex)
const {
return values_[enumIndex]; }
87 void setValue(
int enumIndex, scalar_t value) { values_[enumIndex] = value; }
99 metricName_(mname), values_() {
100 resetValues(memCount);
106 resetValues(memCount);
122 const std::string &
getName()
const {
return metricName_; }
125 void setName(std::string name) { metricName_ = name;}
138 return values_[metricIndex];
146 values_[metricIndex] = value;
152 const std::vector<std::string> & metricNames =
getMetrics();
153 size_t metricIndex = std::find(metricNames.begin(), metricNames.end(), metric_name) - metricNames.begin();
168 template <
typename scalar_t>
172 template <
typename scalar_t>
176 template <
typename scalar_t>
scalar_t getMetricValue(const std::string &metric_name) const
#define IMBALANCE_METRICS_TYPE_NAME
static std::vector< std::string > static_metricNames_
static std::string static_unknown_metricTypeName_
BaseClassMetrics(int memCount, std::string mname)
Constructor.
const std::string & getName() const
Get the name of the item measured.
scalar_t getValue(int enumIndex) const
void setName(std::string name)
Set or reset the name.
void setMetricValue(const std::string &metric_name, scalar_t value) const
void setValue(int enumIndex, scalar_t value)
BaseClassMetrics()
Constructor - for compiling but not used.
size_t convertMetricNameToIndex(const std::string &metric_name) const
bool hasMetricValue(const std::string &metric_name) const
virtual const std::vector< std::string > & getMetrics() const
#define UNKNOWN_METRICS_TYPE_NAME
virtual ~BaseClassMetrics()
static std::vector< std::string > static_allMetricNames_
virtual const std::string & getMetricType() const
Get the class type of the metric.
Gathering definitions used in software development.
virtual void printLine(std::ostream &os) const
BaseClassMetrics(int memCount)
Constructor.
#define GRAPH_METRICS_TYPE_NAME
#define METRICS_UNSET_STRING