LRAUV  revA
Reporter.h
Go to the documentation of this file.
1 
11 #ifndef REPORTER_H_
12 #define REPORTER_H_
13 
15 #include "utils/FlexArray.h"
16 #include "data/StrValue.h"
17 
18 template<typename T> class FlexArray;
19 
38 {
39 
40 public:
41 
42  typedef enum
43  {
47  } ReportType;
48 
50  Reporter();
51 
53  virtual void run( void );
54 
55  void addReport( unsigned short int uriCode, ReportType type = REPORT_CHANGE, const Timespan *timespan = NULL );
56  void changeReport( unsigned short int uriCode, ReportType type = REPORT_CHANGE, const Timespan *timespan = NULL );
57  void removeReport( unsigned short int uriCode );
58  void removeAllReports();
59  void listReports();
60 
61 private:
62 
63  // Note that the copy constructor below is private and not given a body.
64  // Any attempt to call it will return a compiler error.
65  Reporter( const Reporter& old ); // disallow copy constructor
66 
68  class ReportItem
69  {
70  public:
72  ReportItem( Component *owner, unsigned short int uriCode, ReportType type = REPORT_CHANGE, const Timespan *timespan = NULL );
73 
74  unsigned short int getUriCode();
76  const Timespan* getTimespan();
77 
78  void setReportType( ReportType type );
79  void setTimespan( const Timespan *timespan );
80 
81  bool needsReporting();
82  bool report( Logger *logger );
83  void reportStatus( Logger * logger );
84 
86  ~ReportItem();
87 
88  private:
89 
90  // Note that the copy constructor below is private and not given a body.
91  // Any attempt to call it will return a compiler error.
92  ReportItem( const ReportItem& old ); // disallow copy constructor
93 
94  bool initDataReader();
95 
96  unsigned short int uriCode_;
99 
104 
105  static const StrValue NO_VALUE;
106  };
107 
110 };
111 
112 #endif /* REPORTER_H_ */
Client-side interface for injecting log data into the log queue.
Definition: Logger.h:30
Component * owner_
Definition: Reporter.h:100
void setTimespan(const Timespan *timespan)
Definition: Reporter.cpp:171
Contains the SyncComponent class definition.
FlexArray< ReportItem * > reportArray_
Definition: Reporter.h:108
Mutex mutex_
Definition: Reporter.h:109
ReportType
Definition: Reporter.h:42
Str oldValue_
Definition: Reporter.h:103
A DataAccessor that reads values from the Slate Contains a default dataValue that must not be NULL...
Definition: DataReader.h:30
bool needsReporting()
Definition: Reporter.cpp:183
void listReports()
Definition: Reporter.cpp:118
Definition: Reporter.h:45
A simple pthread Mutex abstraction.
Definition: Mutex.h:20
Timespan class, represents a delta of time.
Definition: Timestamp.h:248
Timestamp lastReported_
Definition: Reporter.h:102
ReportType type_
Definition: Reporter.h:97
Component responsible for handling periodic logging of variable values to the syslog and the console...
Definition: Reporter.h:37
~ReportItem()
Destructor.
Definition: Reporter.cpp:310
unsigned short int uriCode_
Definition: Reporter.h:96
Contains the FlexArrayBase and FlexArray class declarations.
Contains the StrValue class definition.
const Timespan * getTimespan()
Definition: Reporter.cpp:159
virtual void run(void)
Run the component.
Definition: Reporter.cpp:27
Keeps track of which how we have to report each DataElement.
Definition: Reporter.h:68
static const StrValue NO_VALUE
Definition: Reporter.h:105
void changeReport(unsigned short int uriCode, ReportType type=REPORT_CHANGE, const Timespan *timespan=NULL)
Definition: Reporter.cpp:73
DataReader * dataReader_
Definition: Reporter.h:101
ReportType getReportType()
Definition: Reporter.cpp:153
void addReport(unsigned short int uriCode, ReportType type=REPORT_CHANGE, const Timespan *timespan=NULL)
Definition: Reporter.cpp:46
Replacement for standard template class string.
Definition: Str.h:12
Abstract Base class for software components.
Definition: Component.h:53
ReportItem(Component *owner, unsigned short int uriCode, ReportType type=REPORT_CHANGE, const Timespan *timespan=NULL)
Constructor.
Definition: Reporter.cpp:134
void setReportType(ReportType type)
Definition: Reporter.cpp:165
Reporter()
Constructor for Reporter.
Definition: Reporter.cpp:19
unsigned short int getUriCode()
Definition: Reporter.cpp:147
Simple class providing a flexible size array of pointers.
Definition: DataReader.h:19
void removeReport(unsigned short int uriCode)
Definition: Reporter.cpp:83
bool report(Logger *logger)
Definition: Reporter.cpp:224
Definition: Reporter.h:44
Wraps a string (see Str) as a DataValue, so strings can be written to and read from the slate...
Definition: StrValue.h:34
Timespan timespan_
Definition: Reporter.h:98
bool initDataReader()
Definition: Reporter.cpp:288
Definition: Reporter.h:46
void reportStatus(Logger *logger)
Definition: Reporter.cpp:245
Represents absolute times.
Definition: Timestamp.h:31
Abstract Base class for components that run in the end of the computation cycle, doing logging...
Definition: SyncComponent.h:276
void removeAllReports()
Definition: Reporter.cpp:110