INET Framework for OMNeT++/OMNEST
inet::IndicatorTextFigure Class Reference

#include <IndicatorTextFigure.h>

Inheritance diagram for inet::IndicatorTextFigure:
inet::IIndicatorFigure

Public Member Functions

 IndicatorTextFigure (const char *name=nullptr)
 
virtual const Point getSize () const override
 
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()

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

Member Function Documentation

◆ getAllowedPropertyKeys()

const char ** inet::IndicatorTextFigure::getAllowedPropertyKeys ( ) const
overrideprotectedvirtual
20 {
21  static const char *keys[32];
22  if (!keys[0]) {
23  const char *localKeys[] = {
24  PKEY_TEXT_FORMAT, PKEY_INITIAL_VALUE, nullptr
25  };
26  concatArrays(keys, cTextFigure::getAllowedPropertyKeys(), localKeys);
27  }
28  return keys;
29 }

◆ getSize()

virtual const Point inet::IndicatorTextFigure::getSize ( ) const
inlineoverridevirtual

Implements inet::IIndicatorFigure.

29 { return Point(0, 0); } // TODO

◆ getTextFormat()

virtual const char* inet::IndicatorTextFigure::getTextFormat ( ) const
inlinevirtual
31 { return textFormat.c_str(); }

◆ parse()

void inet::IndicatorTextFigure::parse ( cProperty *  property)
overrideprotectedvirtual
32 {
33  cTextFigure::parse(property);
34 
35  const char *s;
36  if ((s = property->getValue(PKEY_TEXT_FORMAT)) != nullptr)
38  if ((s = property->getValue(PKEY_INITIAL_VALUE)) != nullptr)
39  setValue(0, simTime(), utils::atod(s));
40 }

◆ refresh()

void inet::IndicatorTextFigure::refresh ( )
protectedvirtual
51 {
52  if (std::isnan(value)) {
53  setText("");
54  }
55  else {
56  char buf[64];
57  sprintf(buf, textFormat.c_str(), value);
58  setText(buf);
59  }
60 }

Referenced by setValue().

◆ setTextFormat()

virtual void inet::IndicatorTextFigure::setTextFormat ( const char *  textFormat)
inlinevirtual
32 { this->textFormat = textFormat; refresh(); }

Referenced by parse().

◆ setValue()

void inet::IndicatorTextFigure::setValue ( int  series,
simtime_t  timestamp,
double  value 
)
overridevirtual

Implements inet::IIndicatorFigure.

43 {
44  // Note: we currently ignore timestamp
45  ASSERT(series == 0);
46  this->value = value;
47  refresh();
48 }

Referenced by parse().

Member Data Documentation

◆ textFormat

std::string inet::IndicatorTextFigure::textFormat = "%g"
protected

Referenced by refresh().

◆ value

double inet::IndicatorTextFigure::value = NaN
protected

Referenced by refresh(), and setValue().


The documentation for this class was generated from the following files:
inet::IndicatorTextFigure::setTextFormat
virtual void setTextFormat(const char *textFormat)
Definition: IndicatorTextFigure.h:32
inet::units::values::s
value< double, units::s > s
Definition: Units.h:1235
inet::utils::atod
double atod(const char *s)
Converts string to double.
Definition: INETUtils.cc:80
inet::keys
std::vector< K > keys(const std::map< K, V > &m)
Definition: stlutils.h:113
inet::IndicatorTextFigure::setValue
virtual void setValue(int series, simtime_t timestamp, double value) override
Definition: IndicatorTextFigure.cc:42
inet::IndicatorTextFigure::refresh
virtual void refresh()
Definition: IndicatorTextFigure.cc:50
inet::IndicatorTextFigure::value
double value
Definition: IndicatorTextFigure.h:20
inet::IndicatorTextFigure::textFormat
std::string textFormat
Definition: IndicatorTextFigure.h:19