Class Scine::Utils::State

class State

Base class for the implementation of a generic State.

A state should be viewed as a checkpoint. Implementation note: If a class having an interface needs to save/load a state, then it has to have a polymorphic pointer to StatesHandler in the interface and then populate it with a derived class, specific to the class. The same is true with the polymorphic State class.

Subclassed by Scine::Utils::ExternalQC::OrcaState

Public Types

using MatrixState = std::map<std::string, Eigen::MatrixXd>

Maps of key-value pairs containing possible states.

Public Functions

State(StateSize size)

Constructor, constructs the state with a StateSize.

StateSize getStateSize() const

Getter for the state size, i.e.

the required level of information about a state.

virtual const Eigen::MatrixXd &getMatrixState(const std::string &matrixName) const = 0

Getter for an Eigen::MatrixXd state identified with a std::string.

This function returns a const reference to an Eigen::MatrixXd in order to avoid unnecessary copying of possibly big matrices. Be careful, the state must not go out of scope!

Return

A const reference to the value of the key-value pair, an Eigen::MatrixXd.

Parameters
  • matrixState: The key for the state’s key-value pair.

virtual const std::string &getStringState(const std::string &stringState) const = 0

Getter for a std::string state identified with a std::string.

This function returns a const reference to a std::string in order to avoid unnecessary copying of possibly big strings. Be careful, the state must not go out of scope!

Return

A const reference to the value of the key-value pair, a std::string.

Parameters
  • stringState: The key for the state’s key-value pair.

virtual int getIntState(const std::string &intState) const = 0

Getter for an integer state identified with a std::string.

Return

The value of the key-value pair, an integer.

Parameters
  • intState: The key for the state’s key-value pair.

virtual double getDoubleState(const std::string &doubleState) const = 0

Getter for a double state identified with a std::string.

Return

The value of the key-value pair, a double.

Parameters
  • doubleState: The key for the state’s key-value pair.

virtual void initialize() = 0

Initializer for the state, resets it to the initial state.