Mantid
Loading...
Searching...
No Matches
Chainable.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2015 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
10#include <memory>
11#include <utility>
12
13namespace Mantid {
14namespace Kernel {
15
31template <typename ChainableType> class DLLExport Chainable {
32protected:
35 std::unique_ptr<ChainableType> m_successor;
37 virtual void checkSuccessor() const {}
38
39public:
41 template <typename T> Chainable &setSuccessor(T &&successor) {
42 m_successor = std::move(successor);
43 checkSuccessor();
44 return *m_successor;
45 }
46 bool hasSuccessor() const { return bool(m_successor); }
47 virtual ~Chainable() = 0;
48};
49
51template <typename ChainableType> Chainable<ChainableType>::~Chainable() = default;
52
53} // namespace Kernel
54} // namespace Mantid
#define DLLExport
Definitions of the DLLImport compiler directives for MSVC.
Definition: System.h:53
bool hasSuccessor() const
Definition: Chainable.h:46
std::unique_ptr< ChainableType > m_successor
Successor factory boost::optional<std::unique_ptr<ChainableType>> m_successor;.
Definition: Chainable.h:35
virtual void checkSuccessor() const
Provide option for derived classes to check successor and throw if bad.
Definition: Chainable.h:37
Chainable & setSuccessor(T &&successor)
Set the successor.
Definition: Chainable.h:41
virtual ~Chainable()=0
Keep our destructor pure virtual, but require an implementation.
Helper class which provides the Collimation Length for SANS instruments.