LRAUV  revA
LogEntry.h
Go to the documentation of this file.
1 
10 #ifndef LOGENTRY_H_
11 #define LOGENTRY_H_
12 
13 #include "io/InStream.h"
14 #include "io/OutStream.h"
15 #include "logger/Logger.h"
16 #include "utils/Str.h"
17 #include "utils/Timestamp.h"
18 
19 class Logger;
20 class Unit;
21 
33 class LogEntry
34 {
35 public:
36 
38  typedef enum
39  {
45  } Type;
46 
47  static const int TYPE_MASK = 0x0003;
48 
50  virtual ~LogEntry();
51 
53  static LogEntry* Read( Timestamp& timeBase, Timespan& timeAdjust, InStream &inStream, Logger& logger );
54 
56  virtual unsigned int write( Timestamp& timeBase, OutStream& logStream ) const = 0;
57 
59  virtual Str toString( const Unit* unit = NULL ) const = 0;
60 
62  const Timestamp& getTimestamp( void ) const
63  {
64  return timestamp_;
65  };
66 
67  // Techically I shouldn't allow this but it is needed for the
68  // log unserialization
69  const Timestamp& setTimestamp( const Timestamp &newTime )
70  {
71  timestamp_ = newTime;
72  return timestamp_;
73  };
74  const Timestamp& setTimestamp( const double newTime )
75  {
76  timestamp_ = newTime;
77  return timestamp_;
78  };
79 
80  Type getType( void ) const
81  {
82  return type_;
83  };
84 
86  static const char *TypeToString( Type theType );
87 
88 protected:
89 
91  LogEntry( Type myType, const Timestamp& timestamp = Timestamp::NOT_SET_TIME );
92 
93  static bool ReadTimestamp( Timestamp& timestamp, bool& changed, InStream& inStream, Logger& logger, Logger::TimePrecisionType timePrecision );
94 
95  unsigned int writeTimestamp( const Timestamp& timeBase, bool changed, OutStream & logStream, Logger::TimePrecisionType timePrecision ) const;
96 
97 
100 
102 
103  static const Str UNKNOWN;
104 
105 private:
106  // Note that the copy constructor below is private and not given a body.
107  // Any attempt to call it will return a compiler error.
108  LogEntry( const LogEntry& old ); // disallow copy constructor
109 
110 
111 };
112 
113 #endif /*LOGENTRY_H_*/
Client-side interface for injecting log data into the log queue.
Definition: Logger.h:30
static LogEntry * Read(Timestamp &timeBase, Timespan &timeAdjust, InStream &inStream, Logger &logger)
Read in a new entry from a stream.
Definition: LogEntry.cpp:57
static const Str UNKNOWN
Definition: LogEntry.h:103
Type getType(void) const
Definition: LogEntry.h:80
const Timestamp & setTimestamp(const Timestamp &newTime)
Definition: LogEntry.h:69
Type
Defines an enum for "typing" the various LogEntries.
Definition: LogEntry.h:38
virtual ~LogEntry()
Destructor.
Definition: LogEntry.cpp:35
LogEntry(Type myType, const Timestamp &timestamp=Timestamp::NOT_SET_TIME)
Constructor.
Definition: LogEntry.cpp:21
Timespan class, represents a delta of time.
Definition: Timestamp.h:248
Definition: LogEntry.h:41
Timestamp timestamp_
Definition: LogEntry.h:101
Contains the OutStream class declaration.
static const int TYPE_MASK
Definition: LogEntry.h:47
This is a very abstract class that can be implemented by classes that want to receive stream input...
Definition: InStream.h:29
One "entry" in a LogQueue.
Definition: LogEntry.h:33
Definition: LogEntry.h:40
Definition: LogEntry.h:44
unsigned int writeTimestamp(const Timestamp &timeBase, bool changed, OutStream &logStream, Logger::TimePrecisionType timePrecision) const
Definition: LogEntry.cpp:114
static const Timestamp NOT_SET_TIME
Constant value to represent "no time".
Definition: Timestamp.h:37
Definition: LogEntry.h:42
Replacement for standard template class string.
Definition: Str.h:12
virtual Str toString(const Unit *unit=NULL) const =0
Convert payload to Str.
virtual unsigned int write(Timestamp &timeBase, OutStream &logStream) const =0
Send payload to a stream.
Type type_
Stores the type of a given LogEntry.
Definition: LogEntry.h:99
TimePrecisionType
Definition: Logger.h:37
Contains the InStream and NullInStream class declarations.
const Timestamp & getTimestamp(void) const
Accessors.
Definition: LogEntry.h:62
Contains the Logger class definition.
static const char * TypeToString(Type theType)
Convert types to Strs.
Definition: LogEntry.cpp:39
This is a very abstract class that can be implemented by classes that want to send stream output...
Definition: OutStream.h:41
Contains the Timestamp and Timespan class declarations.
Code that represents an engineering unit.
Definition: Unit.h:24
static bool ReadTimestamp(Timestamp &timestamp, bool &changed, InStream &inStream, Logger &logger, Logger::TimePrecisionType timePrecision)
Definition: LogEntry.cpp:82
Represents absolute times.
Definition: Timestamp.h:31
const Timestamp & setTimestamp(const double newTime)
Definition: LogEntry.h:74
Definition: LogEntry.h:43