13#include "sparta/statistics/ExpressionNode.hpp"
18class StatInstCalculator;
20 namespace statistics {
21 namespace expression {
58 std::vector<const TreeNode*>& used) :
59 stat_(calculator, used)
67 virtual ~StatVariable() {
79 virtual bool supportsCompression()
const override {
94 virtual void start()
override {
97 virtual void end()
override {
101 virtual void dump(std::ostream& o,
102 bool show_range=
true,
103 bool resolve_subexprs=
true)
const override {
107 virtual void getClocks(std::vector<const Clock*>& clocks)
const override {
113 virtual uint32_t getStats_(std::vector<const StatisticInstance*>& results)
const override {
114 results.push_back(&
stat_);
177 virtual void start()
override {
181 virtual void end()
override {
185 virtual void dump(std::ostream& o,
186 bool show_range=
true,
187 bool resolve_subexprs=
true)
const override {
189 (void) resolve_subexprs;
190 o <<
"{simvar " <<
which_ <<
"}";
193 virtual void getClocks(std::vector<const Clock*>& clocks)
const override {
200 virtual uint32_t getStats_(std::vector<const StatisticInstance*>& results)
const override {
240 template <
typename T>
249 static_assert(std::is_same<T,double>::value,
250 "ReferenceVariable must be constructed with a double&. Someone called this "
251 "method with a non-double argument");
275 virtual void start()
override {
279 virtual void end()
override {
283 virtual void dump(std::ostream& o,
284 bool show_range=
true,
285 bool resolve_subexprs=
true)
const override {
287 (void) resolve_subexprs;
291 virtual void getClocks(std::vector<const Clock*>& clocks)
const override {
298 virtual uint32_t getStats_(std::vector<const StatisticInstance*>& results)
const override {
Contains a StatisticInstance which refers to a StatisticDef or Counter and some local state to comput...
Instance of either a StatisticDef or CounterBase or an Expression. Has a sample window (simulator tic...
std::string getExpressionString(bool show_range=true, bool resolve_subexprs=true) const
Returns a string containing the expression that this statistic will evaluate.
void start()
Start the computation window for this instance.
void getClocks(std::vector< const Clock * > &clocks) const
Gets all clocks associated with this Statistic instance (if any) whether it points to a StatisticDef,...
void end()
Ends the window for this instance. Computes and caches the result of the statistic.
double getValue() const
Returns the value computed for this statistic instance at the current time.
bool supportsCompression() const
Node in a composite tree representing a sparta Tree item.
Abstract interface class for an item in an expression. Subclasses can contain other ExpressionNodes.
Macros for handling exponential backoff.
Expression node for a reference to a double. Anything that cannot actually vary can be handled as a c...
virtual void dump(std::ostream &o, bool show_range=true, bool resolve_subexprs=true) const override
Dump the content of this expression item.
std::string which_
Name of this variable.
virtual void getClocks(std::vector< const Clock * > &clocks) const override
Populates a vector with the clocks found in this subexpression node.
virtual double evaluate_() const override
Compute value of this item in simulation.
ReferenceVariable(const std::string &which, const T &ref)
Construct with a value reference.
const double & ref_
Reference to actual variable.
virtual ReferenceVariable * clone_() const override
Deep copy of the content of this item.
ReferenceVariable operator=(const ReferenceVariable &)=delete
Copy-assignment Disallowed.
virtual bool supportsCompression() const override
Expression node for a simulation variable. Anything that cannot actually vary within a simulation can...
std::string which_
Name of this variable.
getter_t getter_
Function for retrieving the value of this variable.
virtual double evaluate_() const override
Compute value of this item in simulation.
virtual void getClocks(std::vector< const Clock * > &clocks) const override
Populates a vector with the clocks found in this subexpression node.
double(* getter_t)()
Typedef of getter function used to retrieve a variable.
SimVariable(const std::string &which, const getter_t getter)
Construct with a getter function.
virtual SimVariable * clone_() const override
Deep copy of the content of this item.
virtual void dump(std::ostream &o, bool show_range=true, bool resolve_subexprs=true) const override
Dump the content of this expression item.
virtual bool supportsCompression() const override
sparta::StatisticInstance stat_
Contained statistic.
StatVariable(std::shared_ptr< StatInstCalculator > &calculator, std::vector< const TreeNode * > &used)
Construct from a given StatInstCalculator (wrapper class around a SpartaHandler).
virtual double evaluate_() const override
Compute value of this item in simulation.
StatVariable(const TreeNode *n, std::vector< const TreeNode * > &used)
Construct from a given Counter or Statistic.
StatVariable()=delete
Not default constructable.
virtual void getClocks(std::vector< const Clock * > &clocks) const override
Populates a vector with the clocks found in this subexpression node.
virtual StatVariable * clone_() const override
Deep copy of the content of this item.
virtual void dump(std::ostream &o, bool show_range=true, bool resolve_subexprs=true) const override
Dump the content of this expression item.
StatisticInstance * getStatisticInstance()
Returns the sparta StatisticInstance contained in this ExpressionNode Node.