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

Class holding the attributes and aggregates of a single theme, describing a part of a FMTMask. More...

#include <FMTTheme.h>

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

Public Member Functions

 FMTTheme ()
 Default constructor for FMTTheme.
 
 ~FMTTheme ()=default
 Default destructor for FMTTheme.
 
 FMTTheme (const std::vector< std::string > &p_attributes, const std::vector< std::string > &p_attributenames, const std::vector< std::string > &p_aggregates, const std::vector< std::vector< std::string > > &p_aggregatenames, const std::vector< std::map< std::string, double > > &p_indexes, const size_t &p_id, const size_t &p_start, const std::string &p_name)
 Constructor used for theme indexing with indexes.
 
 FMTTheme (const std::vector< std::string > &p_attributes, const std::vector< std::string > &p_attributenames, const std::vector< std::string > &p_aggregates, const std::vector< std::vector< std::string > > &p_aggregatenames, const size_t &p_id, const size_t &p_start, const std::string &p_name)
 Constructor used for theme indexing.
 
 FMTTheme (const std::vector< std::string > &p_attributes, const size_t &p_id, const size_t &p_start, const std::string &p_name)
 Simpler constructor for a theme without aggregates or indexing.
 
 FMTTheme (const FMTTheme &rhs)
 Copy constructor for FMTTheme.
 
FMTThemeoperator= (const FMTTheme &rhs)
 Copy assignment operator for FMTTheme.
 
bool isAttribute (const std::string &p_value) const
 Return true if the value is an attribute of the theme.
 
bool isAggregate (const std::string &p_value) const
 Return true if the value is an aggregate of the theme.
 
bool isIndex (const std::string &p_attribute, const std::string &p_value) const
 Return true if the value is an index of the theme for a given attribute (yields section only).
 
bool isIndex (const std::string &p_value) const
 Return true if the value is an index of the theme (yields section only).
 
bool useIndex () const
 Return true if the theme uses indexes.
 
double getIndex (const std::string &p_attribute, const std::string &p_value) const
 Get the index value for a given attribute and index.
 
bool inAggregate (const std::string &p_value, const std::string &p_aggregate)
 Check if a value is part of an aggregate.
 
bool isValid (const std::string &p_value) const
 Check if a value is a valid attribute, aggregate or question mark for the theme.
 
bool operator== (const FMTTheme &p_rhs) const
 Equality comparison operator of FMTTheme.
 
size_t size () const
 Return the size of the theme, 0 if it has no attribute.
 
const size_t & getStart () const
 Return the bit location of the mask at which the theme starts.
 
const size_t & getId () const
 Return the id of the theme.
 
std::string getName () const
 Return the name of the theme.
 
bool empty () const
 Return true if the theme has no attribute.
 
std::vector< std::string > getAttributes (const std::string &p_value, bool p_aggregate_source=false) const
 Get the attributes of an aggregate for the theme.
 
const std::vector< std::string > & getBaseAttributes () const
 Return a reference to the base attributes of the theme.
 
const std::vector< std::string > & getAttributeNames () const
 Return the names of the attributes.
 
FMTTheme preSolve (FMTMaskFilter &p_maskfilter, size_t &p_newid, size_t &p_newstart) const
 Presolve the theme, removing unused attributes based on the filter and assigning a new id and start.
 
std::string updateFromMask (const Core::FMTMask &p_globalmask)
 Update the theme with the aggregates in a global mask or with newly created aggregates and return the new attribute value.
 
 operator std::string () const
 Return a string representation of the theme as seen in a landscape file.
 
std::vector< std::string > getAggregates () const
 Return the aggregates of the theme.
 
- Public Member Functions inherited from Core::FMTObject
 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 bool validate (const std::vector< Core::FMTTheme > &p_themes, std::string &p_mask, std::string p_otherinformation=std::string())
 Validate the construction of a valid mask string based on the themes, trimming the mask if there are fewer themes than in the string.
 
static bool checkMask (const std::vector< Core::FMTTheme > &p_themes, const std::vector< std::string > &p_values, std::string &p_mask, const std::string &p_otherinformation)
 Validate the mask string for a vector of themes and throw an exception if something is wrong, called by validate.
 
- Static Public Member Functions inherited from Core::FMTObject
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 Attributes

size_t m_id
 Id is the id of the theme first theme in the landscape section is number 1.
 
size_t m_start
 Start is the bit location in the FMTMask at which the attributes of the theme starts.
 

Friends

class FMTMask
 
class Parser::FMTLandscapeParser
 
class boost::serialization::access
 Serialize the FMTTheme through its base FMTObject for multiprocessing across multiple cpus (pickle in Python).
 

Additional Inherited Members

- Protected Member Functions inherited from Core::FMTObject
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 inherited from Core::FMTObject
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 inherited from Core::FMTObject
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.
 

Detailed Description

Class holding the attributes and aggregates of a single theme, describing a part of a FMTMask.

A FMTTheme describes a part of a FMTMask from its start bit to start + size, and holds the attribute aggregates. It is closely related to FMTMask.

Constructor & Destructor Documentation

◆ FMTTheme() [1/5]

Core::FMTTheme::FMTTheme ( )

Default constructor for FMTTheme.

◆ ~FMTTheme()

Core::FMTTheme::~FMTTheme ( )
default

Default destructor for FMTTheme.

◆ FMTTheme() [2/5]

Core::FMTTheme::FMTTheme ( const std::vector< std::string > &  p_attributes,
const std::vector< std::string > &  p_attributenames,
const std::vector< std::string > &  p_aggregates,
const std::vector< std::vector< std::string > > &  p_aggregatenames,
const std::vector< std::map< std::string, double > > &  p_indexes,
const size_t &  p_id,
const size_t &  p_start,
const std::string &  p_name 
)

Constructor used for theme indexing with indexes.

Parameters
[in]p_attributesthe attributes.
[in]p_attributenamesthe attribute names.
[in]p_aggregatesthe aggregates.
[in]p_aggregatenamesthe aggregate names.
[in]p_indexesthe indexes of each attribute.
[in]p_idthe id of the theme.
[in]p_startthe start bit location.
[in]p_namethe name of the theme.

◆ FMTTheme() [3/5]

Core::FMTTheme::FMTTheme ( const std::vector< std::string > &  p_attributes,
const std::vector< std::string > &  p_attributenames,
const std::vector< std::string > &  p_aggregates,
const std::vector< std::vector< std::string > > &  p_aggregatenames,
const size_t &  p_id,
const size_t &  p_start,
const std::string &  p_name 
)

Constructor used for theme indexing.

Parameters
[in]p_attributesthe attributes.
[in]p_attributenamesthe attribute names.
[in]p_aggregatesthe aggregates.
[in]p_aggregatenamesthe aggregate names.
[in]p_idthe id of the theme.
[in]p_startthe start bit location.
[in]p_namethe name of the theme.

◆ FMTTheme() [4/5]

Core::FMTTheme::FMTTheme ( const std::vector< std::string > &  p_attributes,
const size_t &  p_id,
const size_t &  p_start,
const std::string &  p_name 
)

Simpler constructor for a theme without aggregates or indexing.

Parameters
[in]p_attributesthe attributes.
[in]p_idthe id of the theme.
[in]p_startthe start bit location.
[in]p_namethe name of the theme.

◆ FMTTheme() [5/5]

Core::FMTTheme::FMTTheme ( const FMTTheme rhs)

Copy constructor for FMTTheme.

Parameters
[in]rhsthe FMTTheme to copy.

Member Function Documentation

◆ checkMask()

static bool Core::FMTTheme::checkMask ( const std::vector< Core::FMTTheme > &  p_themes,
const std::vector< std::string > &  p_values,
std::string &  p_mask,
const std::string &  p_otherinformation 
)
static

Validate the mask string for a vector of themes and throw an exception if something is wrong, called by validate.

Parameters
[in]p_themesthe themes.
[in]p_valuesthe attribute values.
[in,out]p_maskthe mask string.
[in]p_otherinformationadditional information.
Returns
true if the mask is valid else false.

◆ empty()

bool Core::FMTTheme::empty ( ) const
inline

Return true if the theme has no attribute.

Returns
true if the theme is empty else false.

◆ getAggregates()

std::vector< std::string > Core::FMTTheme::getAggregates ( ) const

Return the aggregates of the theme.

Returns
the aggregates of the theme.

◆ getAttributeNames()

const std::vector< std::string > & Core::FMTTheme::getAttributeNames ( ) const
inline

Return the names of the attributes.

Returns
the names of the attributes.

◆ getAttributes()

std::vector< std::string > Core::FMTTheme::getAttributes ( const std::string &  p_value,
bool  p_aggregate_source = false 
) const

Get the attributes of an aggregate for the theme.

Parameters
[in]p_valuethe aggregate.
[in]p_aggregate_sourceif true uses the aggregate source map.
Returns
the attributes of the aggregate.

◆ getBaseAttributes()

const std::vector< std::string > & Core::FMTTheme::getBaseAttributes ( ) const
inline

Return a reference to the base attributes of the theme.

Returns
a reference to the base attributes.

◆ getId()

const size_t & Core::FMTTheme::getId ( ) const
inline

Return the id of the theme.

Returns
the id of the theme.

◆ getIndex()

double Core::FMTTheme::getIndex ( const std::string &  p_attribute,
const std::string &  p_value 
) const

Get the index value for a given attribute and index.

Parameters
[in]p_attributethe attribute.
[in]p_valuethe index.
Returns
the index value.

◆ getName()

std::string Core::FMTTheme::getName ( ) const
inline

Return the name of the theme.

Returns
the name of the theme.

◆ getStart()

const size_t & Core::FMTTheme::getStart ( ) const
inline

Return the bit location of the mask at which the theme starts.

Returns
the start bit location.

◆ inAggregate()

bool Core::FMTTheme::inAggregate ( const std::string &  p_value,
const std::string &  p_aggregate 
)

Check if a value is part of an aggregate.

Parameters
[in]p_valuethe value to check.
[in]p_aggregatethe aggregate.
Returns
true if the value is part of the aggregate else false.

◆ isAggregate()

bool Core::FMTTheme::isAggregate ( const std::string &  p_value) const
inline

Return true if the value is an aggregate of the theme.

Parameters
[in]p_valuethe value to check.
Returns
true if the value is an aggregate else false.

◆ isAttribute()

bool Core::FMTTheme::isAttribute ( const std::string &  p_value) const
inline

Return true if the value is an attribute of the theme.

Parameters
[in]p_valuethe value to check.
Returns
true if the value is an attribute else false.

◆ isIndex() [1/2]

bool Core::FMTTheme::isIndex ( const std::string &  p_attribute,
const std::string &  p_value 
) const

Return true if the value is an index of the theme for a given attribute (yields section only).

Parameters
[in]p_attributethe attribute.
[in]p_valuethe value to check.
Returns
true if the value is an index else false.

◆ isIndex() [2/2]

bool Core::FMTTheme::isIndex ( const std::string &  p_value) const

Return true if the value is an index of the theme (yields section only).

Parameters
[in]p_valuethe value to check.
Returns
true if the value is an index else false.

◆ isValid()

bool Core::FMTTheme::isValid ( const std::string &  p_value) const

Check if a value is a valid attribute, aggregate or question mark for the theme.

Parameters
[in]p_valuethe value to check.
Returns
true if the value is valid else false.

◆ operator std::string()

Core::FMTTheme::operator std::string ( ) const

Return a string representation of the theme as seen in a landscape file.

Returns
the string representation of the theme.

◆ operator=()

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

Copy assignment operator for FMTTheme.

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

◆ operator==()

bool Core::FMTTheme::operator== ( const FMTTheme p_rhs) const

Equality comparison operator of FMTTheme.

Parameters
[in]p_rhsthe theme to compare with.
Returns
true if both themes are equal else false.

◆ preSolve()

FMTTheme Core::FMTTheme::preSolve ( FMTMaskFilter p_maskfilter,
size_t &  p_newid,
size_t &  p_newstart 
) const

Presolve the theme, removing unused attributes based on the filter and assigning a new id and start.

Parameters
[in,out]p_maskfilterthe mask filter.
[in,out]p_newidthe new id, incremented if the presolved theme is not empty and has size greater than 1.
[in,out]p_newstartthe new start, incremented accordingly.
Returns
the presolved theme.

◆ size()

size_t Core::FMTTheme::size ( ) const
inline

Return the size of the theme, 0 if it has no attribute.

Returns
the size of the theme.

◆ updateFromMask()

std::string Core::FMTTheme::updateFromMask ( const Core::FMTMask p_globalmask)

Update the theme with the aggregates in a global mask or with newly created aggregates and return the new attribute value.

Parameters
[in]p_globalmaskthe global mask.
Returns
the new attribute value.

◆ useIndex()

bool Core::FMTTheme::useIndex ( ) const

Return true if the theme uses indexes.

Returns
true if the theme uses indexes else false.

◆ validate()

static bool Core::FMTTheme::validate ( const std::vector< Core::FMTTheme > &  p_themes,
std::string &  p_mask,
std::string  p_otherinformation = std::string() 
)
static

Validate the construction of a valid mask string based on the themes, trimming the mask if there are fewer themes than in the string.

Parameters
[in]p_themesthe themes.
[in,out]p_maskthe mask string.
[in]p_otherinformationoptional additional information.
Returns
true if the mask is valid else false.

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Serialize the FMTTheme through its base 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.

◆ FMTMask

friend class FMTMask
friend

◆ Parser::FMTLandscapeParser

friend class Parser::FMTLandscapeParser
friend

Member Data Documentation

◆ m_id

size_t Core::FMTTheme::m_id
protected

Id is the id of the theme first theme in the landscape section is number 1.

◆ m_start

size_t Core::FMTTheme::m_start
protected

Start is the bit location in the FMTMask at which the attributes of the theme starts.


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