LRAUV  revA
JsonLogWriter Class Reference

Defines a LogWriter that generates a JSON table of values. More...

#include <JsonLogWriter.h>

Inheritance diagram for JsonLogWriter:
Collaboration diagram for JsonLogWriter:

Public Member Functions

 JsonLogWriter (bool formatted, int varCount, char **varList, char **unitList, int attCount=0, char **attList=NULL)
 Constructor. More...
 
virtual ~JsonLogWriter ()
 Destructor. More...
 
unsigned int writeHeader ()
 Start writing the Json file. More...
 
unsigned int write (const LogEntry *entry, const Unit *unit=NULL)
 Write an entry to the buffer. More...
 
unsigned int writeFooter ()
 Finish writing the Json file. More...
 
- Public Member Functions inherited from FilterLogWriter
 FilterLogWriter (LogWriter *outputTo, int varCount, char **varList, char **unitList, bool passCycleStarts, int attCount=0, char **attList=NULL)
 Constructor. More...
 
virtual ~FilterLogWriter ()
 Destructor. More...
 
virtual void endCycle ()
 Do what needs to be done at the end of the cycle. More...
 
virtual void config (Logger &logger)
 Configure from a config file. More...
 
- Public Member Functions inherited from LogWriter
virtual ~LogWriter ()
 Destructor. More...
 
virtual void setOutStream (OutStream &outStream)
 Sets the OutStream. More...
 
virtual bool isValid ()
 Return true if logStream_ is available. More...
 
void addParent ()
 
void removeParent ()
 
int getParentCount ()
 
virtual void activate ()
 
virtual void deactivate ()
 
virtual bool isActive ()
 
virtual void lockWrites ()
 
virtual void unlockWrites ()
 

Protected Member Functions

virtual unsigned int writeData (const DataEntry *dataEntry, int index, const Unit *unit)
 
virtual unsigned int writeAtt (const DataEntry *dataEntry, int index, const Unit *unit)
 
- Protected Member Functions inherited from FilterLogWriter
virtual void resetInputs ()
 Reset cached input settings. More...
 
void initializeFilterLogWriter ()
 
virtual unsigned int writeCycleStart (const EventEntry *eventEntry)
 
- Protected Member Functions inherited from LogWriter
 LogWriter ()
 Protected constructor for pure virtual class. More...
 
 LogWriter (OutStream &outStream)
 Protected constructor for pure virtual class. More...
 

Private Member Functions

 JsonLogWriter (const JsonLogWriter &old)
 
void initializeJsonLogWriter ()
 Initialize variables, etc. More...
 
void addVar (const int index, const ElementURI *uri, BinaryDataType binaryType, const Unit &unit, short universalCode)
 Add a new variable. More...
 
void setAttValue (const DataEntry *dataEntry, const int attIndex)
 Set an attribute value. More...
 

Private Attributes

cJSON * json_
 
bool jsonLogWriterInitialized_
 
bool finalized_
 
bool formatted_
 
cJSON ** vars_
 
cJSON ** timeVars_
 
const Unit ** units_
 
const ElementURI ** uris_
 

Additional Inherited Members

- Public Types inherited from LogWriter
enum  ServiceType {
  NO_SERVICE = -1, SERVICE_COURIER, SERVICE_EXPRESS, SERVICE_PRIORITY,
  SERVICE_NORMAL, SERVICE_BULK, SERVICE_COUNT, SERVICE_MULTI
}
 
- Static Public Member Functions inherited from LogWriter
static ServiceType Str2ServiceType (const char *const serviceTypeStr, int len=-1)
 
static const char * ServiceType2Str (LogWriter::ServiceType serviceType)
 
static size_t ServiceType2Strlen (LogWriter::ServiceType serviceType)
 
- Static Public Attributes inherited from LogWriter
static const char *const SERVICE_TYPE_STRS [SERVICE_COUNT]
 
static size_t const SERVICE_TYPE_STRLEN [SERVICE_COUNT]
 
- Protected Attributes inherited from FilterLogWriter
LogWriteroutputTo_
 
int varCount_
 
char ** varList_
 
char ** unitList_
 
const Unit ** units_
 
bool passCycleStarts_
 
int attCount_
 
char ** attList_
 
unsigned short * uriCodes_
 
int * codeLookup_
 
unsigned short * attUriCodes_
 
int * attCodeLookup_
 
bool * isUniversal_
 
Timestamp lastTime_
 
bool initializedFilterLogWriter_
 
unsigned int slateElementURICount_
 
- Protected Attributes inherited from LogWriter
OutStreamlogStream_
 Stores an OutStream. More...
 
bool wroteHeader_
 
bool wroteFooter_
 
Mutex writeMutex_
 
int parentCount_
 
bool active_
 

Detailed Description

Defines a LogWriter that generates a JSON table of values.

A list of variable names is supplied to the constructor.

Constructor & Destructor Documentation

JsonLogWriter::JsonLogWriter ( bool  formatted,
int  varCount,
char **  varList,
char **  unitList,
int  attCount = 0,
char **  attList = NULL 
)

Constructor.

Streamless Constructor.

References FilterLogWriter::attCount_, timeVars_, units_, uris_, FilterLogWriter::varCount_, and vars_.

JsonLogWriter::~JsonLogWriter ( )
virtual

Destructor.

References finalized_, json_, timeVars_, units_, uris_, vars_, and writeFooter().

JsonLogWriter::JsonLogWriter ( const JsonLogWriter old)
private

Member Function Documentation

void JsonLogWriter::addVar ( const int  index,
const ElementURI uri,
BinaryDataType  binaryType,
const Unit unit,
short  universalCode 
)
private
void JsonLogWriter::setAttValue ( const DataEntry dataEntry,
const int  attIndex 
)
private

Set an attribute value.

unsigned int JsonLogWriter::write ( const LogEntry entry,
const Unit unit = NULL 
)
virtual
unsigned int JsonLogWriter::writeAtt ( const DataEntry dataEntry,
int  index,
const Unit unit 
)
protectedvirtual

Reimplemented from FilterLogWriter.

References FilterLogWriter::varCount_, and writeData().

unsigned int JsonLogWriter::writeHeader ( )
virtual

Start writing the Json file.

Reimplemented from FilterLogWriter.

Member Data Documentation

bool JsonLogWriter::finalized_
private

Referenced by ~JsonLogWriter().

bool JsonLogWriter::formatted_
private

Referenced by writeFooter().

cJSON* JsonLogWriter::json_
private

Referenced by addVar(), writeFooter(), and ~JsonLogWriter().

bool JsonLogWriter::jsonLogWriterInitialized_
private
cJSON** JsonLogWriter::timeVars_
private
const Unit** JsonLogWriter::units_
private
const ElementURI** JsonLogWriter::uris_
private
cJSON** JsonLogWriter::vars_
private

The documentation for this class was generated from the following files: