Namespace Scine::Core

namespace Core
class ObjectWithStructure

Interface class defining an entity having a molecular structure.

This solves the diamond inheritance problem where multiple different classes have a setStructure() method. A derived class cannot know which method to choose from. This way, there is only one setStructure() method.

Subclassed by Scine::Core::Calculator, Scine::Core::WavefunctionOutputGenerator

class State
#include <StateHandableObject.h>

A naming interface for all states to be handled in SCINE.

class StateHandableObject
#include <StateHandableObject.h>

An interface for all objects that should have a handable state.

All objects that have a state or a configuration that should be extractable and loadable should inherit from this interface.

The state of such an object is to be encoded into a class derived from State. A state should represent a momentary snapshot of a given object

Each such object must then implement the loadState() and getState() functions which are hooks for further utilities. These utilities, such as a StatesHandler can be found in the Scine::Utils namespace/repository.

Subclassed by Scine::Core::Calculator, Scine::Core::WavefunctionOutputGenerator

class SettingsKeyError : public exception
#include <Exceptions.h>

An Exception for an error when handling keys in settings.

class SettingsValueError : public exception
#include <Exceptions.h>

An Exception for an error when handling values in settings.

class ClassNotImplementedError : public exception
#include <Exceptions.h>

An Exception for an error when generating classes through a module-interface.

class FunctionNotImplementedError : public exception
#include <Exceptions.h>

An Exception for an error when a function in a module-interface is not implemented.

class StateCastingException : public exception

Exception to be thrown if the state cannot be cast to the desired type.

class InvalidPropertiesException : public runtime_error
#include <Exceptions.h>

Exception thrown when one requires properties from a calculation which cannot be calculated.

class CalculationException : public runtime_error
#include <Exceptions.h>

Base class for exceptions thrown during calculations.

Subclassed by Scine::Core::EmptyMolecularStructureException, Scine::Core::InitializationException, Scine::Core::StateSavingException, Scine::Core::UnsuccessfulCalculationException

class InitializationException : public Scine::Core::CalculationException
#include <Exceptions.h>

Exception thrown when a problem arises in the calculator initialization.

class EmptyMolecularStructureException : public Scine::Core::CalculationException
#include <Exceptions.h>

Exception thrown when launching a calculation with an empty structure.

class UnsuccessfulCalculationException : public Scine::Core::CalculationException
#include <Exceptions.h>

Exception thrown when a calculation is unsuccessful.

class StateSavingException : public Scine::Core::CalculationException
#include <Exceptions.h>

Exception thrown for errors in state saving / resetting.

class Calculator : public Scine::Core::StateHandableObject, public Scine::Core::ObjectWithStructure
#include <Calculator.h>

The interface for all classes running electronic structure calculations.

class CalculatorWithReference
#include <CalculatorWithReference.h>

The interface for all classes running calculations on top of a reference calculation.

This can be, for example, excited states calculation (CIS, TD-DFT,..), post-HF, but also thermodynamics calculations and the CISE approach.

class MMParametrizer
#include <MMParametrizer.h>

The interface for all classes parametrizing a molecular mechanics model.

class WavefunctionOutputGenerator : public Scine::Core::StateHandableObject, public Scine::Core::ObjectWithStructure

Interface class defining an entity able to generate a wavefunction output file.

class Module
#include <Module.h>

Abstract base class for a module, which flexibly provides consumers with common interface derived classes.

Modules supply consumers with instances of types satisfying a particular common interface concept. Any library that wishes to provide classes satisfying interfaces defined in Core must implement a single derived class of this interface.

Implementation notes:

  • The has / get interface of a module is double-blind so that it can be used polymorphically within the ModuleManager. Its interface does not require knowledge of the Interface class nor the type of the model that satisfies it. This is for ease of implementation for derived classes.

  • Get returns a type-erased wrapper around a shared_ptr to the base class of the interface that the desired model satisfies.

A class deriving from Module that will be part of a compilation unit intended to become a runtime dynamically-loaded library must offer an entry point for ModuleManager at global scope. A Module-derived class header file should look roughly like this:

#include <Core/Module.h>
#include <boost/dll/alias.hpp>
#include <memory>

namespace XYZ {

class FooModule : public Core::Module {
public:
  // Implement name()
  // Use DerivedModule.h to implement has(...), get(...), announceInterfaces(),
  //   announceModels(...)
};

std::vector<std::shared_ptr<Core::Module>> moduleFactory() {
  return {std::make_shared<FooModule>()};
}

} // namespace XYZ

// At global scope, declare an entry point called "moduleFactory"
BOOST_DLL_ALIAS(XYZ::moduleFactory, moduleFactory)

Mandatory virtual interface

Announces the module’s name

class ModuleManager
#include <ModuleManager.h>

The manager for all dynamically loaded modules.

This class is a singleton, in order to ensure that there is only ever one instance of this class controlling all modules loaded.

Use this class by requesting a reference to the single existing instance:

const auto& manager = ModuleManager::getInstance()
if(manager.has<Calculator>("DFT")) {
  auto calculator = manager.get<Calculator>("DFT");
}

namespace DerivedModule

Functions

template<typename MPLMap>
boost::any resolve(const std::string &interface, const std::string &model)

Creates an InterfaceType shared_ptr of a matching model to an interface.

Helper function to implement a derived module’s get function:

// Transforms this:
boost::any Derived::get(const std::string& interface, const std::string& model) const {
  if(interface == Calculator::interface) {
    if(model == PlusCalculator::model) {
      return static_cast<Calculator>(std::make_shared<PlusCalculator>());
    }

    if(model == MinusCalculator::model) {
      return static_cast<Calculator>(std::make_shared<MinusCalculator>());
    }

    ...
  }

  if(interface == Printer::interface) {
    if(model == SlowPrinter::model) {
      return static_cast<Printer>(std::make_shared<SlowPrinter>());
    }
    if(model == EvenSlowerPrinter::model) {
      return static_cast<Printer>(std::make_shared<EvenSlowerPrinter>());
    }

    ...
  }

  ...

  throw Core::ClassNotImplementedError();
}

// Into this:
boost::any Derived::get(const std::string& interface, const std::string& model) const {
  // NOTE: Same map for has, announceInterfaces, anounceModels
  using Map = boost::mpl::map<
    boost::mpl::pair<Calculator, boost::mpl::vector<PlusCalculator, MinusCalculator>>,
    boost::mpl::pair<Printer, boost::mpl::vector<SlowPrinter, EvenSlowerPrinter>>
  >;

  boost::any resolved = DerivedModule::resolve<Map>(interface, model);
  if(resolved.empty()) {
    throw Core::ClassNotImplementedError {};
  }
  return resolved;
}

Return

a boost any containing a shared_ptr to the InterfaceType of the matched model, an empty boost::any otherwise.

Template Parameters
  • MPLMap: An mpl::map of InterfaceType -> mpl::vector<ModelType> InterfaceType::interface and ModelType::Model must be valid expressions

Parameters
  • interface: The interface to model

  • model: The model of interface to create

template<typename MPLMap>
bool has(const std::string &interface, const std::string &model)

Checks whether a module has a particular model for a particular interface.

Return

whether the module has a model for the interface

Template Parameters
  • MPLMap: An mpl::map of InterfaceType -> mpl::vector<ModelType> InterfaceType::interface and ModelType::Model must be valid expressions

Parameters
  • interface: The interface to check for

  • model: The model to check for

template<typename MPLMap>
std::vector<std::string> announceInterfaces()

Announces all interface names.

Return

A list of all interface names

Template Parameters
  • MPLMap: An mpl::map of InterfaceType -> mpl::vector<ModelType> InterfaceType::interface and ModelType::Model must be valid expressions

template<typename MPLMap>
std::vector<std::string> announceModels(const std::string &interface)

Announces all model names for a particular interface.

Return

The list of model names for a particular interface, or an empty list if no models exist for that interface.

Template Parameters
  • MPLMap: An mpl::map of InterfaceType -> mpl::vector<ModelType> InterfaceType::interface and ModelType::Model must be valid expressions

Parameters
  • interface: The interface for which to list model identifiers

namespace detail

Functions

bool caseInsensitiveEqual(const std::string &a, const std::string &b)
template<typename Sequence, typename Predicate, typename Executable>
auto exec_if(const Predicate &p, const Executable &e, Sequence * = 0)

Run-time “iteration” through type list, if predicate matches, call another function, otherwise return its none.

Return

Executable::none() if Predicate never matches, otherwise Executable(T) for the first T in Sequence that matches Predicate.

Template Parameters
  • Sequence: a boost::mpl compatible sequence type

  • Predicate: A type with a template<T> bool operator() (T* = 0) const member specifying whether to execute Executable for the type T in Sequence

  • Executable: A type fulfilling the following requirements:

    • Has a ResultType typedef

    • Has a template<T> ResultType operator() (T* = 0) const member which is executed if returns true for a type in Sequence

    • Has a static ResultType none() const member returning the base case

constexpr bool strEqual(const char *a, const char *b)
template<typename ...ModelTypes>
constexpr bool identifiersOverlap()
template<typename MPLVector, std::size_t... Inds>
constexpr bool identifierOverlapForwarder(std::index_sequence<Inds...>)