Nektar++
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Nektar::Metric Class Referenceabstract

Base class for all metrics. Metric represents a test metric that can be used to evaluate the functionality or performance of a Nektar++ executable. More...

#include <Metric.h>

Inheritance diagram for Nektar::Metric:
[legend]

Public Member Functions

 Metric (TiXmlElement *metric, bool generate)
 Constructor. More...
 
virtual ~Metric ()=default
 
bool Test (std::istream &pStdout, std::istream &pStderr)
 Calls a metric's v_Test function (or v_Generate if m_generate). More...
 
void Generate (std::istream &pStdout, std::istream &pStderr)
 
std::string GetType ()
 Return metric type. More...
 
int GetID ()
 Return metric ID. More...
 
bool SupportsAverage () const
 Return whether this metric supports averaging results from multiple runs. More...
 

Protected Member Functions

virtual bool v_Test (std::istream &pStdout, std::istream &pStderr)=0
 Virtual function to test the metric. Should be redefined in derived classes. More...
 
virtual void v_Generate (std::istream &pStdout, std::istream &pSrderr)=0
 Virtual function to generate the metric. Should be redefined in derived classes. More...
 

Protected Attributes

int m_id
 Stores the ID of this metric. More...
 
std::string m_type
 Stores the type of this metric (uppercase). More...
 
bool m_generate
 Determines whether to generate this metric or not. More...
 
bool m_average = false
 Indicates whether a metric supports averaging results from multiple runs. More...
 
TiXmlElement * m_metric
 Pointer to XML structure containing metric definition. More...
 

Detailed Description

Base class for all metrics. Metric represents a test metric that can be used to evaluate the functionality or performance of a Nektar++ executable.

Definition at line 64 of file Metric.h.

Constructor & Destructor Documentation

◆ Metric()

Nektar::Metric::Metric ( TiXmlElement *  metric,
bool  generate 
)

Constructor.

Definition at line 51 of file Metric.cpp.

52 : m_generate(generate), m_metric(metric)
53{
54 if (!metric->Attribute("id"))
55 {
56 cerr << "Metric has no ID" << endl;
57 }
58 if (!metric->Attribute("type"))
59 {
60 cerr << "Metric has no type" << endl;
61 }
62 m_id = atoi(metric->Attribute("id"));
63 m_type = boost::to_upper_copy(string(metric->Attribute("type")));
64}
TiXmlElement * m_metric
Pointer to XML structure containing metric definition.
Definition: Metric.h:101
int m_id
Stores the ID of this metric.
Definition: Metric.h:92
std::string m_type
Stores the type of this metric (uppercase).
Definition: Metric.h:94
bool m_generate
Determines whether to generate this metric or not.
Definition: Metric.h:96

References m_id, and m_type.

◆ ~Metric()

virtual Nektar::Metric::~Metric ( )
virtualdefault

Member Function Documentation

◆ Generate()

void Nektar::Metric::Generate ( std::istream &  pStdout,
std::istream &  pStderr 
)

◆ GetID()

int Nektar::Metric::GetID ( )
inline

Return metric ID.

Definition at line 79 of file Metric.h.

80 {
81 return m_id;
82 }

References m_id.

◆ GetType()

std::string Nektar::Metric::GetType ( )
inline

Return metric type.

Definition at line 74 of file Metric.h.

75 {
76 return m_type;
77 }

References m_type.

◆ SupportsAverage()

bool Nektar::Metric::SupportsAverage ( ) const
inline

Return whether this metric supports averaging results from multiple runs.

Definition at line 85 of file Metric.h.

86 {
87 return m_average;
88 }
bool m_average
Indicates whether a metric supports averaging results from multiple runs.
Definition: Metric.h:99

References m_average.

◆ Test()

bool Nektar::Metric::Test ( std::istream &  pStdout,
std::istream &  pStderr 
)

Calls a metric's v_Test function (or v_Generate if m_generate).

Definition at line 67 of file Metric.cpp.

68{
69 if (m_generate)
70 {
71 v_Generate(pStdout, pStderr);
72 return true;
73 }
74 else
75 {
76 return v_Test(pStdout, pStderr);
77 }
78}
virtual bool v_Test(std::istream &pStdout, std::istream &pStderr)=0
Virtual function to test the metric. Should be redefined in derived classes.
virtual void v_Generate(std::istream &pStdout, std::istream &pSrderr)=0
Virtual function to generate the metric. Should be redefined in derived classes.

References m_generate, v_Generate(), and v_Test().

◆ v_Generate()

virtual void Nektar::Metric::v_Generate ( std::istream &  pStdout,
std::istream &  pSrderr 
)
protectedpure virtual

Virtual function to generate the metric. Should be redefined in derived classes.

Parameters
pStdoutReference to test output stream.
pSrderrReference to test error stream.

Implemented in Nektar::MetricEigenvalue, Nektar::MetricExecutionTime, Nektar::MetricFile, Nektar::MetricFileExists, Nektar::MetricL2, Nektar::MetricLInf, Nektar::MetricNoWarning, Nektar::MetricPrecon, Nektar::MetricPyUnitTest, and Nektar::MetricRegex.

Referenced by Test().

◆ v_Test()

virtual bool Nektar::Metric::v_Test ( std::istream &  pStdout,
std::istream &  pStderr 
)
protectedpure virtual

Virtual function to test the metric. Should be redefined in derived classes.

Parameters
pStdoutReference to test output stream.
pStderrReference to test error stream.
Returns
true if the test passes, false otherwise.

Implemented in Nektar::MetricExecutionTime, Nektar::MetricFile, Nektar::MetricFileExists, Nektar::MetricNoWarning, and Nektar::MetricRegex.

Referenced by Test().

Member Data Documentation

◆ m_average

bool Nektar::Metric::m_average = false
protected

Indicates whether a metric supports averaging results from multiple runs.

Definition at line 99 of file Metric.h.

Referenced by Nektar::MetricExecutionTime::MetricExecutionTime(), and SupportsAverage().

◆ m_generate

bool Nektar::Metric::m_generate
protected

◆ m_id

int Nektar::Metric::m_id
protected

Stores the ID of this metric.

Definition at line 92 of file Metric.h.

Referenced by GetID(), and Metric().

◆ m_metric

TiXmlElement* Nektar::Metric::m_metric
protected

◆ m_type

std::string Nektar::Metric::m_type
protected