INET Framework for OMNeT++/OMNEST
IndicatorTextFigure Class Reference

#include <IndicatorTextFigure.h>

Inheritance diagram for IndicatorTextFigure:
inet::IIndicatorFigure

Public Member Functions

 IndicatorTextFigure (const char *name=nullptr)
 
virtual void setValue (int series, simtime_t timestamp, double value) override
 
virtual const char * getTextFormat () const
 
virtual void setTextFormat (const char *textFormat)
 
- Public Member Functions inherited from inet::IIndicatorFigure
virtual ~IIndicatorFigure ()
 
virtual int getNumSeries () const
 
virtual void refreshDisplay ()
 

Protected Member Functions

virtual const char ** getAllowedPropertyKeys () const override
 
virtual void parse (cProperty *property) override
 
virtual void refresh ()
 

Protected Attributes

std::string textFormat = "%g"
 
double value = NaN
 

Constructor & Destructor Documentation

IndicatorTextFigure::IndicatorTextFigure ( const char *  name = nullptr)
inlineexplicit
41 : cTextFigure(name) {}

Member Function Documentation

const char ** IndicatorTextFigure::getAllowedPropertyKeys ( ) const
overrideprotectedvirtual
30 {
31  static const char *keys[32];
32  if (!keys[0]) {
33  const char *localKeys[] = {
34  PKEY_TEXT_FORMAT, PKEY_INITIAL_VALUE, nullptr
35  };
36  concatArrays(keys, cTextFigure::getAllowedPropertyKeys(), localKeys);
37  }
38  return keys;
39 }
std::vector< K > keys(const std::map< K, V > &m)
Definition: stlutils.h:96
virtual const char* IndicatorTextFigure::getTextFormat ( ) const
inlinevirtual
43 { return textFormat.c_str(); }
std::string textFormat
Definition: IndicatorTextFigure.h:32
void IndicatorTextFigure::parse ( cProperty *  property)
overrideprotectedvirtual
42 {
43  cTextFigure::parse(property);
44 
45  const char *s;
46  if ((s = property->getValue(PKEY_TEXT_FORMAT)) != nullptr)
47  setTextFormat(s);
48  if ((s = property->getValue(PKEY_INITIAL_VALUE)) != nullptr)
49  setValue(0, simTime(), utils::atod(s));
50 }
virtual void setTextFormat(const char *textFormat)
Definition: IndicatorTextFigure.h:44
double atod(const char *s)
Converts string to double.
Definition: INETUtils.cc:38
virtual void setValue(int series, simtime_t timestamp, double value) override
Definition: IndicatorTextFigure.cc:52
value< double, units::s > s
Definition: Units.h:1049
void IndicatorTextFigure::refresh ( )
protectedvirtual
61 {
62  if (std::isnan(value)) {
63  setText("");
64  }
65  else {
66  char buf[64];
67  sprintf(buf, textFormat.c_str(), value);
68  setText(buf);
69  }
70 }
double value
Definition: IndicatorTextFigure.h:33
std::string textFormat
Definition: IndicatorTextFigure.h:32
virtual void IndicatorTextFigure::setTextFormat ( const char *  textFormat)
inlinevirtual
44 { this->textFormat = textFormat; refresh(); }
virtual void refresh()
Definition: IndicatorTextFigure.cc:60
std::string textFormat
Definition: IndicatorTextFigure.h:32
void IndicatorTextFigure::setValue ( int  series,
simtime_t  timestamp,
double  value 
)
overridevirtual

Implements inet::IIndicatorFigure.

53 {
54  // Note: we currently ignore timestamp
55  ASSERT(series == 0);
56  this->value = value;
57  refresh();
58 }
virtual void refresh()
Definition: IndicatorTextFigure.cc:60
double value
Definition: IndicatorTextFigure.h:33

Member Data Documentation

std::string IndicatorTextFigure::textFormat = "%g"
protected
double IndicatorTextFigure::value = NaN
protected

The documentation for this class was generated from the following files: