CARMA C++
RowVisitor.h
1 #ifndef CARMA_UI_RTD_ROW_VISITOR_H
2 #define CARMA_UI_RTD_ROW_VISITOR_H
3 
4 #include <set>
5 #include <string>
6 
8 #include "carma/ui/rtd/common/MonitorTableVisitor.h"
9 #include "carma/ui/rtd/common/ColorVisitor.h"
11 #include "carma/ui/rtd/common/RtDisplay.h"
12 
13 
14 namespace carma {
15 namespace ui {
16 namespace rtd {
17 
18 
23 
24 // this could have equally been done by adding yet another bool
25 // to the MonitorTableFolder constructor
26 class RowVisitor : public ColorVisitor {
27  public:
28  explicit RowVisitor( CellColor goodColor,
29  CellColor warnColor = YELLOW_CELL_COLOR,
30  CellColor errorColor = RED_CELL_COLOR );
31 
32  virtual ~RowVisitor( );
33 
34  ::std::string generateRowLabel(
35  const monitor::MonitorPoint & mp,
36  bool showUnits ) const;
37 
38 };
39 
40 RowVisitor::RowVisitor( CellColor goodColor,
41  CellColor warnColor,
42  CellColor errorColor)
43 : ColorVisitor( goodColor, warnColor, errorColor )
44 {
45 }
46 
47 RowVisitor::~RowVisitor( )
48 try {
49 } catch ( ... ) {
50  // Just stifle any exception
51 }
52 
53 ::std::string
54 RowVisitor::generateRowLabel( const monitor::MonitorPoint & mp,
55  const bool showUnits ) const
56 {
57  ::std::string rowLabel = mp.getLongName();
58 
59  if ( showUnits ) {
60  const ::std::string units = mp.getUnits();
61 
62  if ( units.empty( ) == false ) {
63  rowLabel += " (";
64  rowLabel += units;
65  rowLabel += ")";
66  }
67  }
68 
69  return rowLabel;
70 }
71 
72 } // namespace carma::ui::rtd
73 } // namespace carma::ui
74 } // namespace carma
75 
76 #endif
Abstract base class for all monitor points.
Cell that takes a MonitorPoint and displays its current value.
Abstract base class for a monitor point.
Definition: MonitorPoint.h:68
enum carma::ui::rtd::CellColorEnum CellColor
Cell color choices.
Visitor that uses the long monitor point names for row labels instead of the short ones...
Definition: RowVisitor.h:26
Visitor that post processes a set of MonitorCell to have good and bad colors set to something other t...
Definition: ColorVisitor.h:19