LRAUV  revA
JsonLogWriter.h
Go to the documentation of this file.
1 
11 #ifndef JSONLOGWRITER_H_
12 #define JSONLOGWRITER_H_
13 
14 #include "data/BinaryDataType.h"
15 #include "logger/FilterLogWriter.h"
16 #include "logger/HasFilename.h"
17 #include "utils/Str.h"
18 #include "../Lib/cJSON/cJSON.h"
19 
20 class DataValue;
21 
29 {
30 public:
31 
33  JsonLogWriter( bool formatted, int varCount, char** varList, char** unitList,
34  int attCount = 0, char** attList = NULL );
35 
37  virtual ~JsonLogWriter();
38 
40  unsigned int writeHeader();
41 
43  unsigned int write( const LogEntry *entry, const Unit* unit = NULL );
44 
46  unsigned int writeFooter();
47 
48 
49 protected:
50 
51  // Override this method to do something special with data entries
52  virtual unsigned int writeData( const DataEntry *dataEntry, int index, const Unit* unit );
53 
54  // Override this method to do something special with attribute entries
55  virtual unsigned int writeAtt( const DataEntry *dataEntry, int index, const Unit* unit );
56 
57 private:
58  // Note that the copy constructor below is private and not given a body.
59  // Any attempt to call it will return a compiler error.
60  JsonLogWriter( const JsonLogWriter& old ); // disallow copy constructor
61 
64 
66  void addVar( const int index, const ElementURI* uri,
67  BinaryDataType binaryType, const Unit& unit,
68  short universalCode );
69 
71  void setAttValue( const DataEntry *dataEntry, const int attIndex );
72 
73  cJSON* json_;
75  bool finalized_;
76  bool formatted_;
77  cJSON** vars_;
78  cJSON** timeVars_;
79  const Unit** units_;
80  const ElementURI** uris_;
81 };
82 
83 #endif /*JSONLOGWRITER_H_*/
Defines a LogWriter that generates a text table of values.
Definition: FilterLogWriter.h:32
cJSON ** vars_
Definition: JsonLogWriter.h:77
BinaryDataType
These are binary type identifiers for serializing and unserializing The syntax below handles up to 16...
Definition: BinaryDataType.h:39
cJSON * json_
Definition: JsonLogWriter.h:73
void setAttValue(const DataEntry *dataEntry, const int attIndex)
Set an attribute value.
bool formatted_
Definition: JsonLogWriter.h:76
JsonLogWriter(bool formatted, int varCount, char **varList, char **unitList, int attCount=0, char **attList=NULL)
Constructor.
Definition: JsonLogWriter.cpp:28
virtual unsigned int writeAtt(const DataEntry *dataEntry, int index, const Unit *unit)
Definition: JsonLogWriter.cpp:173
const Unit ** units_
Definition: JsonLogWriter.h:79
A DataValue is an abstract base class for a data value and associated engineering units of the value...
Definition: DataValue.h:35
virtual unsigned int writeData(const DataEntry *dataEntry, int index, const Unit *unit)
Definition: JsonLogWriter.cpp:95
const ElementURI ** uris_
Definition: JsonLogWriter.h:80
One "entry" in a LogQueue.
Definition: LogEntry.h:33
Code unit that represents an atomic unit of data destined for writing in the log file.
Definition: DataEntry.h:43
virtual ~JsonLogWriter()
Destructor.
Definition: JsonLogWriter.cpp:50
cJSON ** timeVars_
Definition: JsonLogWriter.h:78
unsigned int writeHeader()
Start writing the Json file.
Definition: JsonLogWriter.cpp:63
Simple Interface that contains getFilename() function.
Contains the FilterLogWriter class definition.
void addVar(const int index, const ElementURI *uri, BinaryDataType binaryType, const Unit &unit, short universalCode)
Add a new variable.
Definition: JsonLogWriter.cpp:270
bool finalized_
Definition: JsonLogWriter.h:75
Contains the BinaryDataType enumeration.
Defines a LogWriter that generates a JSON table of values.
Definition: JsonLogWriter.h:28
void initializeJsonLogWriter()
Initialize variables, etc.
Definition: JsonLogWriter.cpp:219
Code unit that represents a unique name for a DataElement.
Definition: ElementURI.h:27
bool jsonLogWriterInitialized_
Definition: JsonLogWriter.h:74
unsigned int writeFooter()
Finish writing the Json file.
Definition: JsonLogWriter.cpp:178
unsigned int write(const LogEntry *entry, const Unit *unit=NULL)
Write an entry to the buffer.
Definition: JsonLogWriter.cpp:68
Code that represents an engineering unit.
Definition: Unit.h:24