File StatesHandler.h¶
- Copyright
This code is licensed under the 3-clause BSD license.
Copyright ETH Zurich, Laboratory for Physical Chemistry, Reiher Group.
See LICENSE.txt for details.
-
namespace
Scine
This header file contains functions that allow for common notation for common things that can be done at a different degree of derivatives.
This header contains alias definitions defining which classes to use for the different degrees of derivatives.
-
namespace
Utils
-
class
EmptyStatesHandlerContainer
: public exception - #include <StatesHandler.h>
This exception is thrown if an empty states handler is popped.
Private Functions
-
const char *
what
() const¶
-
const char *
-
class
NoStateHandableObjectPresent
: public exception - #include <StatesHandler.h>
This exception is thrown if an empty states handler is popped.
Private Functions
-
const char *
what
() const¶
-
const char *
-
class
StatesHandler
- #include <StatesHandler.h>
Class responsible for saving, storing and loading object-specific states.
Core::State is an empty class. This base class is then implemented to have some meaningful definition of a state for an application. I could be, for instance, a density matrix for a Core::Calculator, a partially converged Markov Chain Montecarlo, a checkpoint,… . A Core::StateHandableObject interface exposes the functions for getting and loading a single state. The StatesHandler job is that of storing a list of these states and freely switching between them. This class is stand-alone, but can also be specialized to suit certain needs, this is why it exposes a virtual destructor.
Public Types
Public Functions
Constructor of the class taking a StateHandableObject instance.
-
virtual
~StatesHandler
() Virtual default destructor.
Store an externally generated state as the newest state.
- Parameters
state
: A pointer to the state to store.
-
void
store
() Stores the current state of the Core::StateHandableObject instance in this class.
Loads an externally generated state.
- Parameters
state
: The state to be loaded. The specifics of how exactly the state is stored is not implemented in this class, but is in the Core::StateHandableObject derived class. This just calls the load() method in Core::StateHandableObject instance of this class.
-
void
load
(int index) Loads an internally stored state.
- Parameters
index
: The index of the state to be loaded. The specifics of how exactly the state is stored is not implemented in this class, but is in the Core::StateHandableObject derived class. This just extracts the state and calls the load() method in Core::StateHandableObject instance of this class.
-
std::shared_ptr<Core::State>
getState
(int index) const Gets the state at some index in the StatesContainer.
- Return
A polymorphic smart pointer to the Core::State at some index.
-
std::shared_ptr<Core::State>
popOldestState
() Eliminates the oldest state from the StatesContainer and returns it.
-
std::shared_ptr<Core::State>
popNewestState
() Eliminates the newest state from the underlying container and returns it.
-
void
clear
() Clears all the internally saved states.
-
int
size
() const Gets the current size of the state storage.
Protected Attributes
-
std::weak_ptr<Core::StateHandableObject>
statesHandableObject_
¶
-
StatesContainer
states_
¶
-
class
-
namespace