Deep Learning SDK for Geospatial Data
 1.0.0+
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
Utility

Detailed Description

Contains utilities that include DG's error and logger handling, as well as zip file functionality, boost program options and progress bars.

Files

file  Logging.h
 Macros and initialization methods for logging.
 
file  Progress.h
 Definitions for progress display funcitons.
 

Classes

class  dg::deepcore::AsyncError
 Base class for asynchronous processes that need to report an error from another thread. More...
 
struct  dg::deepcore::CallStackSymbol
 Represents an entry in a callstack. More...
 
struct  dg::deepcore::CloneableValueBase< T >
 A base class for cloneable polymorphic values. Sets up a uniform interface form having a clone() method. More...
 
struct  dg::deepcore::EmbeddedResource
 Hold information on an in-memory resource, with name, pointer, and lengthThis is designed to accompany resources which are added during the cmake phase with EmbedResources.cmake. More...
 
class  dg::deepcore::Error
 Represents a DeepCore error. More...
 
class  dg::deepcore::Logger
 A class to facilitate logging. More...
 
class  boost::program_options::bounded_typed_value< T, charT >
 Extends boost::program_options::typed_value to allow for setting a specific number of tokens. More...
 
class  dg::deepcore::Semaphore
 Represents a semaphore. More...
 
struct  dg::deepcore::is_container< T >
 Checks whether T is an STL container type. More...
 
struct  dg::deepcore::is_specialization_of< X, Y >
 Checks whether Y is a specialization of template X. More...
 
struct  dg::deepcore::is_function< T >
 Checks whether T is an std::function. More...
 
struct  dg::deepcore::is_shared_ptr< T >
 Checks whether T is an std::shared_ptr. More...
 
struct  dg::deepcore::is_cloneable_value< T >
 Checks if T or a base class of T implements CloneableValueBase. More...
 
class  dg::deepcore::rref_capture< T >
 Wraps rvalue references to allow using them to be used in a const context. More...
 
class  dg::deepcore::MultiProgressDisplay
 A console progress display capable of displaying progress of multiple concurrent tasks. More...
 
class  dg::deepcore::Singleton< T, S >
 A thread-safe singleton class holder. More...
 
class  dg::deepcore::UnZipFile
 Reads contents of a zip file. More...
 
class  dg::deepcore::ZipFile
 Creates a zip file and writes data and directory information into it. More...
 

Macros

#define __FILENAME__   (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
 
#define DG_ERROR_INIT(format,...)   dg::deepcore::Error::fromFormat(__FILENAME__, __LINE__, __FUNCTION__, format, ##__VA_ARGS__)
 Initializes an Error for the current position in code, allows for sprintf-style message formatting. More...
 
#define DG_ERROR_THROW(format,...)   throw dg::deepcore::Error::fromFormat(__FILENAME__, __LINE__, __FUNCTION__, format, ##__VA_ARGS__)
 Throws an Error for the current position in code, allows for sprintf-style message formatting. More...
 
#define DG_ERROR_RETHROW(statement, orig, format,...)   try { statement; } catch(const orig& e) { throw dg::deepcore::Error::fromFormat(__FILENAME__, __LINE__, __FUNCTION__, format, ##__VA_ARGS__); }
 If an exception is thrown, rethrows a dg::deepcore::Error. More...
 
#define DG_CHECK(condition, message,...)   if(!(condition)) { DG_ERROR_THROW(message , ##__VA_ARGS__); }
 Checks the condition and throws an Error if the condition is false. More...
 
#define DG_ERROR_LOG(channel, error)   error.log(#channel)
 Logs the Error. More...
 
#define DG_LOG(channel, sev)   DG_LOG_LOCAL( ::dg::deepcore::log::threadLogger(), channel, sev)
 Create a ostream to log a message to the global logging framework at a given severity. More...
 
#define DG_LOG_LOCAL(dg_logger, channel, sev)   DG_LOG_LOCAL_PARAMS(dg_logger, channel, sev, __FILENAME__, __LINE__, __FUNCTION__)
 Create a ostream to log a message to a local logging object. More...
 
#define DG_LOG_LOCAL_PARAMS(dg_logger, channel, sev, filename, line, function)
 Create a ostream to log a message to a local logging object. More...
 
#define DG_STRINGIFY(n)   #n
 Helper macro to stringify a parameter. More...
 
#define DG_CONCAT(a, b)   a##b
 Helper macro to concatenate two parameters. More...
 
#define DG_VFUNC(func,...)
 Defines a macro with variadic arguments. More...
 

Typedefs

using dg::deepcore::ErrorFunc = std::function< Error *(const Error &e)>
 An Error callback function. The can examine the input error and transform it if necessary. If the Error was transformed, the function should return a new Error instance. The caller will take ownership of the pointer. If the Error does not need to be transformed, the function should return nullptr. More...
 
using dg::deepcore::OnErrorFunc = std::function< void(std::exception_ptr ptr)>
 An error handling callback function. Called when an asynchronous process encounters and error that cannot be immediately thrown. More...
 
using dg::deepcore::CallStack = std::vector< CallStackSymbol >
 Represents a callstack. More...
 
using dg::deepcore::SimpleProgress = std::function< bool(float progress)>
 A simple progress reporting callback. More...
 
using dg::deepcore::Progress = std::function< bool(float progress, const char *status)>
 A progress reporting callback with ability to display additional information. More...
 

Enumerations

enum  dg::deepcore::SingletonStorage { dg::deepcore::SingletonStorage::GLOBAL, dg::deepcore::SingletonStorage::THREAD_LOCAL }
 Represents a Singleton storage lifetime. More...
 

Functions

std::ostream & dg::deepcore::operator<< (ostream &os, const CallStackSymbol &symbol)
 Allows writing a CallStackSymbol into an std::ostream. More...
 
std::ostream & dg::deepcore::operator<< (ostream &os, const CallStack &callStack)
 Allows writing a CallStack into an std::ostream. More...
 
boost::log::formatting_ostream & dg::deepcore::operator<< (boost::log::formatting_ostream &os, const CallStackSymbol &symbol)
 Allows logging a CallStackSymbol with DG_LOG. More...
 
boost::log::formatting_ostream & dg::deepcore::operator<< (boost::log::formatting_ostream &os, const CallStack &callStack)
 Allows logging a CallStack with DG_LOG. More...
 
std::string dg::deepcore::demangleSymbol (const char *mangled)
 Demangle a compiler symbol, if possible. More...
 
template<class T >
std::enable_if
<!std::numeric_limits< T >
::is_integer, bool >::type 
dg::deepcore::almostEq (T x, T y, int ulp=4)
 Checks if the two numbers are approximately equal. More...
 
template<class T >
std::enable_if
<!std::numeric_limits< T >
::is_integer, bool >::type 
dg::deepcore::almostEq (const cv::Point_< T > &p1, const cv::Point_< T > &p2, int ulp=4)
 Checks if the two cv::Point_<T> coordinates are approximately equal. More...
 
template<class T >
std::enable_if
<!std::numeric_limits< T >
::is_integer, bool >::type 
dg::deepcore::almostEq (const cv::Size_< T > &s1, const cv::Size_< T > &s2, int ulp=4)
 Checks if the two cv::Size_<T> sizes are approximately equal. More...
 
template<class T >
std::enable_if
<!std::numeric_limits< T >
::is_integer, bool >::type 
dg::deepcore::almostEq (const cv::Rect_< T > &r1, const cv::Rect_< T > &r2, int ulp=4)
 Checks if the two cv::Rect_<T> rectangles are approximately equal. More...
 
std::vector< option > boost::program_options::ignore_numbers (std::vector< std::string > &args)
 A boost::program_options::detail::style_parser that allows using multitoken options with numbers, including negative numbers. This disallows using numbers are short command line arguments. More...
 
template<class T >
std::string boost::program_options::name_with_default (std::string name, T defaultVal)
 Creates a value for the default which is suitable for input to po::value_name();. More...
 
template<class T , class charT = char>
bounded_typed_value< T, charT > * boost::program_options::bounded_value (T *store_to=nullptr)
 Creates a new instance of bounded_typed_value. More...
 
detail::cmdline::style_parser boost::program_options::postfix_argument (const std::string &postfix)
 Factory for a boost::program_options::detail::style_parser that allows grouping of parameters with the same postfix in a key/value fashion. More...
 
std::string dg::deepcore::network::parseJsonMessage (const string &json) noexcept
 Extracts a "message" object from the root object of a JSON string. More...
 
std::string dg::deepcore::readMaskedInputFromConsole ()
 Initializes a getline that is masked for the purposes of hiding the user input of a password. More...
 
double dg::deepcore::radians (double degrees) noexcept
 Convert degrees to radians. More...
 
cv::Point2d dg::deepcore::radians (const cv::Point2d &degrees) noexcept
 Convert degrees to radians. More...
 
cv::Size2d dg::deepcore::radians (const cv::Size2d &degrees) noexcept
 Convert degrees to radians. More...
 
cv::Rect2d dg::deepcore::radians (const cv::Rect2d &degrees) noexcept
 Convert degrees to radians. More...
 
double dg::deepcore::degrees (double radians) noexcept
 Convert radians to degrees. More...
 
cv::Point2d dg::deepcore::degrees (const cv::Point2d &radians) noexcept
 Convert radians to degrees. More...
 
cv::Size2d dg::deepcore::degrees (const cv::Size2d &radians) noexcept
 Convert radians to degrees. More...
 
cv::Rect2d dg::deepcore::degrees (const cv::Rect2d &radians) noexcept
 Convert radians to degrees. More...
 
Logger & dg::deepcore::log::threadLogger ()
 get the global static instance More...
 
void dg::deepcore::log::init ()
 Initialize the logging framework. More...
 
boost::shared_ptr< sinks::sink > dg::deepcore::log::addStreamSink (boost::shared_ptr< std::ostream > const &stream, level_t minLevel, level_t maxLevel, dg_log_format format)
 add a simple log sink which directs output to clog More...
 
boost::shared_ptr< sinks::sink > dg::deepcore::log::addClogSink (level_t minLevel, level_t maxLevel, dg_log_format format)
 add a simple log sink which directs output to clog More...
 
boost::shared_ptr< sinks::sink > dg::deepcore::log::addCerrSink (level_t minLevel, level_t maxLevel, dg_log_format format)
 add a simple log sink which directs output to cerr More...
 
boost::shared_ptr< sinks::sink > dg::deepcore::log::addCoutSink (level_t minLevel, level_t maxLevel, dg_log_format format)
 add a simple log sink which directs output to cout More...
 
boost::shared_ptr< sinks::sink > dg::deepcore::log::addSink (boost::shared_ptr< sinks::sink > const &sink)
 add a complex log sink More...
 
void dg::deepcore::log::removeSink (boost::shared_ptr< sinks::sink > const &sink)
 remove a log sink More...
 
std::string dg::deepcore::log::levelToString (level_t level)
 Convert an enum representation of logging level to string. More...
 
level_t dg::deepcore::log::stringToLevel (const std::string &str)
 Convert a string representation of logging level to enum. More...
 
std::string dg::deepcore::loginUser ()
 Returns the current login user name. If the information cannot be determined returns a blank string. More...
 
 dg::deepcore::Error::Error (const char *file, const unsigned int line, const char *function, const char *message)
 Constructs an Error. More...
 
 dg::deepcore::Error::Error (const std::string &file, const unsigned int line, const std::string &function, const std::string &message)
 Constructs an Error. More...
 
 dg::deepcore::Error::Error (const char *file, const unsigned int line, const char *function, const std::string &message)
 Constructs an Error. More...
 
 dg::deepcore::Error::Error (const char *file, const unsigned int line, const char *function, const std::string &message, size_t skipLevels)
 Constructs an Error with ability to skip callstack levels. More...
 
 dg::deepcore::Error::Error (const char *file, const unsigned int line, const char *function, const std::string &message, const CallStack &callStackOverride)
 Constructs an Error with ability to override the callstack. More...
 
static Error dg::deepcore::Error::fromFormat (const char *file, const unsigned int line, const char *function, const char *format,...) noexcept
 Creates an error with a message that can be formatted using sprintf-style format. More...
 
virtual const char * dg::deepcore::Error::what () const noexceptoverride
 Returns the error description in format "{message} in {function}, file: {file}, line: {line}.". More...
 
const std::string & dg::deepcore::Error::file () const noexcept
 Gets the source file name in which the error occured. More...
 
const unsigned int dg::deepcore::Error::line () const noexcept
 Returns the source line number. More...
 
const std::string & dg::deepcore::Error::function () const noexcept
 Returns the function name in which the error occured. More...
 
const std::string & dg::deepcore::Error::message () const noexcept
 Returns the error message. More...
 
 dg::deepcore::MultiProgressDisplay::MultiProgressDisplay (const std::vector< std::string > &categories, int intervalMs=500)
 Constructs a MultiProgressDisplay. More...
 
 dg::deepcore::MultiProgressDisplay::~MultiProgressDisplay ()
 The destructor. More...
 
void dg::deepcore::MultiProgressDisplay::start ()
 Starts and displays the progress meter(s). More...
 
void dg::deepcore::MultiProgressDisplay::stop ()
 Stops the progress meter(s). More...
 
void dg::deepcore::MultiProgressDisplay::update (size_t categoryId, float progress)
 Updateds progress. More...
 
const std::vector< std::string > & dg::deepcore::MultiProgressDisplay::categories () const noexcept
 Gets the categories. More...
 
 dg::deepcore::UnZipFile::UnZipFile (std::istream &is)
 Constructs a UnZipFile from a given input stream. More...
 
 dg::deepcore::UnZipFile::UnZipFile (const std::vector< uint8_t > &buf)
 Constructs a UnZipFile from a given vector. More...
 
 dg::deepcore::UnZipFile::UnZipFile (const uint8_t *buf, size_t size)
 Constructs a UnZipFile from a given memory buffer. More...
 
 dg::deepcore::UnZipFile::UnZipFile (const std::string &fileName)
 Constructs a UnZipFile from a file on disk. More...
 
 dg::deepcore::UnZipFile::~UnZipFile ()
 Destructs the UnZipFile object and closes the zip file. More...
 
void dg::deepcore::UnZipFile::close ()
 Closes the zip file. UnZipFile object is no longer usable after it's closed. More...
 
void dg::deepcore::UnZipFile::goToFirstFile ()
 Goes to the first file in the archive. More...
 
bool dg::deepcore::UnZipFile::goToNextFile ()
 Goes to the next file in the archive if possible. More...
 
size_t dg::deepcore::UnZipFile::readFile (uint8_t *buf, size_t size, const std::string &password="")
 Reads the current file from the archive into a memory buffer. More...
 
std::ostream & dg::deepcore::UnZipFile::readFile (std::ostream &os, const std::string &password="")
 Reads the current file from the archive into an output stream. More...
 
std::vector< uint8_t > dg::deepcore::UnZipFile::readFile (const std::string &password="")
 Reads the current file from the archive into a vector. More...
 
std::string dg::deepcore::UnZipFile::readFileToString (const std::string &password="")
 Reads the current file from the archive into a string. More...
 
const std::string & dg::deepcore::UnZipFile::fileName () const
 Returns the name and path of the current file in the archive. More...
 
const uint64_t dg::deepcore::UnZipFile::fileSize () const
 Returns the uncompressed file size of the current file in the archive. More...
 
bool dg::deepcore::UnZipFile::encrypted () const
 Returns whether the current file is encrypted. More...
 
 dg::deepcore::ZipFile::ZipFile (std::ostream &os)
 Constructs a ZipFile to write the given output stream. More...
 
 dg::deepcore::ZipFile::ZipFile (const std::string &fileName)
 Constructs a ZipFile that creates or overwrites a file on disk. More...
 
 dg::deepcore::ZipFile::~ZipFile ()
 Destructs the ZipFile object and closes the zip file. More...
 
void dg::deepcore::ZipFile::close ()
 Closes the zip file. ZipFile object is no longer usable after it's closed. More...
 
void dg::deepcore::ZipFile::addFile (const std::string &zipPath, const std::string &fileName, const std::string &password="", CompressionLevel level=DEFAULT_COMPRESSION)
 Adds a file to the archive from given path. Input file must be readable. More...
 
void dg::deepcore::ZipFile::addFile (const std::string &zipPath, std::istream &is, const std::string &password="", CompressionLevel level=DEFAULT_COMPRESSION)
 Adds a file to the archive from the given input stream. More...
 
void dg::deepcore::ZipFile::addFile (const std::string &zipPath, const std::vector< uint8_t > &buf, const std::string &password="", CompressionLevel level=DEFAULT_COMPRESSION)
 Adds a file to the archive from a vector. More...
 
void dg::deepcore::ZipFile::addFile (const std::string &zipPath, const uint8_t *buf, size_t size, const std::string &password="", CompressionLevel level=DEFAULT_COMPRESSION)
 Adds a file to the archive from a raw memory buffer. More...
 
void dg::deepcore::ZipFile::addFileFromString (const std::string &zipPath, const std::string &buf, const std::string &password="", CompressionLevel level=DEFAULT_COMPRESSION)
 Adds a file to the archive from a string. More...
 

Macro Definition Documentation

#define __FILENAME__   (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
#define DG_CHECK (   condition,
  message,
  ... 
)    if(!(condition)) { DG_ERROR_THROW(message , ##__VA_ARGS__); }

Checks the condition and throws an Error if the condition is false.

Parameters
[in]conditionThe condition to check.
[in]messageThe sprintf-style format for the error message if condition is false.
[in]...Arguments for format specification.
#define DG_CONCAT (   a,
 
)    a##b

Helper macro to concatenate two parameters.

#define DG_ERROR_INIT (   format,
  ... 
)    dg::deepcore::Error::fromFormat(__FILENAME__, __LINE__, __FUNCTION__, format, ##__VA_ARGS__)

Initializes an Error for the current position in code, allows for sprintf-style message formatting.

Parameters
[in]formatThe sprintf-style format for the error message.
[in]...Arguments for format specification.
Returns
A new instance of the Error class initialized with the message and the current file, line, and function.
#define DG_ERROR_LOG (   channel,
  error 
)    error.log(#channel)

Logs the Error.

Parameters
[in]channelThe log channel.
[in]errorThe Error to log.
#define DG_ERROR_RETHROW (   statement,
  orig,
  format,
  ... 
)    try { statement; } catch(const orig& e) { throw dg::deepcore::Error::fromFormat(__FILENAME__, __LINE__, __FUNCTION__, format, ##__VA_ARGS__); }

If an exception is thrown, rethrows a dg::deepcore::Error.

Parameters
[in]statementThe statement to run.
[in]origThe original exception type to catch.
[in]formatThe sprintf-style format for the error message.
[in]...Arguments for format specification.
#define DG_ERROR_THROW (   format,
  ... 
)    throw dg::deepcore::Error::fromFormat(__FILENAME__, __LINE__, __FUNCTION__, format, ##__VA_ARGS__)

Throws an Error for the current position in code, allows for sprintf-style message formatting.

Parameters
[in]formatThe sprintf-style format for the error message.
[in]...Arguments for format specification.
#define DG_LOG (   channel,
  sev 
)    DG_LOG_LOCAL( ::dg::deepcore::log::threadLogger(), channel, sev)

Create a ostream to log a message to the global logging framework at a given severity.

Parameters
[in]channelthe channel to which to associate this message
[in]sevthe severity of the log message

Severity (case sensitive) must be one of {trace, debug, info, warning, error, fatal}

#define DG_LOG_LOCAL (   dg_logger,
  channel,
  sev 
)    DG_LOG_LOCAL_PARAMS(dg_logger, channel, sev, __FILENAME__, __LINE__, __FUNCTION__)

Create a ostream to log a message to a local logging object.

Parameters
[in]dg_loggerthe logger object to which to push the message
[in]channelthe channel to which to associate this message
[in]sevthe severity of the log message

Severity (case sensitive) must be one of {trace, debug, info, warning, error, fatal}

#define DG_LOG_LOCAL_PARAMS (   dg_logger,
  channel,
  sev,
  filename,
  line,
  function 
)
Value:
BOOST_LOG_STREAM_WITH_PARAMS( \
(dg_logger.logger()), \
(dg_logger.setScope(#channel, filename, line, function)) \
(::boost::log::keywords::severity = (::boost::log::trivial::sev)) \
)

Create a ostream to log a message to a local logging object.

Parameters
[in]dg_loggerthe logger object to which to push the message
[in]channelthe channel to which to associate this message
[in]sevthe severity of the log message
[in]filenamethe filename attribute
[in]linethe line attribute
[in]functionthe function attribute

Severity (case sensitive) must be one of {trace, debug, info, warning, error, fatal}

#define DG_STRINGIFY (   n)    #n

Helper macro to stringify a parameter.

#define DG_VFUNC (   func,
  ... 
)

Defines a macro with variadic arguments.

Parameters
funcBase name of the varidic macro to create.
...always set to __VA_ARGS__

Example In this example we define a macro MY_MACRO taking one to three parameters

#define MY_MACRO DG_VFUNC(MY_MACRO, __VA_ARGS__)
#define MY_MACRO1(a) myFunc(a)
#define MY_MACRO2(a, b) myFunc(a, b)
#define MY_MACRO3(a, b, c) myFunc(a, b, c)

Typedef Documentation

using dg::deepcore::CallStack = typedef std::vector<CallStackSymbol>

Represents a callstack.

using dg::deepcore::ErrorFunc = typedef std::function<Error*(const Error& e)>

An Error callback function. The can examine the input error and transform it if necessary. If the Error was transformed, the function should return a new Error instance. The caller will take ownership of the pointer. If the Error does not need to be transformed, the function should return nullptr.

Parameters
[in]eThe input Error.
Returns
A new instance of Error, or nullptr if Error was not transformed.
using dg::deepcore::OnErrorFunc = typedef std::function<void(std::exception_ptr ptr)>

An error handling callback function. Called when an asynchronous process encounters and error that cannot be immediately thrown.

Parameters
[in]ptrAn exception pointer obtained by calling std::current_exception for caught exceptions or by creating one by calling std::make_exception_ptr.

A progress reporting callback with ability to display additional information.

Parameters
[in]progressProgress value, must be a value in range from 0.0 to 1.0.
[in]statusAdditional information to display. If status is nullptr, status did not change.
Returns

A simple progress reporting callback.

Parameters
[in]progressProgress value, must be a value in range from 0.0 to 1.0.

Enumeration Type Documentation

Represents a Singleton storage lifetime.

Enumerator
GLOBAL 

Singleton is shared between all threads.

THREAD_LOCAL 

Singleton is thread-local.

Function Documentation

dg::deepcore::Error::Error ( const char *  file,
const unsigned int  line,
const char *  function,
const char *  message 
)

Constructs an Error.

Parameters
[in]fileName of source file in which the error occurred.
[in]lineSource line number for the error.
[in]functionFunction name in which the error occured.
[in]messageThe error message.
dg::deepcore::Error::Error ( const char *  file,
const unsigned int  line,
const char *  function,
const std::string &  message 
)

Constructs an Error.

Parameters
[in]fileName of source file in which the error occurred.
[in]lineSource line number for the error.
[in]functionFunction name in which the error occured.
[in]messageThe error message.
dg::deepcore::Error::Error ( const std::string &  file,
const unsigned int  line,
const std::string &  function,
const std::string &  message 
)

Constructs an Error.

Parameters
[in]fileName of source file in which the error occurred.
[in]lineSource line number for the error.
[in]functionFunction name in which the error occured.
[in]messageThe error message.
dg::deepcore::Error::Error ( const char *  file,
const unsigned int  line,
const char *  function,
const std::string &  message,
size_t  skipLevels 
)
protected

Constructs an Error with ability to skip callstack levels.

Parameters
[in]fileName of source file in which the error occurred.
[in]lineSource line number for the error.
[in]functionFunction name in which the error occured.
[in]messageThe error message.
[in]skipLevelsThe number of callstack levels to skip when recording the callstack.
dg::deepcore::Error::Error ( const char *  file,
const unsigned int  line,
const char *  function,
const std::string &  message,
const CallStack callStackOverride 
)
protected

Constructs an Error with ability to override the callstack.

Parameters
[in]fileName of source file in which the error occurred.
[in]lineSource line number for the error.
[in]functionFunction name in which the error occured.
[in]messageThe error message.
[in]callStackOverrideThe callstack to use for this Error instance.
dg::deepcore::MultiProgressDisplay::MultiProgressDisplay ( const std::vector< std::string > &  categories,
int  intervalMs = 500 
)

Constructs a MultiProgressDisplay.

Parameters
[in]categoriesA list of display categories.
[in]intervalMsThe display refresh interval in milliseconds.
dg::deepcore::UnZipFile::UnZipFile ( std::istream &  is)

Constructs a UnZipFile from a given input stream.

Parameters
[in,out]isThe input stream to read from. UnZipFile does not take ownership of this object, so lifetime must be greater than the UnZipFile's instance lifetime.
dg::deepcore::UnZipFile::UnZipFile ( const std::vector< uint8_t > &  buf)

Constructs a UnZipFile from a given vector.

Parameters
[in]bufThe input vector to read from. UnZipFile does not take ownership of this object or make a copy, so lifetime must be greater than the UnZipFile's instance lifetime.
dg::deepcore::UnZipFile::UnZipFile ( const uint8_t *  buf,
size_t  size 
)

Constructs a UnZipFile from a given memory buffer.

Parameters
[in]bufThe input buffer to read from. UnZipFile does not take ownership of this object or make a copy, so lifetime must be greater than the UnZipFile's instance lifetime.
[in]sizeSize of the input buffer.
dg::deepcore::UnZipFile::UnZipFile ( const std::string &  fileName)

Constructs a UnZipFile from a file on disk.

Parameters
[in]fileNamePath to the zip file. Must exist and be readable.
dg::deepcore::ZipFile::ZipFile ( std::ostream &  os)

Constructs a ZipFile to write the given output stream.

Parameters
[in,out]osThe output stream to write to. ZipFile does not take ownership of this object, so lifetime must be greater than the ZipFile's instance lifetime.
dg::deepcore::ZipFile::ZipFile ( const std::string &  fileName)

Constructs a ZipFile that creates or overwrites a file on disk.

Parameters
[in]fileNamePath to the zip file to create. Must be in a writable location.
dg::deepcore::MultiProgressDisplay::~MultiProgressDisplay ( )

The destructor.

dg::deepcore::UnZipFile::~UnZipFile ( )

Destructs the UnZipFile object and closes the zip file.

dg::deepcore::ZipFile::~ZipFile ( )

Destructs the ZipFile object and closes the zip file.

boost::shared_ptr< sinks::sink > dg::deepcore::log::addCerrSink ( level_t  minLevel,
level_t  maxLevel,
dg_log_format  format 
)

add a simple log sink which directs output to cerr

Parameters
[in]minLevelthe minimum level (inclusive) for output of messages to this sink
[in]maxLevelthe maximum level (inclusive) for output of messages to this sink
[in]formatthe formatter to use for this sink
Returns
A pointer to the sink which was added to the log framework
boost::shared_ptr< sinks::sink > dg::deepcore::log::addClogSink ( level_t  minLevel,
level_t  maxLevel,
dg_log_format  format 
)

add a simple log sink which directs output to clog

Parameters
[in]minLevelthe minimum level (inclusive) for output of messages to this sink
[in]maxLevelthe maximum level (inclusive) for output of messages to this sink
[in]formatthe formatter to use for this sink
Returns
A pointer to the sink which was added to the log framework
boost::shared_ptr< sinks::sink > dg::deepcore::log::addCoutSink ( level_t  minLevel,
level_t  maxLevel,
dg_log_format  format 
)

add a simple log sink which directs output to cout

Parameters
[in]minLevelthe minimum level (inclusive) for output of messages to this sink
[in]maxLevelthe maximum level (inclusive) for output of messages to this sink
[in]formatthe formatter to use for this sink
Returns
A pointer to the sink which was added to the log framework
void dg::deepcore::ZipFile::addFile ( const std::string &  zipPath,
const std::string &  fileName,
const std::string &  password = "",
CompressionLevel  level = DEFAULT_COMPRESSION 
)

Adds a file to the archive from given path. Input file must be readable.

Parameters
[in]zipPathPath and file name that the file will have inside the archive.
[in]fileNamePath to the input file.
[in]passwordPassword for encryption. No encryption is perform if password is blank.
[in]levelZip compression level for the file.
Note
The archive must be open. If it's closed an exception will be thrown.
void dg::deepcore::ZipFile::addFile ( const std::string &  zipPath,
std::istream &  is,
const std::string &  password = "",
CompressionLevel  level = DEFAULT_COMPRESSION 
)

Adds a file to the archive from the given input stream.

Parameters
[in]zipPathPath and file name that the file will have inside the archive.
[in]isThe input stream to read from.
[in]passwordPassword for encryption. No encryption is perform if password is blank.
[in]levelZip compression level for the file.
Note
The archive must be open. If it's closed an exception will be thrown.
void dg::deepcore::ZipFile::addFile ( const std::string &  zipPath,
const std::vector< uint8_t > &  buf,
const std::string &  password = "",
ZipFile::CompressionLevel  level = DEFAULT_COMPRESSION 
)

Adds a file to the archive from a vector.

Parameters
[in]zipPathPath and file name that the file will have inside the archive.
[in]bufThe vector to read from.
[in]passwordPassword for encryption. No encryption is perform if password is blank.
[in]levelZip compression level for the file.
Note
The archive must be open. If it's closed an exception will be thrown.
void dg::deepcore::ZipFile::addFile ( const std::string &  zipPath,
const uint8_t *  buf,
size_t  size,
const std::string &  password = "",
ZipFile::CompressionLevel  level = DEFAULT_COMPRESSION 
)

Adds a file to the archive from a raw memory buffer.

Parameters
[in]zipPathPath and file name that the file will have inside the archive.
[in]bufThe input buffer to read from.
[in]sizeSize of the input buffer.
[in]passwordPassword for encryption. No encryption is perform if password is blank.
[in]levelZip compression level for the file.
Note
The archive must be open. If it's closed an exception will be thrown.
void dg::deepcore::ZipFile::addFileFromString ( const std::string &  zipPath,
const std::string &  buf,
const std::string &  password = "",
ZipFile::CompressionLevel  level = DEFAULT_COMPRESSION 
)

Adds a file to the archive from a string.

Parameters
[in]zipPathPath and file name that the file will have inside the archive.
[in]bufThe input string to read from.
[in]passwordPassword for encryption. No encryption is perform if password is blank.
[in]levelZip compression level for the file.
Note
The archive must be open. If it's closed an exception will be thrown.
boost::shared_ptr< sinks::sink > dg::deepcore::log::addSink ( boost::shared_ptr< sinks::sink > const &  sink)

add a complex log sink

Parameters
[in]sinkthe sink to add
Returns
A pointer to the sink which was added to the log framework
boost::shared_ptr< sinks::sink > dg::deepcore::log::addStreamSink ( boost::shared_ptr< std::ostream > const &  stream,
level_t  minLevel,
level_t  maxLevel,
dg_log_format  format 
)

add a simple log sink which directs output to clog

Parameters
[in]streamthe stream to add with the given format and filter
[in]minLevelthe minimum level (inclusive) for output of messages to this sink
[in]maxLevelthe maximum level (inclusive) for output of messages to this sink
[in]formatthe formatter to use for this sink
Returns
A pointer to the sink which was added to the log framework
template<class T >
std::enable_if<!std::numeric_limits<T>::is_integer, bool>::type dg::deepcore::almostEq ( x,
y,
int  ulp = 4 
)

Checks if the two numbers are approximately equal.

Reference: link text

Template Parameters
TNumber format, must be floating point.
Parameters
[in]xFirst number to compare.
[in]ySecond number to compare.
[in]ulpPrecision in units in last place.
Returns
Whether the two numbers are approximately equal.
template<class T >
std::enable_if<!std::numeric_limits<T>::is_integer, bool>::type dg::deepcore::almostEq ( const cv::Point_< T > &  p1,
const cv::Point_< T > &  p2,
int  ulp = 4 
)

Checks if the two cv::Point_<T> coordinates are approximately equal.

Parameters
[in]p1The first point to compare.
[in]p2The second point to compare.
[in]ulpPrecision in units in last place.
Returns
Whether the two coordinates are approximately equal.
template<class T >
std::enable_if<!std::numeric_limits<T>::is_integer, bool>::type dg::deepcore::almostEq ( const cv::Size_< T > &  s1,
const cv::Size_< T > &  s2,
int  ulp = 4 
)

Checks if the two cv::Size_<T> sizes are approximately equal.

Parameters
[in]s1The first size to compare.
[in]s2The second size to compare.
[in]ulpPrecision in units in last place.
Returns
Whether the two sizes are approximately equal.
template<class T >
std::enable_if<!std::numeric_limits<T>::is_integer, bool>::type dg::deepcore::almostEq ( const cv::Rect_< T > &  r1,
const cv::Rect_< T > &  r2,
int  ulp = 4 
)

Checks if the two cv::Rect_<T> rectangles are approximately equal.

Parameters
[in]r1The first rectangle to compare.
[in]r2The second rectangle to compare.
[in]ulpPrecision in units in last place.
Returns
Whether the two rectangles are approximately equal.
template<class T , class charT = char>
bounded_typed_value<T, charT>* boost::program_options::bounded_value ( T *  store_to = nullptr)

Creates a new instance of bounded_typed_value.

Parameters
[in,out]store_toPointer to a variable that automatically receives the argument's value.

Usage example:

boost::program_options::options_description desc;
desc.add_options()
("bounding-box,b", boost::program_options::bounded_value<vector<double>>()->fixed_tokens(4), "Bounding box");
Returns
A new instance of bounded_typed_value.
const vector< string > & dg::deepcore::MultiProgressDisplay::categories ( ) const
noexcept

Gets the categories.

Returns
The categories.
void dg::deepcore::UnZipFile::close ( )

Closes the zip file. UnZipFile object is no longer usable after it's closed.

void dg::deepcore::ZipFile::close ( )

Closes the zip file. ZipFile object is no longer usable after it's closed.

double dg::deepcore::degrees ( double  radians)
noexcept

Convert radians to degrees.

Parameters
[in]radiansValue in radians.
Returns
Value in degrees.
cv::Point2d dg::deepcore::degrees ( const cv::Point2d &  radians)
noexcept

Convert radians to degrees.

Parameters
[in]radiansValue in radians.
Returns
Value in degrees.
cv::Size2d dg::deepcore::degrees ( const cv::Size2d &  radians)
noexcept

Convert radians to degrees.

Parameters
[in]radiansValue in radians.
Returns
Value in degrees.
cv::Rect2d dg::deepcore::degrees ( const cv::Rect2d &  radians)
noexcept

Convert radians to degrees.

Parameters
[in]radiansValue in radians.
Returns
Value in degrees.
std::string dg::deepcore::demangleSymbol ( const char *  mangled)

Demangle a compiler symbol, if possible.

Parameters
[in]mangledThe mangled symbol.
Returns
The demangled symbol, or the input if demangling failed.
bool dg::deepcore::UnZipFile::encrypted ( ) const

Returns whether the current file is encrypted.

Returns
Whether the current file is encrypted.
Note
It's up to the caller to check this flag before deciding whether to pass a password to UnZipFile::readFile.
const string & dg::deepcore::Error::file ( ) const
noexcept

Gets the source file name in which the error occured.

Returns
The source file name.
const string & dg::deepcore::UnZipFile::fileName ( ) const

Returns the name and path of the current file in the archive.

Returns
The current file name.
Note
The archive must be open. If it's closed an exception will be thrown.
const uint64_t dg::deepcore::UnZipFile::fileSize ( ) const

Returns the uncompressed file size of the current file in the archive.

Returns
The uncompressed size of the current file.
Note
The archive must be open. If it's closed an exception will be thrown.
Error dg::deepcore::Error::fromFormat ( const char *  file,
const unsigned int  line,
const char *  function,
const char *  format,
  ... 
)
staticnoexcept

Creates an error with a message that can be formatted using sprintf-style format.

Parameters
[in]fileName of source file in which the error occurred.
[in]lineSource line number for the error.
[in]functionFunction name in which the error occured.
[in]formatThe sprintf-style format specifier for the error message.
[in]...Arguments for format specification.
Returns
The error.
const string & dg::deepcore::Error::function ( ) const
noexcept

Returns the function name in which the error occured.

Returns
The function name.
void dg::deepcore::UnZipFile::goToFirstFile ( )

Goes to the first file in the archive.

Note
The archive must be open. If it's closed an exception will be thrown.
bool dg::deepcore::UnZipFile::goToNextFile ( )

Goes to the next file in the archive if possible.

Returns
true if the traversal was successful, false if the end of archive was reached.
Note
The archive must be open. If it's closed an exception will be thrown.
std::vector<option> boost::program_options::ignore_numbers ( std::vector< std::string > &  args)

A boost::program_options::detail::style_parser that allows using multitoken options with numbers, including negative numbers. This disallows using numbers are short command line arguments.

Example usage:

boost::program_options::store(
boost::program_options::command_line_parser(argc, argv)
.options(commands).run(), vm);
Parameters
argsArguments.
Returns
Parsed arguments.
void dg::deepcore::log::init ( )

Initialize the logging framework.

This redirects glog messages to the DeepCore framework and remove all sinks

std::string dg::deepcore::log::levelToString ( level_t  level)

Convert an enum representation of logging level to string.

Parameters
[in]levelThe enum representation of logging level.
Returns
The string representation of logging level.
const unsigned int dg::deepcore::Error::line ( ) const
noexcept

Returns the source line number.

Returns
The source line number.
std::string dg::deepcore::loginUser ( )

Returns the current login user name. If the information cannot be determined returns a blank string.

Returns
The current login user name.
const string & dg::deepcore::Error::message ( ) const
noexcept

Returns the error message.

Returns
The error message.
template<class T >
std::string boost::program_options::name_with_default ( std::string  name,
defaultVal 
)

Creates a value for the default which is suitable for input to po::value_name();.

Example usage:

("zoom", po::value<int>()->value_name(name_with_default("ZOOM", zoom)), "Zoom level.")

This replaces po::default_value(), when the triggering of notifiers is not desired.

Parameters
[in]namethe name of the option
[in]defaultValthe default value of the option
Returns
A string that represents the name with a default value
ostream & dg::deepcore::operator<< ( ostream &  os,
const CallStackSymbol &  symbol 
)

Allows writing a CallStackSymbol into an std::ostream.

Parameters
[in,out]osThe output stream to write to.
[in]symbolThe CallStackSymbol to write.
Returns
A reference to the input stream.
ostream & dg::deepcore::operator<< ( ostream &  os,
const CallStack &  callStack 
)

Allows writing a CallStack into an std::ostream.

Parameters
[in,out]osThe output stream to write to.
[in]callStackThe CallStack to write.
Returns
A reference to the input stream.
boost::log::formatting_ostream & dg::deepcore::operator<< ( boost::log::formatting_ostream &  os,
const CallStackSymbol &  symbol 
)

Allows logging a CallStackSymbol with DG_LOG.

Parameters
[in,out]osThe stream to write to.
[in]symbolThe CallStackSymbol to write.
Returns
A reference to the input stream.
boost::log::formatting_ostream & dg::deepcore::operator<< ( boost::log::formatting_ostream &  os,
const CallStack &  callStack 
)

Allows logging a CallStack with DG_LOG.

Parameters
[in,out]osThe stream to write to.
[in]callStackThe CallStack to write.
Returns
A reference to the input stream.
string dg::deepcore::network::parseJsonMessage ( const string &  json)
noexcept

Extracts a "message" object from the root object of a JSON string.

Parameters
[in]jsonThe JSON string.
Returns
The contents for the "message" object. If the input string is not JSON or if the "message" object does not exist, an empty string is returned.
detail::cmdline::style_parser boost::program_options::postfix_argument ( const std::string &  postfix)

Factory for a boost::program_options::detail::style_parser that allows grouping of parameters with the same postfix in a key/value fashion.

Parameters
postfixThe postfix of the parameters to group.
Returns
The style parser.
Note
This parser works for prefixed arguments with either zero or one options.

For zero options the acceptable formats are −−<key>-<prefix> or −−<prefix> <key1> <key2> <key3> ...

For one option the acceptable formats are −−<key>-<prefix> <value> or −−<prefix> <key1> <value1> <key2> <value2> <key3> <value3> ...

Either option format can be specified multiple times, they will all be grouped in the same command line option named "<prefix>".

Example usage:

po::options_description desc;
desc.add_options()
("one-foo", po::value<string>(), "one foo")
("three-foo", po::value<string>(), "three foo")
("five-foo", po::value<string>(), "five foo")
("foo", po::value<vector<string>>()->multitoken(), "all foos")
;
po::variables_map vm;
po::store(po::command_line_parser(argc, argv)
.options(desc)
.extra_style_parser(po::postfix_argument("foo"))
.run(),
vm
);
auto result = vm["foo"].as<vector<string>>();
// command line: myprogram --one-foo two --three-foo four --foo five six
// result == { "one", "two", "three", "four", "five", "six" }
double dg::deepcore::radians ( double  degrees)
noexcept

Convert degrees to radians.

Parameters
degreesValue in degrees.
Returns
Value in radians.
cv::Point2d dg::deepcore::radians ( const cv::Point2d &  degrees)
noexcept

Convert degrees to radians.

Parameters
[in]degreesValue in degrees.
Returns
Value in radians.
cv::Size2d dg::deepcore::radians ( const cv::Size2d &  degrees)
noexcept

Convert degrees to radians.

Parameters
[in]degreesValue in degrees.
Returns
Value in radians.
cv::Rect2d dg::deepcore::radians ( const cv::Rect2d &  degrees)
noexcept

Convert degrees to radians.

Parameters
[in]degreesValue in degrees.
Returns
Value in radians.
size_t dg::deepcore::UnZipFile::readFile ( uint8_t *  buf,
size_t  size,
const std::string &  password = "" 
)

Reads the current file from the archive into a memory buffer.

Parameters
[out]bufThe buffer to read the data into. Must not be nullptr.
[in]sizeSize of the buffer. If the buffer is smaller than the current file, the file will only be read partially.
[in]passwordPassword for the file if it was encrypted. If the password is incorrect, an exception will be thrown.
Returns
Number of bytes read.
Note
The archive must be open. If it's closed an exception will be thrown.
ostream & dg::deepcore::UnZipFile::readFile ( std::ostream &  os,
const std::string &  password = "" 
)

Reads the current file from the archive into an output stream.

Parameters
[in,out]osThe output stream to read the data into.
[in]passwordPassword for the file if it was encrypted. If the password is incorrect, an exception will be thrown.
Returns
Reference to the output stream.
Note
The archive must be open. If it's closed an exception will be thrown.
vector< uint8_t > dg::deepcore::UnZipFile::readFile ( const std::string &  password = "")

Reads the current file from the archive into a vector.

Parameters
[in]passwordPassword for the file if it was encrypted. If the password is incorrect, an exception will be thrown.
Returns
A vector containing the file's data.
Note
The archive must be open. If it's closed an exception will be thrown.
string dg::deepcore::UnZipFile::readFileToString ( const std::string &  password = "")

Reads the current file from the archive into a string.

Parameters
[in]passwordPassword for the file if it was encrypted. If the password is incorrect, an exception will be thrown.
Returns
A string containing the file's data.
Note
The archive must be open. If it's closed an exception will be thrown.
std::string dg::deepcore::readMaskedInputFromConsole ( )

Initializes a getline that is masked for the purposes of hiding the user input of a password.

Returns
The password entered by the user
void dg::deepcore::log::removeSink ( boost::shared_ptr< sinks::sink > const &  sink)

remove a log sink

Parameters
[in]sinkthe sink to remove

If any sinks were added and all are removed, the logger uses a default sink

void dg::deepcore::MultiProgressDisplay::start ( )

Starts and displays the progress meter(s).

void dg::deepcore::MultiProgressDisplay::stop ( )

Stops the progress meter(s).

level_t dg::deepcore::log::stringToLevel ( const std::string &  str)

Convert a string representation of logging level to enum.

Parameters
[in]strThe string representation of logging level.
Returns
The enum representation of logging level.
Logger & dg::deepcore::log::threadLogger ( )

get the global static instance

void dg::deepcore::MultiProgressDisplay::update ( size_t  categoryId,
float  progress 
)

Updateds progress.

Parameters
[in]categoryIdIndex of the progress category to update. Must be
[in]progress
const char * dg::deepcore::Error::what ( ) const
overridevirtualnoexcept

Returns the error description in format "{message} in {function}, file: {file}, line: {line}.".

Returns
The error description.