Pakman
AbstractController Class Referenceabstract

#include <AbstractController.h>

Inheritance diagram for AbstractController:

Public Member Functions

 AbstractController ()=default
 
virtual ~AbstractController ()=default
 
void assignMaster (std::shared_ptr< AbstractMaster > p_master)
 
virtual void iterate ()=0
 
virtual Command getSimulator () const =0
 

Static Public Member Functions

static controller_t getController (const std::string &arg)
 
static std::string help (controller_t controller)
 
static void addLongOptions (controller_t controller, LongOptions &lopts)
 
static AbstractControllermakeController (controller_t controller, const Arguments &args)
 

Protected Attributes

std::shared_ptr< AbstractMasterm_p_master
 

Detailed Description

An abstract class for submitting simulation tasks.

AbstractControllers are responsible for submitting simulation tasks to an instantiation of AbstractMaster, as part of some algorithm.

The AbstractController::assignMaster() and AbstractMaster::assignController() methods are used for assigning AbstractMaster and AbstractController objects to each other.

AbstractControllers are designed for use in an event loop. The AbstractController::iterate() method should be called repeatedly by AbstractMaster. The AbstractController should call AbstractMaster::terminate() on its assigned AbstractMaster when the algorithm has finished.

From the perspective of AbstractController, the AbstractMaster is a black box that it pushes tasks to (via AbstractMaster::pushPendingTask()), and retrieves finished tasks from (via AbstractMaster::frontFinishedTask()). This simplifies the design of Controller classes to implement new algorithms, since the programmer does not need to worry about the execution of the tasks.

The use of AbstractController is governed by static methods. The static addLongOptions() and help() methods determine which command-line options the Controller accepts and return a help message explaining the options, respectively. The static makeController() method is a factory method that creates a Controller from command-line arguments.

Definition at line 44 of file AbstractController.h.

Constructor & Destructor Documentation

◆ AbstractController()

AbstractController::AbstractController ( )
default

Default constructor does nothing.

◆ ~AbstractController()

virtual AbstractController::~AbstractController ( )
virtualdefault

Default destructor does nothing.

Member Function Documentation

◆ addLongOptions()

void AbstractController::addLongOptions ( controller_t  controller,
LongOptions lopts 
)
static

Add Controller-specific long command-line options to the given LongOptions object.

When subclassing AbstractController, be sure to include a static method with the signature

static void addLongOptions(LongOptions& lopts)

and add an entry in the switch statement of AbstractController::addLongOptions().

Parameters
controllerController type.
loptslong command-line options that the Controller needs.

Definition at line 50 of file AbstractControllerStatic.cc.

◆ assignMaster()

void AbstractController::assignMaster ( std::shared_ptr< AbstractMaster p_master)

Assign pointer to AbstractMaster.

Parameters
p_masterpointer to AbstractMaster object to be assigned to AbstractController.

Definition at line 6 of file AbstractController.cc.

◆ getController()

controller_t AbstractController::getController ( const std::string &  arg)
static

Interpret string as Controller type.

The controller_t enumeration type is defined in common.h.

Parameters
argstring to be interpreted.
Returns
the Controller type.

Definition at line 16 of file AbstractControllerStatic.cc.

◆ getSimulator()

virtual Command AbstractController::getSimulator ( ) const
pure virtual
Returns
simulator command.

Implemented in ABCRejectionController, ABCSMCController, and SweepController.

◆ help()

std::string AbstractController::help ( controller_t  controller)
static

Return help message based on Controller type.

When subclassing AbstractController, be sure to include a static method with the signature

static std::string help()

and add an entry in the switch statement of AbstractController::help().

Parameters
controllerController type.
Returns
help message string.

Definition at line 34 of file AbstractControllerStatic.cc.

◆ iterate()

virtual void AbstractController::iterate ( )
pure virtual

Iterates the AbstractController. Should be called by a Master.

Implemented in ABCRejectionController, ABCSMCController, and SweepController.

◆ makeController()

AbstractController * AbstractController::makeController ( controller_t  controller,
const Arguments args 
)
static

Create Controller instance based on Controller type.

When subclassing AbstractController, be sure to include a static method with the signature

and add an entry in the switch statement of AbstractController::help()

Parameters
controllerController type.
argscommand-line arguments.
Returns
pointer to created Controller instance.

Definition at line 67 of file AbstractControllerStatic.cc.

Member Data Documentation

◆ m_p_master

std::shared_ptr<AbstractMaster> AbstractController::m_p_master
protected

Shared pointer to AbstractMaster.

Definition at line 137 of file AbstractController.h.


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