Scine::Core  3.0.0
Module management and core interface definitions
 All Classes Files Functions Variables Typedefs Pages
Calculator.h
Go to the documentation of this file.
1 
7 #ifndef CORE_CALCULATOR_H_
8 #define CORE_CALCULATOR_H_
9 /* Internal Includes */
13 /* External Includes */
14 #include <string>
15 
16 namespace Scine {
17 
18 namespace Utils {
19 class Results;
20 class Settings;
21 class StatesHandler;
22 class PropertyList;
23 } // namespace Utils
24 
25 namespace Core {
31  public:
32  static constexpr const char* interface = "calculator";
33 
35  Calculator() = default;
37  virtual ~Calculator() = default;
43  virtual void setRequiredProperties(const Utils::PropertyList& requiredProperties) = 0;
47  virtual Utils::PropertyList getRequiredProperties() const = 0;
53  virtual Utils::PropertyList possibleProperties() const = 0;
62  virtual const Utils::Results& calculate(std::string description = "") = 0;
67  virtual std::string name() const = 0;
74  std::unique_ptr<Core::Calculator> clone() const {
75  return std::unique_ptr<Core::Calculator>(this->cloneImpl());
76  }
81  virtual Utils::Settings& settings() = 0;
86  virtual const Utils::Settings& settings() const = 0;
91  virtual Utils::Results& results() = 0;
96  virtual const Utils::Results& results() const = 0;
104  virtual bool supportsMethodFamily(const std::string& methodFamily) const = 0;
114  static auto supports(const std::string& methodFamily) {
115  return [methodFamily](const std::shared_ptr<Calculator>& calculatorPtr) -> bool {
116  return calculatorPtr->supportsMethodFamily(methodFamily);
117  };
118  }
119 
120  private:
121  /*
122  * Implementation of the clone() function, pure virtual private method.
123  * It returns a pointer to allow for covariant return types in inheritance.
124  */
125  virtual Core::Calculator* cloneImpl() const = 0;
126 };
127 
128 } /* namespace Core */
129 } /* namespace Scine */
130 
131 #endif /* CORE_CALCULATOR_H_ */
virtual void setRequiredProperties(const Utils::PropertyList &requiredProperties)=0
Sets the properties to calculate.
An interface for all objects that should have a handable state.
Definition: StateHandableObject.h:39
Base class for objects with a Log member.
Definition: ObjectWithLog.h:25
virtual Utils::PropertyList getRequiredProperties() const =0
Gets the current properties to calculate.
virtual bool supportsMethodFamily(const std::string &methodFamily) const =0
Whether the calculator supports a method family.
static auto supports(const std::string &methodFamily)
Predicate-generator for ModuleManager&#39;s get&lt;Interface, UnaryPredicate&gt; function.
Definition: Calculator.h:114
Calculator()=default
Default constructor.
The interface for all classes running electronic structure calculations.
Definition: Calculator.h:30
Interface class defining an entity having a molecular structure. This solves the diamond inheritance ...
Definition: ObjectWithStructure.h:27
virtual Utils::Results & results()=0
Accessor for the saved instance of Utils::Results.
virtual Utils::Settings & settings()=0
Accessor for the settings.
virtual std::string name() const =0
Getter for the name of the Calculator.
virtual const Utils::Results & calculate(std::string description="")=0
The main function running calculations.
std::unique_ptr< Core::Calculator > clone() const
Method allowing to clone the derived class into a Core::Calculator The derived, leaf class needs to i...
Definition: Calculator.h:74
virtual ~Calculator()=default
Default destructor.
virtual Utils::PropertyList possibleProperties() const =0
Returns the list of the possible properties to calculate analytically. By some method analytical hess...