Scarab Use and API Documentation

Scarab/Library Overview

Scarab/CMake Overview

API_Ref

library

library/authentication

library/authentication/authentication.cc

Defines

SCARAB_API_EXPORTS
namespace scarab

The standard scarab namespace.

Functions

scarab::LOGGER(mtlog, "authentication")
library/authentication/authentication.hh
namespace scarab

The standard scarab namespace.

class authentication
#include <authentication.hh>

Inherits from param_node

Public Functions

authentication(const std::string &a_auth_file, bool a_is_in_user_home = true)
~authentication()
bool load(const std::string &a_auth_file, bool a_is_in_user_home = true)
mv_referrable(std::string, auth_filename)
mv_accessible_noset(bool, is_loaded)

library/logger

library/logger/logger.cc
struct Private

Public Types

typedef std::set<logger *> LoggerSet

Public Functions

void logCout(ELevel level, const string &message, const Location &loc)
void logCerr(ELevel level, const string &message, const Location &loc)

Public Members

const char *fLogger
ELevel fThreshold

Public Static Functions

static LoggerSet *AllLoggers()
static size_t getTimeAbsoluteStr()
static const char *level2Str(ELevel level)
static string level2Color(ELevel level)

Public Static Attributes

mutex sMutex
char sDateTimeFormat
time_t sRawTime
tm *sProcessedTime
char sTimeBuff
bool fColored = true
std::ostream *fOut = &cout
std::ostream *fErr = &cerr
namespace scarab

The standard scarab namespace.

Functions

const string &EndColor()
const string &FatalColor()
const string &ErrorColor()
const string &WarnColor()
const string &InfoColor()
const string &ProgColor()
const string &DebugColor()
const string &TraceColor()
const string &OtherColor()
library/logger/logger.hh

Contains the logger class and macros, based on Kasper’s KLogger class.

Date
Created on: 18.11.2011
Author
Marco Haag marco.haag@kit.edu

Defines

LOGGER_UTILITY_MACROS_
va_num_args(...)
va_num_args_impl(_1, _2, _3, _4, _5, N, ...)
macro_dispatcher(func, ...)
macro_dispatcher_(func, nargs)
macro_dispatcher__(func, nargs)
COLOR_NORMAL
COLOR_BRIGHT
COLOR_FOREGROUND_RED
COLOR_FOREGROUND_GREEN
COLOR_FOREGROUND_YELLOW
COLOR_FOREGROUND_BLUE
COLOR_FOREGROUND_CYAN
COLOR_FOREGROUND_WHITE
COLOR_PREFIX
COLOR_SUFFIX
COLOR_SEPARATOR
__DEFAULT_LOGGER
__LOG_LOCATION
__LOG_LOG_4(I, L, M, O)
__LOG_LOG_3(I, L, M)
__LOG_LOG_2(L, M)
__LOG_LOG_1(M)
__LOG_TRACE_2(I, M)
__LOG_TRACE_1(M)
__LOG_DEBUG_2(I, M)
__LOG_DEBUG_1(M)
__LOG_INFO_2(I, M)
__LOG_INFO_1(M)
__LOG_PROG_2(I, M)
__LOG_PROG_1(M)
__LOG_WARN_2(I, M)
__LOG_WARN_1(M)
__LOG_ERROR_2(I, M)
__LOG_ERROR_1(M)
__LOG_FATAL_2(I, M)
__LOG_FATAL_1(M)
__LOG_ASSERT_3(I, C, M)
__LOG_ASSERT_2(C, M)
__LOG_LOG_ONCE_3(I, L, M)
__LOG_LOG_ONCE_2(L, M)
__LOG_LOG_ONCE_1(M)
__LOG_TRACE_ONCE_2(I, M)
__LOG_TRACE_ONCE_1(M)
__LOG_DEBUG_ONCE_2(I, M)
__LOG_DEBUG_ONCE_1(M)
__LOG_INFO_ONCE_2(I, M)
__LOG_INFO_ONCE_1(M)
__LOG_WARN_ONCE_2(I, M)
__LOG_WARN_ONCE_1(M)
__LOG_ERROR_ONCE_2(I, M)
__LOG_ERROR_ONCE_1(M)
__LOG_FATAL_ONCE_2(I, M)
__LOG_FATAL_ONCE_1(M)
LOGGER(I, K)
LOG(...)
LTRACE(...)
LDEBUG(...)
LINFO(...)
LPROG(...)
LWARN(...)
LERROR(...)
LFATAL(...)
LASSERT(...)
LOG_ONCE(...)
LTRACE_ONCE(...)
LDEBUG_ONCE(...)
LINFO_ONCE(...)
LPROG_ONCE(...)
LWARN_ONCE(...)
LERROR_ONCE(...)
LFATAL_ONCE(...)
namespace scarab

The standard scarab namespace.

class logger
#include <logger.hh>

The scarab logger.

The usage and syntax is inspired by log4j. logger itself uses the log4cxx library if it was available on the system during compiling, otherwise it falls back to std::stream.

The logger output can be configured in a file specified with the environment variable LOGGER_CONFIGURATION (by default log4cxx.properties in the config directory).

In most cases the following macro can be used to instantiate a Logger in your code:

This is equivalent to:

For logging the following macros can be used. The source code location will then automatically included in the output:

Public Types

enum ELevel

Values:

eTrace = 0
eDebug = 1
eInfo = 2
eProg = 3
eWarn = 4
eError = 5
eFatal = 6

Public Functions

logger(const char *name = 0)

Standard constructor assigning a name to the logger instance.

Parameters
  • name: The logger name.

logger(const std::string &name)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

~logger()
bool IsLevelEnabled(ELevel level) const

Check whether a certain log-level is enabled.

Return
Parameters
  • level: The log level

void SetLevel(ELevel level) const

Set a logger’s minimum logging level

Parameters
  • level: The log level

void SetGlobalLevel(ELevel level) const

Set all loggers’ minimum logging level

Parameters
  • level: The log level

void Log(ELevel level, const std::string &message, const Location &loc = Location ())

Log a message with the specified level. Use the macro LOG(logger, level, message).

Parameters
  • level: The log level.
  • message: The message.
  • loc: Source code location (set automatically by the corresponding macro).

void LogTrace(const std::string &message, const Location &loc = Location ())

Log a message at TRACE level. Use the macro LTRACE(logger, message).

Parameters
  • message: The message.
  • loc: Source code location (set automatically by the corresponding macro).

void LogDebug(const std::string &message, const Location &loc = Location ())

Log a message at DEBUG level. Use the macro LDEBUG(logger, message).

Parameters
  • message: The message.
  • loc: Source code location (set automatically by the corresponding macro).

void LogInfo(const std::string &message, const Location &loc = Location ())

Log a message at INFO level. Use the macro LINFO(logger, message).

Parameters
  • message: The message.
  • loc: Source code location (set automatically by the corresponding macro).

void LogProg(const std::string &message, const Location &loc = Location ())

Log a message at PROG level. Use the macro PROG(logger, message).

Parameters
  • message: The message.
  • loc: Source code location (set automatically by the corresponding macro).

void LogWarn(const std::string &message, const Location &loc = Location ())

Log a message at WARN level. Use the macro LWARN(logger, message).

Parameters
  • message: The message.
  • loc: Source code location (set automatically by the corresponding macro).

void LogError(const std::string &message, const Location &loc = Location ())

Log a message at ERROR level. Use the macro LERROR(logger, message).

Parameters
  • message: The message.
  • loc: Source code location (set automatically by the corresponding macro).

void LogFatal(const std::string &message, const Location &loc = Location ())

Log a message at FATAL level. Use the macro FATAL(logger, message).

Parameters
  • message: The message.
  • loc: Source code location (set automatically by the corresponding macro).

Public Static Functions

static logger &GetRootLogger()
void SetColored(bool flag)

Set whether colored text will be used

Parameters
  • flag: Bool determining whether colored text will be used

void SetOutStream(std::ostream *stream)

Set the ostream pointer used for standard output messages

Parameters
  • stream: Stream object for standard output

void SetErrStream(std::ostream *stream)

Set the ostream pointer used for standard error messages

Parameters
  • stream: Stream object for standard errors

Private Members

Private *fPrivate
struct Location
#include <logger.hh>

A simple struct used by the Logger macros to pass information about the filename and line number. Not to be used directly by the user!

Public Functions

Location(const char *const fileName = "", const char *const functionName = "", int lineNumber = -1)

Public Members

int fLineNumber
std::string fFileName
std::string fFunctionName

library/param

library/param/configurator.cc
namespace scarab

The standard scarab namespace.

Functions

scarab::LOGGER(slog, "configurator")
library/param/configurator.hh
namespace scarab

The standard scarab namespace.

class configurator
#include <configurator.hh>

Public Functions

configurator(int an_argc, char **an_argv, scarab::param_node *a_default = NULL)
~configurator()
const std::string &exe_name() const
scarab::param_node &config()
const scarab::param_node &config() const
bool help_flag() const
bool version_flag() const
template <typename XReturnType>
XReturnType get(const std::string &a_name) const
template <typename XReturnType>
XReturnType get(const std::string &a_name, XReturnType a_default) const

Private Members

std::string f_exe_name
scarab::param_node *f_master_config
bool f_help_flag
bool f_version_flag
scarab::param *f_param_buffer
std::string f_string_buffer
library/param/global_config.cc
namespace scarab

The standard scarab namespace.

library/param/global_config.hh
namespace scarab

The standard scarab namespace.

class global_config
#include <global_config.hh>

Inherits from singleton< global_config >

Public Functions

void set_config(const param_node &a_config)
const param_node &retrieve() const

Protected Functions

global_config()
~global_config()

Private Members

param_node f_config

Friends

friend scarab::scarab::singleton< global_config >
friend scarab::scarab::destroyer< global_config >
library/param/param.cc

Defines

SCARAB_API_EXPORTS
namespace scarab

The standard scarab namespace.

Functions

SCARAB_API std::ostream & operator<<(std::ostream & out, const param & a_value)
SCARAB_API std::ostream & operator<<(std::ostream & out, const param_value & a_value)
SCARAB_API std::ostream & operator<<(std::ostream & out, const param_array & a_value)
SCARAB_API std::ostream & operator<<(std::ostream & out, const param_node & a_value)
library/param/param.hh
namespace scarab

The standard scarab namespace.

Functions

template <>
template<>
std::string get<std::string>() const
template <>
template<>
scarab::path get<scarab::path>() const
class param
#include <param.hh>

Subclassed by param_array, param_node, param_value

Public Functions

param()
param(const param &orig)
~param()
param *clone() const
bool is_null() const
bool is_value() const
bool is_array() const
bool is_node() const
bool has_subset(const param &a_subset) const
param_value &as_value()
param_array &as_array()
param_node &as_node()
const param_value &as_value() const
const param_array &as_array() const
const param_node &as_node() const
const param_value &operator()() const

Assumes that the parameter is a value, and returns a reference to itself.

param_value &operator()()

Assumes that the parameter is a value, and returns a reference to itself.

const param &operator[](unsigned a_index) const

Assumes that the parameter is an array, and returns a reference to the KTParam at aIndex. Behavior is undefined if aIndex is out-of-range.

param &operator[](unsigned a_index)

Assumes that the parameter is an array, and returns a reference to the KTParam at aIndex. Behavior is undefined if aIndex is out-of-range.

const param &operator[](const std::string &a_name) const

Assumes that the parameter is a node, and returns a reference to the KTParam corresponding to aName. Throws an KTException if aName is not present.

param &operator[](const std::string &a_name)

Assumes that the parameter is a node, and returns a reference to the KTParam corresponding to aName. Adds a new Value if aName is not present.

std::string to_string() const

Public Static Attributes

SCARAB_API unsigned s_indent_level = 0
class param_array
#include <param.hh>

Inherits from param

Public Types

typedef std::deque<param *> contents
typedef contents::iterator iterator
typedef contents::const_iterator const_iterator
typedef contents::reverse_iterator reverse_iterator
typedef contents::const_reverse_iterator const_reverse_iterator
typedef contents::value_type contents_type

Public Functions

param_array()
param_array(const param_array &orig)
~param_array()
param_array &operator=(const param_array &rhs)
param *clone() const
bool is_null() const
bool is_array() const
bool has_subset(const param &a_subset) const
unsigned size() const
bool empty() const
void resize(unsigned a_size)

sets the size of the array if smaller than the current size, extra elements are deleted

std::string get_value(unsigned a_index) const

Returns the result of ParamValue::get if a_name is present and is of type ParamValue Throws an error if a_name is not present or is not of type ParamValue

template <typename XValType>
XValType get_value(unsigned a_index) const

Returns the result of ParamValue::get if a_name is present and is of type ParamValue Throws an error if a_name is not present or is not of type ParamValue

std::string get_value(unsigned a_index, const std::string &a_default) const

Returns the result of ParamValue::get if a_name is present and is of type ParamValue Returns a_default if a_name is not present or is not of type ParamValue

std::string get_value(unsigned a_index, const char *a_default) const
template <typename XValType>
XValType get_value(unsigned a_index, XValType a_default) const

Returns the result of ParamValue::get if a_name is present and is of type ParamValue Returns a_default if a_name is not present or is not of type ParamValue

const param *at(unsigned a_index) const

Returns a pointer to the param corresponding to a_name. Returns NULL if a_name is not present.

param *at(unsigned a_index)

Returns a pointer to the param corresponding to a_name. Returns NULL if a_name is not present.

const param_value *value_at(unsigned a_index) const

Returns a pointer to the param_value (static-ly cast) corresponding to a_name. Returns NULL if a_name is not present.

param_value *value_at(unsigned a_index)

Returns a pointer to the param_value (static-ly cast) corresponding to a_name. Returns NULL if a_name is not present.

const param_array *array_at(unsigned a_index) const

Returns a pointer to the param_array (static-ly cast) corresponding to a_name. Returns NULL if a_name is not present.

param_array *array_at(unsigned a_index)

Returns a pointer to the param_array (static-ly cast) corresponding to a_name. Returns NULL if a_name is not present.

const param_node *node_at(unsigned a_index) const

Returns a pointer to the param_node (static-ly cast) corresponding to a_name. Returns NULL if a_name is not present.

param_node *node_at(unsigned a_index)

Returns a pointer to the param_node (static-ly cast) corresponding to a_name. Returns NULL if a_name is not present.

const param &operator[](unsigned a_index) const

Returns a reference to the param at a_index. Behavior is undefined if a_index is out-of-range.

param &operator[](unsigned a_index)

Returns a reference to the param at a_index. Behavior is undefined if a_index is out-of-range.

const param *front() const
param *front()
const param *back() const
param *back()
void assign(unsigned a_index, const param &a_value)
void assign(unsigned a_index, param *a_value_ptr)
void push_back(const param &a_value)
void push_back(param *a_value_ptr)
void push_front(const param &a_value)
void push_front(param *a_value_ptr)
void append(const param_array &an_array)
void erase(unsigned a_index)
param *remove(unsigned a_index)
void clear()
param_array::iterator begin()
param_array::const_iterator begin() const
param_array::iterator end()
param_array::const_iterator end() const
param_array::reverse_iterator rbegin()
param_array::const_reverse_iterator rbegin() const
param_array::reverse_iterator rend()
param_array::const_reverse_iterator rend() const
std::string to_string() const

Protected Attributes

contents f_contents
class param_node
#include <param.hh>

Inherits from param

Subclassed by authentication, parsable, parser

Public Types

typedef std::map<std::string, param *> contents
typedef contents::iterator iterator
typedef contents::const_iterator const_iterator
typedef contents::value_type contents_type

Public Functions

param_node()
param_node(const param_node &orig)
~param_node()
param_node &operator=(const param_node &rhs)
param *clone() const
bool is_null() const
bool is_node() const
bool has_subset(const param &a_subset) const
unsigned size() const
bool empty() const
bool has(const std::string &a_name) const
unsigned count(const std::string &a_name) const
std::string get_value(const std::string &a_name) const

Returns the result of ParamValue::get if a_name is present and is of type ParamValue Throws an error if a_name is not present or is not of type ParamValue

template <typename XValType>
XValType get_value(const std::string &a_name) const

Returns the result of ParamValue::get if a_name is present and is of type ParamValue Throws an error if a_name is not present or is not of type ParamValue

std::string get_value(const std::string &a_name, const std::string &a_default) const

Returns the result of ParamValue::get if a_name is present and is of type ParamValue Returns a_default if a_name is not present or is not of type ParamValue

std::string get_value(const std::string &a_name, const char *a_default) const
template <typename XValType>
XValType get_value(const std::string &a_name, XValType a_default) const

Returns the result of ParamValue::get if a_name is present and is of type ParamValue Returns a_default if a_name is not present or is not of type ParamValue

const param *at(const std::string &a_name) const

Returns a pointer to the param corresponding to a_name. Returns NULL if a_name is not present.

param *at(const std::string &a_name)

Returns a pointer to the param corresponding to a_name. Returns NULL if a_name is not present.

const param_value *value_at(const std::string &a_name) const
param_value *value_at(const std::string &a_name)
const param_array *array_at(const std::string &a_name) const
param_array *array_at(const std::string &a_name)
const param_node *node_at(const std::string &a_name) const
param_node *node_at(const std::string &a_name)
const param &operator[](const std::string &a_name) const

Returns a reference to the param corresponding to a_name. Throws an error if a_name is not present.

param &operator[](const std::string &a_name)

Returns a reference to the param corresponding to a_name. Adds a new value if a_name is not present.

bool add(const std::string &a_name, const param &a_value)

creates a copy of a_value

bool add(const std::string &a_name, param *a_value_ptr)

directly adds (without copying) a_value_ptr

void replace(const std::string &a_name, const param &a_value)

creates a copy of a_value

void replace(const std::string &a_name, param *a_value_ptr)

directly adds (without copying) a_value_ptr

void merge(const param_node &a_object)

Merges the contents of a_object into this object. If names in the contents of a_object exist in this object, the values in this object corresponding to the matching names will be replaced.

void erase(const std::string &a_name)
param *remove(const std::string &a_name)
void clear()
param_node::iterator begin()
param_node::const_iterator begin() const
param_node::iterator end()
param_node::const_iterator end() const
std::string to_string() const

Protected Attributes

contents f_contents
class param_value
#include <param.hh>

Inherits from param

Public Functions

param_value()
param_value(bool a_value)
param_value(uint8_t a_value)
param_value(uint16_t a_value)
param_value(uint32_t a_value)
param_value(uint64_t a_value)
param_value(int8_t a_value)
param_value(int16_t a_value)
param_value(int32_t a_value)
param_value(int64_t a_value)
param_value(float a_value)
param_value(double a_value)
param_value(const std::string &a_value)
param_value(const char *a_value)
param_value(const param_value &orig)
~param_value()
param_value &operator=(const param_value &rhs)
param *clone() const
bool empty() const
bool is_null() const
bool is_value() const
bool has_subset(const param &a_subset) const
std::string type() const
bool is_bool() const
bool is_uint() const
bool is_int() const
bool is_double() const
bool is_string() const
bool as_bool() const
uint64_t as_uint() const
int64_t as_int() const
double as_double() const
const string &as_string() const
path as_path() const
template <typename XValType>
XValType get() const
void set(bool a_value)
void set(uint8_t a_value)
void set(uint16_t a_value)
void set(uint32_t a_value)
void set(uint64_t a_value)
void set(int8_t a_value)
void set(int16_t a_value)
void set(int32_t a_value)
void set(int64_t a_value)
void set(float a_value)
void set(double a_value)
void set(const std::string &a_value)
void set(const char *a_value)
std::string to_string() const
void clear()
template <>
bool get() const
template <>
uint64_t get() const
template <>
int64_t get() const
template <>
double get() const

Private Types

enum ValueTypes

Values:

k_bool
k_uint
k_int
k_double
k_string
k_invalid

Private Members

union scarab::param_value::Values f_value
scarab::param_value::ValueTypes f_value_type
std::string f_buffer
union Values

Public Members

bool f_bool
uint64_t f_uint
int64_t f_int
double f_double
std::string *f_string
library/param/param_codec.cc

Defines

SCARAB_API_EXPORTS

Functions

LOGGER(slog, "param_codec")
namespace scarab

The standard scarab namespace.

library/param/param_codec.hh

Defines

REGISTER_PARAM_INPUT_CODEC(codec_class, encoding)
REGISTER_PARAM_OUTPUT_CODEC(codec_class, encoding)
namespace scarab

The standard scarab namespace.

class param_input_codec
#include <param_codec.hh>

Subclassed by param_input_json, param_input_yaml

Public Functions

param_input_codec()
~param_input_codec()
virtual param *read_file(const std::string &a_filename, const param_node *a_options = nullptr) = 0
virtual param *read_string(const std::string &a_string, const param_node *a_options = nullptr) = 0
class param_output_codec
#include <param_codec.hh>

Subclassed by param_output_json, param_output_yaml

Public Functions

param_output_codec()
~param_output_codec()
virtual bool write_file(const param &a_param, const std::string &a_filename, const param_node *a_options = nullptr) = 0
virtual bool write_string(const param &a_param, std::string &a_string, const param_node *a_options = nullptr) = 0
class param_translator
#include <param_codec.hh>

Public Functions

param_translator()
~param_translator()
param *read_file(const std::string &a_filename, const param_node *a_options = nullptr)
param *read_string(const std::string &a_string, const param_node *a_options = nullptr)
bool write_file(const param &a_param, const std::string &a_filename, const param_node *a_options = nullptr)
bool write_string(const param &a_param, std::string &a_string, const param_node *a_options = nullptr)
library/param/parsable.cc

Defines

SCARAB_API_EXPORTS
namespace scarab

The standard scarab namespace.

Functions

scarab::LOGGER(dlog, "parsable")
library/param/parsable.hh
namespace scarab

The standard scarab namespace.

class parsable
#include <parsable.hh>

Inherits from param_node

Public Functions

parsable()
parsable(const std::string &a_addr_with_value)
parsable(const std::string &a_addr, const std::string &a_value)
parsable(const parsable &a_orig)
~parsable()

Public Static Attributes

const char f_value_separator = '='
const char f_node_separator = '.'

Private Functions

void add_next(param_node *a_parent, const std::string &a_addr, const std::string &a_value)
library/param/parser.cc

Defines

SCARAB_API_EXPORTS
namespace scarab

The standard scarab namespace.

library/param/parser.hh
namespace scarab

The standard scarab namespace.

class parser
#include <parser.hh>

Inherits from param_node

Public Functions

parser(int an_argc, char **an_argv)
~parser()
void parse(int an_argc, char **an_argv)
library/param/codec
library/param/codec/json
library/param/codec/json/param_json.cc

Defines

SCARAB_API_EXPORTS
namespace scarab

The standard scarab namespace.

Functions

scarab::LOGGER(dlog, "param")
scarab::REGISTER_PARAM_INPUT_CODEC(param_input_json, "json")
scarab::REGISTER_PARAM_OUTPUT_CODEC(param_output_json, "json")
library/param/codec/json/param_json.hh
namespace scarab

The standard scarab namespace.

Functions

scarab::LOGGER(dlog_param_json, "param_json")
class param_input_json
#include <param_json.hh>

Convert JSON to Param.

Options: None

Author
N.S. Oblath

Inherits from param_input_codec

Public Functions

param_input_json()
~param_input_json()
param *read_file(const std::string &a_filename, const param_node *a_options = nullptr)
param *read_string(const std::string &a_json_str, const param_node *a_options = nullptr)
param_node *read_document(const rapidjson::Document &a_document)
param *read_value(const rapidjson::Value &a_value)
class param_output_json
#include <param_json.hh>

Convert Param to JSON.

Options:

Author
N.S. Oblath

Inherits from param_output_codec

Public Types

enum json_writing_style

Values:

k_compact = 0
k_pretty = 1
typedef rapidjson::Writer<rapidjson::FileWriteStream> rj_file_writer
typedef rapidjson::PrettyWriter<rapidjson::FileWriteStream> rj_pretty_file_writer
typedef rapidjson::Writer<rapidjson::StringBuffer> rj_string_writer
typedef rapidjson::PrettyWriter<rapidjson::StringBuffer> rj_pretty_string_writer

Public Functions

param_output_json()
~param_output_json()
bool write_file(const param &a_to_write, const std::string &a_filename, const param_node *a_options = nullptr)
bool write_string(const param &a_to_write, std::string &a_string, const param_node *a_options = nullptr)
template <class XWriter>
bool write_param(const param &a_to_write, XWriter *a_writer)
template <class XWriter>
bool write_param_null(const param &a_to_write, XWriter *a_writer)
template <class XWriter>
bool write_param_value(const param_value &a_to_write, XWriter *a_writer)
template <class XWriter>
bool write_param_array(const param_array &a_to_write, XWriter *a_writer)
template <class XWriter>
bool write_param_node(const param_node &a_to_write, XWriter *a_writer)
library/param/codec/msgpack
library/param/codec/msgpack/param_msgpack.cc

Defines

SCARAB_API_EXPORTS
namespace scarab

The standard scarab namespace.

Functions

scarab::LOGGER(dlog, "param_msgpack")
library/param/codec/msgpack/param_msgpack.hh
namespace scarab

The standard scarab namespace.

Functions

scarab::LOGGER(dlog_param_msgpack, "param_msgpack")
class param_input_msgpack
#include <param_msgpack.hh>

Public Functions

param_input_msgpack()
~param_input_msgpack()

Public Static Functions

static param *read_file(const std::string &a_filename)
param *read_string(const std::string &a_msgpack_str)
param *read_msgpack_element(const msgpack::object &a_msgpack_array)
class param_output_msgpack
#include <param_msgpack.hh>

Public Types

enum json_writing_style

Values:

k_compact
k_pretty

Public Functions

param_output_msgpack()
~param_output_msgpack()

Public Static Functions

static bool write_file(const param &a_to_write, const std::string &a_filename, json_writing_style a_style)
bool write_string(const param &a_to_write, std::string &a_string, json_writing_style a_style)
template <class XWriter>
bool write_param(const param &a_to_write, XWriter *a_writer)
template <class XWriter>
bool write_param_null(const param &a_to_write, XWriter *a_writer)
template <class XWriter>
bool write_param_value(const param_value &a_to_write, XWriter *a_writer)
template <class XWriter>
bool write_param_array(const param_array &a_to_write, XWriter *a_writer)
template <class XWriter>
bool write_param_node(const param_node &a_to_write, XWriter *a_writer)
library/param/codec/yaml
library/param/codec/yaml/param_yaml.cc

Defines

SCARAB_API_EXPORTS
namespace scarab

The standard scarab namespace.

Functions

scarab::LOGGER(slog, "param_yaml")
scarab::REGISTER_PARAM_INPUT_CODEC(param_input_yaml, "yaml")
scarab::REGISTER_PARAM_OUTPUT_CODEC(param_output_yaml, "yaml")
library/param/codec/yaml/param_yaml.hh
namespace scarab

The standard scarab namespace.

class param_input_yaml
#include <param_yaml.hh>

Convert YAML to Param.

Options: None

Author
N.S. Oblath

Inherits from param_input_codec

Public Functions

param_input_yaml()
~param_input_yaml()
param *read_file(const std::string &a_filename, const param_node *a_options = nullptr)
param *read_string(const std::string &a_json_str, const param_node *a_options = nullptr)
param *read_node_type(const YAML::Node &a_node)
param_array *sequence_handler(const YAML::Node &a_node)
param_node *map_handler(const YAML::Node &a_node)
param_value *scalar_handler(const YAML::Node &a_node)
class param_output_yaml
#include <param_yaml.hh>

Convert YAMl to JSON.

Options: None

Author
N.S. Oblath

Inherits from param_output_codec

Public Functions

param_output_yaml()
~param_output_yaml()
bool write_file(const param &a_to_write, const std::string &a_filename, const param_node *a_options = nullptr)
bool write_string(const param &a_to_write, std::string &a_string, const param_node *a_options = nullptr)
YAML::Node check_param_type(const param &a_to_write)
YAML::Node param_node_handler(const param &a_to_write)
YAML::Node param_array_handler(const param &a_to_write)
YAML::Node param_value_handler(const param &a_to_write)

library/test

library/test/test__member_variables.cc

Functions

int main()
library/test/test__member_variables.hh

Defines

set_prefix
get_prefix
var_prefix
static_prefix
struct test_acc
#include <test__member_variables.hh>

Public Functions

mv_accessible_noset(int, mv_acc_ns_int)
struct test_acc_static
#include <test__member_variables.hh>

Public Functions

mv_accessible_static_noset(int, mv_acc_ns_int)
struct test_acc_mutable
#include <test__member_variables.hh>

Public Functions

mv_accessible_mutable_noset(int, mv_acc_ns_int)
struct test_ref
#include <test__member_variables.hh>

Public Functions

mv_referrable_const(int, mv_ref_c_int)
struct test_ptr
#include <test__member_variables.hh>

Public Functions

mv_assignable_noset(int, mv_ptr_ns_int)
struct test_ptr_static
#include <test__member_variables.hh>

Public Functions

mv_assignable_static_noset(int, mv_ptr_ns_int)
struct test_ptr_mutable
#include <test__member_variables.hh>

Public Functions

mv_assignable_mutable_noset(int, mv_ptr_ns_int)
struct test_shptr
#include <test__member_variables.hh>

Public Functions

mv_shared_ptr_const(int, mv_shptr_c_int)
struct test_atm
#include <test__member_variables.hh>

Public Functions

mv_atomic_noset(int, mv_atm_ns_int)
struct test_atm_static
#include <test__member_variables.hh>

Public Functions

mv_atomic_static_noset(int, mv_atm_ns_int)
struct test_atm_mutable
#include <test__member_variables.hh>

Public Functions

mv_atomic_mutable_noset(int, mv_atm_ns_int)
library/test/test_configurator.cc

Functions

LOGGER(conflog, "test_configurator")
int main(int argc, char **argv)
library/test/test_logger.cc

Functions

LOGGER(tlog, "test_logger")
int main()
library/test/test_yaml.cc

Functions

LOGGER(slog, "test_yaml")
int main(int argc, char **argv)

library/utility

library/utility/_member_variables.hh

Defines

get_fcn(x_variable)

Templates for macros for class member variables

Types of variables:

  • ”normal”
  • referrable (i.e. accessed by reference)
  • pointers
  • std::shared_ptr
  • std::atomic

Variations:

  • no set (non-const) accessor
  • static
  • mutable

How to use this file:

  1. Create the include file that will be used (see e.g. member_variables.hh)
  2. Add include guards
  3. Define set_prefix, get_prefix, var_prefix, and static_prefix
  4. #include this file

Macros that must be defined to use this file:

  • set_prefix: the prefix for set accessor functions (e.g. set_)
  • get_prefix: the prefix for get accessor functions (e.g. get_)
  • var_prefix: the prefix for variables (e.g. f_)
  • static_prefix: the prefix for static variables (e.g. s_)

Accessors for normal variables, pointers, and atomics are of the form [set_prefix][variable name] and [get_prefix][variable_name]. Accessors for referrable variables and shared_ptr’s are of the form [variable name], both const and non-const

set_fcn(x_variable)
var_name(x_variable)
static_var_name(x_variable)
mv_accessible_noset(x_type, x_variable)
mv_accessible(x_type, x_variable)
mv_accessible_static_noset(x_type, x_variable)
mv_accessible_static(x_type, x_variable)
mv_accessible_mutable_noset(x_type, x_variable)
mv_accessible_mutable(x_type, x_variable)
mv_referrable_const(x_type, x_variable)
mv_referrable(x_type, x_variable)
mv_referrable_static(x_type, x_variable)
mv_referrable_mutable(x_type, x_variable)
mv_assignable_noset(x_type, x_variable)
mv_assignable(x_type, x_variable)
mv_assignable_static_noset(x_type, x_variable)
mv_assignable_static(x_type, x_variable)
mv_assignable_mutable_noset(x_type, x_variable)
mv_assignable_mutable(x_type, x_variable)
mv_shared_ptr_const(x_type, x_variable)
mv_shared_ptr(x_type, x_variable)
mv_shared_ptr_static(x_type, x_variable)
mv_shared_ptr_mutable(x_type, x_variable)
mv_atomic_noset(x_type, x_variable)
mv_atomic(x_type, x_variable)
mv_atomic_static_noset(x_type, x_variable)
mv_atomic_static(x_type, x_variable)
mv_atomic_mutable_noset(x_type, x_variable)
mv_atomic_mutable(x_type, x_variable)
library/utility/cancelable.cc
namespace scarab

The standard scarab namespace.

Functions

scarab::LOGGER(slog, "cancelable")
library/utility/cancelable.hh
namespace scarab

The standard scarab namespace.

class cancelable
#include <cancelable.hh>

Public Functions

cancelable()
~cancelable()
void cancel()

asynchronous cancel function

void reset_cancel()

reset to non-canceled state

bool is_canceled() const

check canceled state

Protected Attributes

std::atomic<bool> f_canceled

Private Functions

void do_cancellation()
void do_reset_cancellation()
library/utility/concurrent_queue.hh
namespace scarab

The standard scarab namespace.

Functions

scarab::LOGGER(slog_cq, "concurrent_queue")
template <class XDataType>
class concurrent_queue
#include <concurrent_queue.hh>

Public Types

typedef std::deque<XDataType> queue
typedef std::unique_lock<std::mutex> cq_lock

Public Functions

concurrent_queue()
virtual ~concurrent_queue()
void push(XDataType const &a_data)
bool empty() const
bool size() const
bool try_pop(XDataType &a_popped_value)
bool wait_and_pop(XDataType &a_popped_value)
bool timed_wait_and_pop(XDataType &a_popped_value)
void interrupt()
unsigned get_timeout() const
void set_timeout(unsigned a_duration)

Private Members

queue f_queue
bool f_interrupt
std::chrono::milliseconds f_timeout
std::mutex f_mutex

Timeout duration in milliseconds.

std::condition_variable f_condition_var
struct queue_not_empty
#include <concurrent_queue.hh>

Public Functions

queue_not_empty(queue &a_queue)
bool operator()() const

Public Members

queue &f_queue
library/utility/destroyer.hh
namespace scarab

The standard scarab namespace.

template <class XDoomed>
class destroyer
#include <destroyer.hh>

Public Functions

destroyer(XDoomed *d = 0)
~destroyer()
void set_doomed(XDoomed *d)

Private Functions

destroyer(const destroyer<XDoomed>&)
void operator=(const destroyer<XDoomed>&)

Private Members

XDoomed *f_doomed
library/utility/digital.cc

Defines

SCARAB_API_EXPORTS
namespace scarab

The standard scarab namespace.

Functions

SCARAB_API void get_calib_params(unsigned n_bits, unsigned data_type_size, double v_offset, double v_range, bool bits_r_aligned, dig_calib_params * params)
SCARAB_API void get_calib_params2(unsigned n_bits, unsigned data_type_size, double v_offset, double v_range, double dac_gain, bool bits_r_aligned, dig_calib_params * params)
library/utility/digital.hh
namespace scarab

The standard scarab namespace.

Functions

template <typename dig_type, typename an_type>
an_type d2a(dig_type dig, const struct dig_calib_params *params)
template <typename an_type, typename dig_type>
dig_type a2d(an_type analog, const struct dig_calib_params *params)
struct dig_calib_params
#include <digital.hh>

Public Members

unsigned bit_depth
unsigned levels
unsigned data_type_size
double v_range
double v_offset
double inv_levels
double inv_v_range
double dac_gain
bool bits_right_aligned
library/utility/error.cc

Defines

SCARAB_API_EXPORTS
namespace scarab

The standard scarab namespace.

library/utility/error.hh
namespace scarab

The standard scarab namespace.

class error
#include <error.hh>

Inherits from exception

Public Functions

error()
error(const error &an_error)
~error()
template <class x_streamable>
error &operator<<(x_streamable a_fragment)
error &operator<<(const std::string &a_fragment)
error &operator<<(const char *a_fragment)
const char *what() const

Private Members

std::string f_error
library/utility/factory.hh
namespace scarab

The standard scarab namespace.

Functions

scarab::LOGGER(slog_fact, "factory")
template <class XBaseType, typename… XArgs>
class base_registrar
#include <factory.hh>

Public Functions

base_registrar()
virtual ~base_registrar()

Protected Functions

virtual XBaseType *create(XArgs... args) const = 0

Friends

friend scarab::factory< XBaseType, XArgs... >
template <class XBaseType>
template<>
class base_registrar<XBaseType, void>
#include <factory.hh>

Public Functions

base_registrar()
virtual ~base_registrar()

Protected Functions

virtual XBaseType *create() const = 0

Friends

friend scarab::factory< XBaseType >
template <class XBaseType, typename… XArgs>
class factory
#include <factory.hh>

Inherits from singleton< factory< XBaseType, XArgs… > >

Public Types

typedef std::map<std::string, const base_registrar<XBaseType, XArgs...> *> FactoryMap
typedef FactoryMap::value_type FactoryEntry
typedef FactoryMap::iterator FactoryIt
typedef FactoryMap::const_iterator FactoryCIt

Public Functions

XBaseType *create(const std::string &a_class_name, XArgs... args)
XBaseType *create(const FactoryCIt &iter, XArgs... args)
void register_class(const std::string &a_class_name, const base_registrar<XBaseType, XArgs...> *base_registrar)
bool has_class(const std::string &a_class_name) const
void remove_class(const std::string &a_class_name)
factory<XBaseType, XArgs...>::FactoryCIt begin() const
factory<XBaseType, XArgs...>::FactoryCIt end() const

Protected Functions

allow_singleton_access(factory)
factory()
~factory()

Protected Attributes

FactoryMap *fMap
std::mutex f_factory_mutex
template <class XBaseType>
template<>
class factory<XBaseType, void>
#include <factory.hh>

Inherits from singleton< factory< XBaseType > >

Public Types

typedef std::map<std::string, const base_registrar<XBaseType> *> FactoryMap
typedef FactoryMap::value_type FactoryEntry
typedef FactoryMap::iterator FactoryIt
typedef FactoryMap::const_iterator FactoryCIt

Public Functions

XBaseType *create(const std::string &a_class_name)
XBaseType *create(const FactoryCIt &iter)
void register_class(const std::string &a_class_name, const base_registrar<XBaseType> *base_registrar)
bool has_class(const std::string &a_class_name) const
void remove_class(const std::string &a_class_name)
factory<XBaseType, void>::FactoryCIt begin() const
factory<XBaseType, void>::FactoryCIt end() const

Protected Functions

factory()
~factory()

Protected Attributes

FactoryMap *fMap
std::mutex f_factory_mutex

Friends

friend scarab::singleton< factory >
friend scarab::destroyer< factory >
template <class XBaseType, class XDerivedType, typename… XArgs>
class registrar
#include <factory.hh>

Inherits from base_registrar< XBaseType, XArgs… >

Public Functions

registrar(const std::string &a_class_name)
~registrar()

Protected Functions

void register_class(const std::string &a_class_name) const
XBaseType *create(XArgs... args) const

Protected Attributes

std::string f_class_name
template <class XBaseType, class XDerivedType>
template<>
class registrar<XBaseType, XDerivedType, void>
#include <factory.hh>

Inherits from base_registrar< XBaseType >

Public Functions

registrar(const std::string &a_class_name)
~registrar()

Protected Functions

void register_class(const std::string &a_class_name) const
XBaseType *create() const

Protected Attributes

std::string f_class_name
library/utility/macros.hh

Defines

PASTE2(x, y)
PASTE(x, y)
STRINGIFY(x)
TOSTRING(x)
__FILE_LINE__
__FILENAME_LINE__
__FUNC__
library/utility/member_variables.hh

Defines

set_prefix

Macros for class member variables

In all cases remember to initialize the variables!

For “normal” variables Defines accessors [type get_my_var() const], [void set_my_var( type )], and member variable [type f_my_var] The set_ function is not available if the _noset macros are used

  • mv_accessible
  • mv_accessible_noset
  • mv_accessible_static
  • mv_accessible_static_noset

For variables accessed by reference Defines accessors [const type& my_var() const], [type& my_var()], and member variable [type f_my_var] The non-const function is not available if the _const macros are used

  • mv_referrable
  • mv_referrable_const
  • mv_referrable_static
  • mv_referrable_static_const

For pointer variables Defines accessors [type* get_my_var() const], [void set_my_var( type* )], and member variable [type* f_my_var] The set_ function is not available if the _noset macros are used

  • mv_assignable
  • mv_assignable_noset
  • mv_assignable_static
  • mv_assignable_static_noset

For std::shared_ptr’s Defines accessors [const std::shared_ptr< type > my_var() const], [std::shared_ptr< type > my_var()], and member variable [std::shared_ptr< type > f_my_var] The non-const function is not available if the _const macros are used

  • mv_shared_ptr
  • mv_shared_ptr_const
  • mv_shared_ptr_static
  • mv_shared_ptr_static_const

For atomic variables Defines accessors [type get_my_var() const], [void set_my_var( type )], and member variable [std::atomic< type > f_my_var] The set_ function is not available if the _noset macros are used

  • mv_atomic
  • mv_atomic_noset
  • mv_atomic_static
  • mv_atomic_static_noset

get_prefix
var_prefix
static_prefix
library/utility/path.cc

Defines

SCARAB_API_EXPORTS
namespace scarab

The standard scarab namespace.

Functions

path SCARAB_API expand_path(const string & a_path)
library/utility/path.hh
namespace scarab

The standard scarab namespace.

Typedefs

typedef fs::path path
library/utility/scarab_api.hh

Defines

SCARAB_API
namespace scarab

The standard scarab namespace.

library/utility/scarab_version.hh
namespace scarab

The standard scarab namespace.

class version
#include <scarab_version.hh>

Inherits from version_semantic

Public Functions

version()
~version()
class version_ifc
#include <scarab_version.hh>

Subclassed by version_semantic

Public Functions

version_ifc()
version_ifc(const version_ifc&)
virtual ~version_ifc()
version_ifc &operator=(const version_ifc&)
virtual unsigned major_version() const = 0
virtual unsigned minor_version() const = 0
virtual unsigned patch_version() const = 0
virtual const std::string &version_str() const = 0
virtual const std::string &package() const = 0
virtual const std::string &commit() const = 0
virtual const std::string &exe_name() const = 0
virtual const std::string &hostname() const = 0
virtual const std::string &username() const = 0
virtual std::string version_info_string() const = 0
class version_semantic
#include <scarab_version.hh>

Inherits from version_ifc

Subclassed by version

Public Functions

version_semantic()
version_semantic(unsigned a_maj_ver, unsigned a_min_ver, unsigned a_patch_ver)
version_semantic(const std::string &a_ver)
version_semantic(const version_semantic &a_orig)
~version_semantic()
version_semantic &operator=(const version_semantic &a_orig)
unsigned major_version() const
unsigned minor_version() const
unsigned patch_version() const
const std::string &version_str() const
const std::string &package() const
const std::string &commit() const
const std::string &exe_name() const
const std::string &hostname() const
const std::string &username() const
virtual std::string version_info_string() const
bool parse(const std::string &a_ver)
bool combine(unsigned a_maj_ver, unsigned a_min_ver, unsigned a_patch_ver)
bool update_exe_host_user()

Protected Attributes

unsigned f_major_ver
unsigned f_minor_ver
unsigned f_patch_ver
std::string f_version
std::string f_package
std::string f_commit
std::string f_exe_name
std::string f_hostname
std::string f_username

Protected Static Attributes

char s_delimeter
library/utility/singleton.hh

Defines

allow_singleton_access(class_name)
namespace scarab

The standard scarab namespace.

template <class x_type>
class singleton
#include <singleton.hh>

Public Static Functions

x_type *get_instance()
void kill_instance()
template <class… x_args>
x_type *create_instance(x_args... args)

Protected Functions

singleton()
~singleton()

Private Static Functions

void construct_instance()
void delete_instance()

Private Static Attributes

x_type *f_instance = nullptr
destroyer<x_type> f_destroyer
std::mutex f_mutex

Friends

friend scarab::destroyer< x_type >
library/utility/time.cc

Defines

SCARAB_API_EXPORTS
namespace scarab

The standard scarab namespace.

Functions

SCARAB_API int get_time_monotonic(struct timespec * time)
SCARAB_API int get_time_current(struct timespec * time)
SCARAB_API time_nsec_type time_to_nsec(struct timespec time)
SCARAB_API double time_to_sec(struct timespec time)
SCARAB_API void time_diff(struct timespec start, struct timespec end, struct timespec * diff)
SCARAB_API size_t get_time_absolute_str(char * ptr)
SCARAB_API std::string get_absolute_time_string()

Variables

SCARAB_API char date_time_format = “%Y-%m-%dT%H:%M:%SZ”
library/utility/time.hh

Defines

NSEC_PER_SEC
SEC_PER_NSEC

Functions

SCARAB_API bool operator==(const timespec & lhs, const timespec & rhs)
SCARAB_API bool operator<(const timespec & lhs, const timespec & rhs)
namespace scarab

The standard scarab namespace.

Typedefs

typedef uint64_t time_nsec_type
library/utility/typename.cc
namespace scarab

The standard scarab namespace.

Functions

std::string demangle(const char *a_name)
library/utility/typename.hh
namespace scarab

The standard scarab namespace.

Functions

template <class x_type>
std::string type(const x_type &a_param)

Full Doxygen API Reference