DISPLACE  1.0
A spatial model of fisheries to help sustainable fishing and maritime spatial planning
dtree::DecisionTreeManager Class Reference

A class that implements a Singleton for managing the Decision Trees for vessels. More...

#include <decisiontreemanager.h>

Public Types

enum  TreeType {
  InvalidTreeType = -1, GoFishing, ChooseGround, StartFishing,
  ChangeGround, StopFishing, ChoosePort, SIZE
}
 An enumerated type to identify which tree to refer. They are internally used as index to various container classes (mostly vectors) so don't change the integer values, especially for InvalidTreeType and SIZE (that must be the last). More...
 

Public Member Functions

int readFromDirectory (std::string path)
 Read all the dtrees in a directory, returning the number of loaded trees. More...
 
int readFromScenario (std::string path, displace::commons::Scenario scenario)
 
std::shared_ptr< dtree::DecisionTreetree (TreeType type)
 Returns a reference to the specified tree. More...
 
bool hasTree (TreeType type)
 
bool hasTreeVariable (TreeType type, dtree::Variable variable) const
 

Static Public Member Functions

static DecisionTreeManagermanager ()
 returns the instance of the singleton. Uses lazy initialization to proper initialize the instance. More...
 
static std::string treeTypeCode (TreeType type)
 
static TreeType treeTypeFromCode (std::string code)
 

Protected Member Functions

bool readFile (std::string filename)
 Loads a specific file, creating the dtree and allocating it to the type specified in the file. More...
 
void readScenarioFileIfAvailable (std::string path, std::string scenarioname)
 

Detailed Description

A class that implements a Singleton for managing the Decision Trees for vessels.

Member Enumeration Documentation

◆ TreeType

An enumerated type to identify which tree to refer. They are internally used as index to various container classes (mostly vectors) so don't change the integer values, especially for InvalidTreeType and SIZE (that must be the last).

Enumerator
InvalidTreeType 
GoFishing 
ChooseGround 
StartFishing 
ChangeGround 
StopFishing 
ChoosePort 
SIZE 

Member Function Documentation

◆ hasTree()

bool DecisionTreeManager::hasTree ( DecisionTreeManager::TreeType  type)

◆ hasTreeVariable()

bool DecisionTreeManager::hasTreeVariable ( DecisionTreeManager::TreeType  type,
dtree::Variable  variable 
) const

◆ manager()

static DecisionTreeManager* dtree::DecisionTreeManager::manager ( )
inlinestatic

returns the instance of the singleton. Uses lazy initialization to proper initialize the instance.

◆ readFile()

bool DecisionTreeManager::readFile ( std::string  filename)
protected

Loads a specific file, creating the dtree and allocating it to the type specified in the file.

◆ readFromDirectory()

int DecisionTreeManager::readFromDirectory ( std::string  path)

Read all the dtrees in a directory, returning the number of loaded trees.

◆ readFromScenario()

int DecisionTreeManager::readFromScenario ( std::string  path,
displace::commons::Scenario  scenario 
)

◆ readScenarioFileIfAvailable()

void DecisionTreeManager::readScenarioFileIfAvailable ( std::string  path,
std::string  scenarioname 
)
protected

◆ tree()

std::shared_ptr< dtree::DecisionTree > DecisionTreeManager::tree ( DecisionTreeManager::TreeType  type)

Returns a reference to the specified tree.

◆ treeTypeCode()

std::string DecisionTreeManager::treeTypeCode ( DecisionTreeManager::TreeType  type)
static

◆ treeTypeFromCode()

DecisionTreeManager::TreeType DecisionTreeManager::treeTypeFromCode ( std::string  code)
static

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