FMT 1.2.0
Forest management tools for forest planning
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Static Protected Attributes | Friends | List of all members
Core::FMTObject Class Reference

Base class of multiple FMT classes holding a shared exception handler pointer and logger. More...

#include <FMTObject.h>

Inheritance diagram for Core::FMTObject:
[legend]
Collaboration diagram for Core::FMTObject:
[legend]

Public Member Functions

 FMTObject ()
 Default constructor for FMTObject.
 
virtual ~FMTObject ()
 Default virtual destructor for FMTObject.
 
 FMTObject (const std::unique_ptr< Exception::FMTExceptionHandler > exhandler)
 Construct a FMTObject passing in the exception handler of another FMTObject.
 
 FMTObject (const FMTObject &rhs)
 Copy constructor for FMTObject.
 
FMTObjectoperator= (const FMTObject &rhs)
 Copy assignment operator for FMTObject.
 
virtual void passInLogger (const std::unique_ptr< Logging::FMTLogger > &logger)
 Pass in the logger of another FMTObject.
 
void passInExceptionHandler (const std::unique_ptr< Exception::FMTExceptionHandler > &exhandler)
 Pass in the exception handler of another FMTObject.
 
void redirectLogToFile (const std::string &location)
 Redirect the log to a specific file, appending to it.
 
virtual void setDefaultLogger ()
 Create and set a default logger to the FMTObject.
 
virtual void setQuietLogger ()
 Create and set a quiet logger to the FMTObject.
 
virtual void setTaskLogger ()
 Create and set a task logger to the FMTObject.
 
virtual void setDebugLogger ()
 Create and set a debug logger to the FMTObject.
 
void setDefaultExceptionHandler ()
 Create and set a default exception handler to the FMTObject.
 
void setQuietExceptionHandler ()
 Create and set a quiet exception handler to the FMTObject.
 
void setDebugExceptionHandler ()
 Create and set a debug exception handler to the FMTObject.
 
void setFreeExceptionHandler ()
 Create and set a free exception handler to the FMTObject.
 
void disableNestedExceptions ()
 Disable the nested exception throw of the exception handler.
 
void enableNestedExceptions ()
 Enable the nested exception throw of the exception handler.
 
void setErrorsToWarnings (const std::vector< Exception::FMTexc > &errors)
 Set a list of errors to be cast to warnings on the exception handler.
 
void setMaxWarningsBeforeSilenced (const size_t &maxwarningcount)
 Set the number of warnings raised before being silenced.
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Static Public Member Functions

static Logging::FMTLoggergetLogger ()
 get a pointer to the actual logger.
 
static Exception::FMTExceptionHandlergetExceptionHandler ()
 get a pointer to the actual exception handler.
 
static std::string getRuntimeLocation ()
 Return the location of the FMT shared library.
 
static unsigned long long getAvailableMemory ()
 Return the available memory in bytes.
 
static void setTerminateStack ()
 will write the stack in the log when terminate called and raise a function failed.
 
static void setAbortStack ()
 will write the stack in the log when abort called with SIGABRT and raise a function failed.
 

Protected Member Functions

template<class Archive >
void forceSave (Archive &ar, const unsigned int version) const
 Force the serialization to save useful information, which the default FMTObject serialization does not.
 
template<class Archive >
void forceLoad (Archive &ar, const unsigned int version)
 Force the serialization to load useful information, which the default FMTObject serialization does not.
 
void checkSignals () const
 Check if the user has sent a ctrl-c signal using boost::python to FMT.
 
void setCplHandler ()
 Pass the FMT exception handler to the GDAL exception handler (GDAL only).
 

Static Protected Member Functions

static std::chrono::time_point< std::chrono::high_resolution_clock > getClock ()
 Return a clock of the current time.
 
template<class chrono >
static double getDuration (const std::chrono::time_point< std::chrono::high_resolution_clock > &startclock)
 Return the time elapsed since a start clock as a double.
 
static std::string getDurationInSeconds (const std::chrono::time_point< std::chrono::high_resolution_clock > &startclock)
 Return the time elapsed since a start clock in seconds as a string.
 
static void _logStack ()
 Log the stack trace...
 
static void _terminate ()
 Raise an error with the boost stacktrace.
 
static void _abort (int p_signal)
 Raise an error with the boost stacktrace on abort.
 

Static Protected Attributes

static std::unique_ptr< Exception::FMTExceptionHandler_exhandler
 A shared pointer to the exception handler.
 
static std::unique_ptr< Logging::FMTLogger_logger
 A shared pointer to the logger.
 

Friends

class boost::serialization::access
 Serialize the FMTObject for multiprocessing across multiple cpus (pickle in Python).
 

Detailed Description

Base class of multiple FMT classes holding a shared exception handler pointer and logger.

Plays a major role in exception handling and ctrl-c signals for boost::python, and provides utility functions for mask validation and runtime location.

Constructor & Destructor Documentation

◆ FMTObject() [1/3]

Core::FMTObject::FMTObject ( )

Default constructor for FMTObject.

◆ ~FMTObject()

virtual Core::FMTObject::~FMTObject ( )
virtual

Default virtual destructor for FMTObject.

◆ FMTObject() [2/3]

Core::FMTObject::FMTObject ( const std::unique_ptr< Exception::FMTExceptionHandler exhandler)

Construct a FMTObject passing in the exception handler of another FMTObject.

Parameters
[in]exhandlerthe exception handler to pass in.

◆ FMTObject() [3/3]

Core::FMTObject::FMTObject ( const FMTObject rhs)

Copy constructor for FMTObject.

Parameters
[in]rhsthe FMTObject to copy.

Member Function Documentation

◆ _abort()

static void Core::FMTObject::_abort ( int  p_signal)
staticprotected

Raise an error with the boost stacktrace on abort.

Parameters
[in]p_signalthe signal for abort.

◆ _logStack()

static void Core::FMTObject::_logStack ( )
staticprotected

Log the stack trace...

◆ _terminate()

static void Core::FMTObject::_terminate ( )
staticprotected

Raise an error with the boost stacktrace.

◆ checkSignals()

void Core::FMTObject::checkSignals ( ) const
protected

Check if the user has sent a ctrl-c signal using boost::python to FMT.

◆ disableNestedExceptions()

void Core::FMTObject::disableNestedExceptions ( )

Disable the nested exception throw of the exception handler.

◆ enableNestedExceptions()

void Core::FMTObject::enableNestedExceptions ( )

Enable the nested exception throw of the exception handler.

◆ forceLoad()

template<class Archive >
void Core::FMTObject::forceLoad ( Archive &  ar,
const unsigned int  version 
)
inlineprotected

Force the serialization to load useful information, which the default FMTObject serialization does not.

Template Parameters
Archivethe archive type.
Parameters
[in,out]arthe archive to load from.
[in]versionthe serialization version.

◆ forceSave()

template<class Archive >
void Core::FMTObject::forceSave ( Archive &  ar,
const unsigned int  version 
) const
inlineprotected

Force the serialization to save useful information, which the default FMTObject serialization does not.

Template Parameters
Archivethe archive type.
Parameters
[in,out]arthe archive to save to.
[in]versionthe serialization version.

◆ getAvailableMemory()

static unsigned long long Core::FMTObject::getAvailableMemory ( )
static

Return the available memory in bytes.

Returns
the available memory in bytes.

◆ getClock()

static std::chrono::time_point< std::chrono::high_resolution_clock > Core::FMTObject::getClock ( )
staticprotected

Return a clock of the current time.

Returns
a clock of the current time.

◆ getDuration()

template<class chrono >
static double Core::FMTObject::getDuration ( const std::chrono::time_point< std::chrono::high_resolution_clock > &  startclock)
staticprotected

Return the time elapsed since a start clock as a double.

Template Parameters
chronothe duration type.
Parameters
[in]startclockthe start clock.
Returns
the elapsed time.

◆ getDurationInSeconds()

static std::string Core::FMTObject::getDurationInSeconds ( const std::chrono::time_point< std::chrono::high_resolution_clock > &  startclock)
staticprotected

Return the time elapsed since a start clock in seconds as a string.

Parameters
[in]startclockthe start clock.
Returns
the elapsed time in seconds.

◆ getExceptionHandler()

static Exception::FMTExceptionHandler * Core::FMTObject::getExceptionHandler ( )
static

get a pointer to the actual exception handler.

Returns
the valid FMTExceptionHandler;

◆ getLogger()

static Logging::FMTLogger * Core::FMTObject::getLogger ( )
static

get a pointer to the actual logger.

Returns
the valid FMTLogger

◆ getRuntimeLocation()

static std::string Core::FMTObject::getRuntimeLocation ( )
static

Return the location of the FMT shared library.

Returns
the runtime location of the FMT shared library.

◆ operator=()

FMTObject & Core::FMTObject::operator= ( const FMTObject rhs)

Copy assignment operator for FMTObject.

Parameters
[in]rhsthe FMTObject to copy.
Returns
a reference to this FMTObject.

◆ passInExceptionHandler()

void Core::FMTObject::passInExceptionHandler ( const std::unique_ptr< Exception::FMTExceptionHandler > &  exhandler)

Pass in the exception handler of another FMTObject.

Parameters
[in]exhandlerthe exception handler to pass in.

◆ passInLogger()

virtual void Core::FMTObject::passInLogger ( const std::unique_ptr< Logging::FMTLogger > &  logger)
virtual

Pass in the logger of another FMTObject.

Parameters
[in]loggerthe logger to pass in.

Reimplemented in Models::FMTLpSolver, Parallel::FMTOpAreaSchedulerTask, Parallel::FMTPlanningTask, Parallel::FMTReplanningTask, Models::FMTSrModel, and Parallel::FMTTaskHandler.

◆ redirectLogToFile()

void Core::FMTObject::redirectLogToFile ( const std::string &  location)

Redirect the log to a specific file, appending to it.

Parameters
[in]locationthe file to redirect the log to.

◆ serialize()

template<class Archive >
void Core::FMTObject::serialize ( Archive &  ar,
const unsigned int  version 
)
inline

◆ setAbortStack()

static void Core::FMTObject::setAbortStack ( )
static

will write the stack in the log when abort called with SIGABRT and raise a function failed.

◆ setCplHandler()

void Core::FMTObject::setCplHandler ( )
protected

Pass the FMT exception handler to the GDAL exception handler (GDAL only).

◆ setDebugExceptionHandler()

void Core::FMTObject::setDebugExceptionHandler ( )

Create and set a debug exception handler to the FMTObject.

◆ setDebugLogger()

virtual void Core::FMTObject::setDebugLogger ( )
virtual

Create and set a debug logger to the FMTObject.

◆ setDefaultExceptionHandler()

void Core::FMTObject::setDefaultExceptionHandler ( )

Create and set a default exception handler to the FMTObject.

◆ setDefaultLogger()

virtual void Core::FMTObject::setDefaultLogger ( )
virtual

Create and set a default logger to the FMTObject.

◆ setErrorsToWarnings()

void Core::FMTObject::setErrorsToWarnings ( const std::vector< Exception::FMTexc > &  errors)

Set a list of errors to be cast to warnings on the exception handler.

Parameters
[in]errorsthe errors to treat as warnings.

◆ setFreeExceptionHandler()

void Core::FMTObject::setFreeExceptionHandler ( )

Create and set a free exception handler to the FMTObject.

◆ setMaxWarningsBeforeSilenced()

void Core::FMTObject::setMaxWarningsBeforeSilenced ( const size_t &  maxwarningcount)

Set the number of warnings raised before being silenced.

Parameters
[in]maxwarningcountthe maximum warning count.

◆ setQuietExceptionHandler()

void Core::FMTObject::setQuietExceptionHandler ( )

Create and set a quiet exception handler to the FMTObject.

◆ setQuietLogger()

virtual void Core::FMTObject::setQuietLogger ( )
virtual

Create and set a quiet logger to the FMTObject.

◆ setTaskLogger()

virtual void Core::FMTObject::setTaskLogger ( )
virtual

Create and set a task logger to the FMTObject.

◆ setTerminateStack()

static void Core::FMTObject::setTerminateStack ( )
static

will write the stack in the log when terminate called and raise a function failed.

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Serialize the FMTObject for multiprocessing across multiple cpus (pickle in Python).

Template Parameters
Archivethe archive type.
Parameters
[in,out]arthe archive to serialize to or from.
[in]versionthe serialization version.

Member Data Documentation

◆ _exhandler

std::unique_ptr<Exception::FMTExceptionHandler> Core::FMTObject::_exhandler
staticprotected

A shared pointer to the exception handler.

◆ _logger

std::unique_ptr<Logging::FMTLogger> Core::FMTObject::_logger
staticprotected

A shared pointer to the logger.


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