File worldLogger.h

class worldLogger

Subclassed by rodNodeLogger, velocityLogger

Public Functions

worldLogger(std::string fileNamePrefix, std::string logfile_base, std::ofstream &df, int per)

Constructor for a worldLogger

.

worldLogger.cpp

Some minimal definitions for functions in the abstract class worldLogger, mostly related to setup.

Copyright 2020 Andrew P. Sabelhaus and Soft Machines Lab at CMU

Parameters:
  • fileNamePrefix – a string to prepend to the file name

  • logfile_base – the base folder for the logs (actual folder will be organized by year, month, day)

  • df – ref to an ofstream to use to write to the data file

  • per – integer, period to write to log file (only once per this many samples)

worldLogger(std::string fileNamePrefix, std::string file_name_suffix, std::string logfile_base, std::ofstream &df, int per)
~worldLogger()
void setup()

Setup function, separate from constructor, for various tasks that are prevented from taking place before construction, e.g. init-ing the log file. Note, calls a secondary (abstract) function for the children to do whatever else they’d need

void logWorldData()

Log data, used by the caller. Writes to file according to getLogData at period.

void pruneEmptyLog()

For a clean shutdown upon convergence issues, remove a log file that has no data.

Public Members

shared_ptr<world> world_ptr

Protected Functions

void initLogFile()

A helper for initializing the file, so that we can get dynamic binding to functions in the classes which inherit from this.

virtual void setupHelper()

An setup function, to be overridden by childen if desired. Called by setup. Virtual so that derived classes can override.

virtual std::string getLogHeader() = 0
virtual std::string getLogData() = 0
int countLinesInLog()
std::string getTimestamp()
std::string getTimeDateFolderPath()

Protected Attributes

int num_lines_header
std::string m_fileName
std::ofstream &m_dataFile
int period