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
9#include <memory>
10#include <utility>
11
12namespace Mantid {
13namespace Kernel {
14
30template <typename ChainableType> class Chainable {
31protected:
34 std::unique_ptr<ChainableType> m_successor;
36 virtual void checkSuccessor() const {}
37
38public:
40 template <typename T> Chainable &setSuccessor(T &&successor) {
41 m_successor = std::move(successor);
43 return *m_successor;
44 }
45 bool hasSuccessor() const { return bool(m_successor); }
46 virtual ~Chainable() = 0;
47};
48
50template <typename ChainableType> Chainable<ChainableType>::~Chainable() = default;
51
52} // namespace Kernel
53} // namespace Mantid
bool hasSuccessor() const
Definition Chainable.h:45
std::unique_ptr< ChainableType > m_successor
Successor factory std::optional<std::unique_ptr<ChainableType>> m_successor;.
Definition Chainable.h:34
virtual void checkSuccessor() const
Provide option for derived classes to check successor and throw if bad.
Definition Chainable.h:36
Chainable & setSuccessor(T &&successor)
Set the successor.
Definition Chainable.h:40
virtual ~Chainable()=0
Keep our destructor pure virtual, but require an implementation.
Helper class which provides the Collimation Length for SANS instruments.