stats: get rid of meaningless uses of virtual
This commit is contained in:
parent
ec209953e7
commit
2dd5a5b3dc
1 changed files with 79 additions and 79 deletions
|
@ -155,7 +155,7 @@ class ScalarInfoBase : public Info
|
||||||
virtual Counter value() const = 0;
|
virtual Counter value() const = 0;
|
||||||
virtual Result result() const = 0;
|
virtual Result result() const = 0;
|
||||||
virtual Result total() const = 0;
|
virtual Result total() const = 0;
|
||||||
virtual void visit(Visit &visitor) { visitor.visit(*this); }
|
void visit(Visit &visitor) { visitor.visit(*this); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Stat>
|
template <class Stat>
|
||||||
|
@ -167,12 +167,12 @@ class ScalarInfo : public ScalarInfoBase
|
||||||
public:
|
public:
|
||||||
ScalarInfo(Stat &stat) : s(stat) {}
|
ScalarInfo(Stat &stat) : s(stat) {}
|
||||||
|
|
||||||
virtual bool check() const { return s.check(); }
|
bool check() const { return s.check(); }
|
||||||
virtual Counter value() const { return s.value(); }
|
Counter value() const { return s.value(); }
|
||||||
virtual Result result() const { return s.result(); }
|
Result result() const { return s.result(); }
|
||||||
virtual Result total() const { return s.total(); }
|
Result total() const { return s.total(); }
|
||||||
virtual void reset() { s.reset(); }
|
void reset() { s.reset(); }
|
||||||
virtual bool zero() const { return s.zero(); }
|
bool zero() const { return s.zero(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class VectorInfoBase : public Info
|
class VectorInfoBase : public Info
|
||||||
|
@ -183,10 +183,10 @@ class VectorInfoBase : public Info
|
||||||
mutable std::vector<std::string> subdescs;
|
mutable std::vector<std::string> subdescs;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual size_type size() const = 0;
|
virtual size_type size() const = 0;
|
||||||
virtual const VCounter &value() const = 0;
|
virtual const VCounter &value() const = 0;
|
||||||
virtual const VResult &result() const = 0;
|
virtual const VResult &result() const = 0;
|
||||||
virtual Result total() const = 0;
|
virtual Result total() const = 0;
|
||||||
|
|
||||||
void
|
void
|
||||||
update()
|
update()
|
||||||
|
@ -213,29 +213,29 @@ class VectorInfo : public VectorInfoBase
|
||||||
public:
|
public:
|
||||||
VectorInfo(Stat &stat) : s(stat) {}
|
VectorInfo(Stat &stat) : s(stat) {}
|
||||||
|
|
||||||
virtual bool check() const { return s.check(); }
|
bool check() const { return s.check(); }
|
||||||
virtual bool zero() const { return s.zero(); }
|
bool zero() const { return s.zero(); }
|
||||||
virtual void reset() { s.reset(); }
|
void reset() { s.reset(); }
|
||||||
|
|
||||||
virtual size_type size() const { return s.size(); }
|
size_type size() const { return s.size(); }
|
||||||
|
|
||||||
virtual VCounter &
|
VCounter &
|
||||||
value() const
|
value() const
|
||||||
{
|
{
|
||||||
s.value(cvec);
|
s.value(cvec);
|
||||||
return cvec;
|
return cvec;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const VResult &
|
const VResult &
|
||||||
result() const
|
result() const
|
||||||
{
|
{
|
||||||
s.result(rvec);
|
s.result(rvec);
|
||||||
return rvec;
|
return rvec;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Result total() const { return s.total(); }
|
Result total() const { return s.total(); }
|
||||||
|
|
||||||
virtual void
|
void
|
||||||
visit(Visit &visitor)
|
visit(Visit &visitor)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
|
@ -274,11 +274,11 @@ class DistInfo : public DistInfoBase
|
||||||
public:
|
public:
|
||||||
DistInfo(Stat &stat) : s(stat) {}
|
DistInfo(Stat &stat) : s(stat) {}
|
||||||
|
|
||||||
virtual bool check() const { return s.check(); }
|
bool check() const { return s.check(); }
|
||||||
virtual void reset() { s.reset(); }
|
void reset() { s.reset(); }
|
||||||
virtual bool zero() const { return s.zero(); }
|
bool zero() const { return s.zero(); }
|
||||||
|
|
||||||
virtual void
|
void
|
||||||
visit(Visit &visitor)
|
visit(Visit &visitor)
|
||||||
{
|
{
|
||||||
s.update(this);
|
s.update(this);
|
||||||
|
@ -323,12 +323,12 @@ class VectorDistInfo : public VectorDistInfoBase
|
||||||
public:
|
public:
|
||||||
VectorDistInfo(Stat &stat) : s(stat) {}
|
VectorDistInfo(Stat &stat) : s(stat) {}
|
||||||
|
|
||||||
virtual bool check() const { return s.check(); }
|
bool check() const { return s.check(); }
|
||||||
virtual void reset() { s.reset(); }
|
void reset() { s.reset(); }
|
||||||
virtual size_type size() const { return s.size(); }
|
size_type size() const { return s.size(); }
|
||||||
virtual bool zero() const { return s.zero(); }
|
bool zero() const { return s.zero(); }
|
||||||
|
|
||||||
virtual void
|
void
|
||||||
visit(Visit &visitor)
|
visit(Visit &visitor)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
|
@ -368,11 +368,11 @@ class Vector2dInfo : public Vector2dInfoBase
|
||||||
public:
|
public:
|
||||||
Vector2dInfo(Stat &stat) : s(stat) {}
|
Vector2dInfo(Stat &stat) : s(stat) {}
|
||||||
|
|
||||||
virtual bool check() const { return s.check(); }
|
bool check() const { return s.check(); }
|
||||||
virtual void reset() { s.reset(); }
|
void reset() { s.reset(); }
|
||||||
virtual bool zero() const { return s.zero(); }
|
bool zero() const { return s.zero(); }
|
||||||
|
|
||||||
virtual void
|
void
|
||||||
visit(Visit &visitor)
|
visit(Visit &visitor)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
|
@ -862,12 +862,12 @@ class ScalarBase : public InfoAccess
|
||||||
class ProxyInfo : public ScalarInfoBase
|
class ProxyInfo : public ScalarInfoBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void visit(Visit &visitor) { visitor.visit(*this); }
|
void visit(Visit &visitor) { visitor.visit(*this); }
|
||||||
virtual std::string str() const { return to_string(value()); }
|
std::string str() const { return to_string(value()); }
|
||||||
virtual size_type size() const { return 1; }
|
size_type size() const { return 1; }
|
||||||
virtual bool zero() const { return value() == 0; }
|
bool zero() const { return value() == 0; }
|
||||||
virtual bool check() const { return true; }
|
bool check() const { return true; }
|
||||||
virtual void reset() { }
|
void reset() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
@ -878,9 +878,9 @@ class ValueProxy : public ProxyInfo
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ValueProxy(T &val) : scalar(&val) {}
|
ValueProxy(T &val) : scalar(&val) {}
|
||||||
virtual Counter value() const { return *scalar; }
|
Counter value() const { return *scalar; }
|
||||||
virtual Result result() const { return *scalar; }
|
Result result() const { return *scalar; }
|
||||||
virtual Result total() const { return *scalar; }
|
Result total() const { return *scalar; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
@ -891,9 +891,9 @@ class FunctorProxy : public ProxyInfo
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FunctorProxy(T &func) : functor(&func) {}
|
FunctorProxy(T &func) : functor(&func) {}
|
||||||
virtual Counter value() const { return (*functor)(); }
|
Counter value() const { return (*functor)(); }
|
||||||
virtual Result result() const { return (*functor)(); }
|
Result result() const { return (*functor)(); }
|
||||||
virtual Result total() const { return (*functor)(); }
|
Result total() const { return (*functor)(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class ValueBase : public InfoAccess
|
class ValueBase : public InfoAccess
|
||||||
|
@ -2024,21 +2024,21 @@ class ScalarStatNode : public Node
|
||||||
public:
|
public:
|
||||||
ScalarStatNode(const ScalarInfoBase *d) : data(d), vresult(1) {}
|
ScalarStatNode(const ScalarInfoBase *d) : data(d), vresult(1) {}
|
||||||
|
|
||||||
virtual const VResult &
|
const VResult &
|
||||||
result() const
|
result() const
|
||||||
{
|
{
|
||||||
vresult[0] = data->result();
|
vresult[0] = data->result();
|
||||||
return vresult;
|
return vresult;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Result total() const { return data->result(); };
|
Result total() const { return data->result(); };
|
||||||
|
|
||||||
virtual size_type size() const { return 1; }
|
size_type size() const { return 1; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
virtual std::string str() const { return data->name; }
|
std::string str() const { return data->name; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Stat>
|
template <class Stat>
|
||||||
|
@ -2053,20 +2053,20 @@ class ScalarProxyNode : public Node
|
||||||
: proxy(p), vresult(1)
|
: proxy(p), vresult(1)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
virtual const VResult &
|
const VResult &
|
||||||
result() const
|
result() const
|
||||||
{
|
{
|
||||||
vresult[0] = proxy.result();
|
vresult[0] = proxy.result();
|
||||||
return vresult;
|
return vresult;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Result
|
Result
|
||||||
total() const
|
total() const
|
||||||
{
|
{
|
||||||
return proxy.result();
|
return proxy.result();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual size_type
|
size_type
|
||||||
size() const
|
size() const
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -2075,7 +2075,7 @@ class ScalarProxyNode : public Node
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
virtual std::string
|
std::string
|
||||||
str() const
|
str() const
|
||||||
{
|
{
|
||||||
return proxy.str();
|
return proxy.str();
|
||||||
|
@ -2089,12 +2089,12 @@ class VectorStatNode : public Node
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VectorStatNode(const VectorInfoBase *d) : data(d) { }
|
VectorStatNode(const VectorInfoBase *d) : data(d) { }
|
||||||
virtual const VResult &result() const { return data->result(); }
|
const VResult &result() const { return data->result(); }
|
||||||
virtual Result total() const { return data->total(); };
|
Result total() const { return data->total(); };
|
||||||
|
|
||||||
virtual size_type size() const { return data->size(); }
|
size_type size() const { return data->size(); }
|
||||||
|
|
||||||
virtual std::string str() const { return data->name; }
|
std::string str() const { return data->name; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
@ -2106,9 +2106,9 @@ class ConstNode : public Node
|
||||||
public:
|
public:
|
||||||
ConstNode(T s) : vresult(1, (Result)s) {}
|
ConstNode(T s) : vresult(1, (Result)s) {}
|
||||||
const VResult &result() const { return vresult; }
|
const VResult &result() const { return vresult; }
|
||||||
virtual Result total() const { return vresult[0]; };
|
Result total() const { return vresult[0]; };
|
||||||
virtual size_type size() const { return 1; }
|
size_type size() const { return 1; }
|
||||||
virtual std::string str() const { return to_string(vresult[0]); }
|
std::string str() const { return to_string(vresult[0]); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
@ -2121,7 +2121,7 @@ class ConstVectorNode : public Node
|
||||||
ConstVectorNode(const T &s) : vresult(s.begin(), s.end()) {}
|
ConstVectorNode(const T &s) : vresult(s.begin(), s.end()) {}
|
||||||
const VResult &result() const { return vresult; }
|
const VResult &result() const { return vresult; }
|
||||||
|
|
||||||
virtual Result
|
Result
|
||||||
total() const
|
total() const
|
||||||
{
|
{
|
||||||
size_type size = this->size();
|
size_type size = this->size();
|
||||||
|
@ -2131,8 +2131,8 @@ class ConstVectorNode : public Node
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual size_type size() const { return vresult.size(); }
|
size_type size() const { return vresult.size(); }
|
||||||
virtual std::string
|
std::string
|
||||||
str() const
|
str() const
|
||||||
{
|
{
|
||||||
size_type size = this->size();
|
size_type size = this->size();
|
||||||
|
@ -2219,9 +2219,9 @@ class UnaryNode : public Node
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual size_type size() const { return l->size(); }
|
size_type size() const { return l->size(); }
|
||||||
|
|
||||||
virtual std::string
|
std::string
|
||||||
str() const
|
str() const
|
||||||
{
|
{
|
||||||
return OpString<Op>::str() + l->str();
|
return OpString<Op>::str() + l->str();
|
||||||
|
@ -2281,7 +2281,7 @@ class BinaryNode : public Node
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual size_type
|
size_type
|
||||||
size() const
|
size() const
|
||||||
{
|
{
|
||||||
size_type ls = l->size();
|
size_type ls = l->size();
|
||||||
|
@ -2296,7 +2296,7 @@ class BinaryNode : public Node
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::string
|
std::string
|
||||||
str() const
|
str() const
|
||||||
{
|
{
|
||||||
return csprintf("(%s %s %s)", l->str(), OpString<Op>::str(), r->str());
|
return csprintf("(%s %s %s)", l->str(), OpString<Op>::str(), r->str());
|
||||||
|
@ -2345,9 +2345,9 @@ class SumNode : public Node
|
||||||
return vresult;
|
return vresult;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual size_type size() const { return 1; }
|
size_type size() const { return 1; }
|
||||||
|
|
||||||
virtual std::string
|
std::string
|
||||||
str() const
|
str() const
|
||||||
{
|
{
|
||||||
return csprintf("total(%s)", l->str());
|
return csprintf("total(%s)", l->str());
|
||||||
|
@ -2740,7 +2740,7 @@ class FormulaInfoBase : public VectorInfoBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual std::string str() const = 0;
|
virtual std::string str() const = 0;
|
||||||
virtual bool check() const { return true; }
|
bool check() const { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Stat>
|
template <class Stat>
|
||||||
|
@ -2754,21 +2754,21 @@ class FormulaInfo : public FormulaInfoBase
|
||||||
public:
|
public:
|
||||||
FormulaInfo(Stat &stat) : s(stat) {}
|
FormulaInfo(Stat &stat) : s(stat) {}
|
||||||
|
|
||||||
virtual bool zero() const { return s.zero(); }
|
bool zero() const { return s.zero(); }
|
||||||
virtual void reset() { s.reset(); }
|
void reset() { s.reset(); }
|
||||||
|
|
||||||
virtual size_type size() const { return s.size(); }
|
size_type size() const { return s.size(); }
|
||||||
|
|
||||||
virtual const VResult &
|
const VResult &
|
||||||
result() const
|
result() const
|
||||||
{
|
{
|
||||||
s.result(vec);
|
s.result(vec);
|
||||||
return vec;
|
return vec;
|
||||||
}
|
}
|
||||||
virtual Result total() const { return s.total(); }
|
Result total() const { return s.total(); }
|
||||||
virtual VCounter &value() const { return cvec; }
|
VCounter &value() const { return cvec; }
|
||||||
|
|
||||||
virtual void
|
void
|
||||||
visit(Visit &visitor)
|
visit(Visit &visitor)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
|
@ -2776,7 +2776,7 @@ class FormulaInfo : public FormulaInfoBase
|
||||||
visitor.visit(*this);
|
visitor.visit(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::string str() const { return s.str(); }
|
std::string str() const { return s.str(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class Temp;
|
class Temp;
|
||||||
|
@ -2822,11 +2822,11 @@ class FormulaNode : public Node
|
||||||
public:
|
public:
|
||||||
FormulaNode(const Formula &f) : formula(f) {}
|
FormulaNode(const Formula &f) : formula(f) {}
|
||||||
|
|
||||||
virtual size_type size() const { return formula.size(); }
|
size_type size() const { return formula.size(); }
|
||||||
virtual const VResult &result() const { formula.result(vec); return vec; }
|
const VResult &result() const { formula.result(vec); return vec; }
|
||||||
virtual Result total() const { return formula.total(); }
|
Result total() const { return formula.total(); }
|
||||||
|
|
||||||
virtual std::string str() const { return formula.str(); }
|
std::string str() const { return formula.str(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue