The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::statistics::expression::SimVariable Struct Reference

Expression node for a simulation variable. Anything that cannot actually vary within a simulation can be handled as a Constant. If it can vary, however, it should be handled through this. More...

#include <ExpressionNodeVariables.hpp>

Inheritance diagram for sparta::statistics::expression::SimVariable:
Collaboration diagram for sparta::statistics::expression::SimVariable:

Public Types

typedef double(* getter_t) ()
 Typedef of getter function used to retrieve a variable.
 

Public Member Functions

 SimVariable (const SimVariable &rhp)
 
 SimVariable (const std::string &which, const getter_t getter)
 Construct with a getter function.
 
virtual SimVariableclone_ () const override
 Deep copy of the content of this item.
 
virtual double evaluate_ () const override
 Compute value of this item in simulation.
 
virtual bool supportsCompression () const override
 
virtual void start () override
 
virtual void end () override
 
virtual void dump (std::ostream &o, bool show_range=true, bool resolve_subexprs=true) const override
 Dump the content of this expression item.
 
virtual void getClocks (std::vector< const Clock * > &clocks) const override
 Populates a vector with the clocks found in this subexpression node.
 
- Public Member Functions inherited from sparta::statistics::expression::ExpressionNode
 ExpressionNode (const ExpressionNode &)=delete
 No copy-constructable.
 
ExpressionNodeclone () const
 
uint32_t getStats (std::vector< const StatisticInstance * > &results) const
 Gets the statistics present in this expression.
 
double evaluate ()
 Compute value of this item in simulation. Must be implemented by subclass.
 

Public Attributes

std::string which_
 Name of this variable.
 
getter_t getter_
 Function for retrieving the value of this variable.
 

Detailed Description

Expression node for a simulation variable. Anything that cannot actually vary within a simulation can be handled as a Constant. If it can vary, however, it should be handled through this.

Note
SimVariables are treated as invariant for the lifetime of an expression

Definition at line 125 of file ExpressionNodeVariables.hpp.

Member Typedef Documentation

◆ getter_t

typedef double(* sparta::statistics::expression::SimVariable::getter_t) ()

Typedef of getter function used to retrieve a variable.

Definition at line 130 of file ExpressionNodeVariables.hpp.

Constructor & Destructor Documentation

◆ SimVariable() [1/2]

sparta::statistics::expression::SimVariable::SimVariable ( const SimVariable rhp)
inline

Definition at line 144 of file ExpressionNodeVariables.hpp.

◆ SimVariable() [2/2]

sparta::statistics::expression::SimVariable::SimVariable ( const std::string &  which,
const getter_t  getter 
)
inline

Construct with a getter function.

Parameters
whichName of the variable
getterPointer to function for getting the variable as a double

Definition at line 155 of file ExpressionNodeVariables.hpp.

Member Function Documentation

◆ clone_()

virtual SimVariable * sparta::statistics::expression::SimVariable::clone_ ( ) const
inlineoverridevirtual

Deep copy of the content of this item.

To be overridden by subclasses

Implements sparta::statistics::expression::ExpressionNode.

Definition at line 160 of file ExpressionNodeVariables.hpp.

◆ dump()

virtual void sparta::statistics::expression::SimVariable::dump ( std::ostream &  o,
bool  show_range = true,
bool  resolve_subexprs = true 
) const
inlineoverridevirtual

Dump the content of this expression item.

Note
Must not evaluate the expression
Parameters
oOstream to write to
show_rangeShould the range be shown in any subexpression nodes.
resolve_subexprsShould any referenced statistic defs be expanded to their full expressions so that this becomes an expression containing only counters.

Implements sparta::statistics::expression::ExpressionNode.

Definition at line 185 of file ExpressionNodeVariables.hpp.

◆ end()

virtual void sparta::statistics::expression::SimVariable::end ( )
inlineoverridevirtual

◆ evaluate_()

virtual double sparta::statistics::expression::SimVariable::evaluate_ ( ) const
inlineoverridevirtual

Compute value of this item in simulation.

Implements sparta::statistics::expression::ExpressionNode.

Definition at line 164 of file ExpressionNodeVariables.hpp.

◆ getClocks()

virtual void sparta::statistics::expression::SimVariable::getClocks ( std::vector< const Clock * > &  clocks) const
inlineoverridevirtual

Populates a vector with the clocks found in this subexpression node.

Parameters
clocksVector of clocks to which any found clocks will be appended. This vector is not cleared.

Implements sparta::statistics::expression::ExpressionNode.

Definition at line 193 of file ExpressionNodeVariables.hpp.

◆ start()

virtual void sparta::statistics::expression::SimVariable::start ( )
inlineoverridevirtual

◆ supportsCompression()

virtual bool sparta::statistics::expression::SimVariable::supportsCompression ( ) const
inlineoverridevirtual

The SimVariable is a wrapper around a function pointer which returns a double. It might as well be generating random floating-point numbers. Let's not try to compress it.

Implements sparta::statistics::expression::ExpressionNode.

Definition at line 173 of file ExpressionNodeVariables.hpp.

Member Data Documentation

◆ getter_

getter_t sparta::statistics::expression::SimVariable::getter_

Function for retrieving the value of this variable.

Definition at line 140 of file ExpressionNodeVariables.hpp.

◆ which_

std::string sparta::statistics::expression::SimVariable::which_

Name of this variable.

Definition at line 135 of file ExpressionNodeVariables.hpp.


The documentation for this struct was generated from the following file: