Newer
Older
Russell Taylor
committed
#ifndef MANTID_KERNEL_INSTANTIATOR_H_
#define MANTID_KERNEL_INSTANTIATOR_H_
Russell Taylor
committed
namespace Mantid {
namespace Kernel {
Russell Taylor
committed
/** @class Instantiator Instantiator.h Kernel/Instantiator.h
The instantiator is a generic class for creating objects of the template
type.
Russell Taylor
committed
It is used by DynamicFactory.
@author Nick Draper, Tessella Support Services plc
@date 10/10/2007
Copyright © 2007 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
National Laboratory & European Spallation Source
Russell Taylor
committed
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
Russell Taylor
committed
*/
template <class Base>
/// The base class for instantiators
{
Russell Taylor
committed
public:
/// Creates the AbstractInstantiator.
AbstractInstantiator() = default;
Russell Taylor
committed
/// Destroys the AbstractInstantiator.
virtual ~AbstractInstantiator() = default;
/// Creates an instance of a concrete subclass of Base.
Russell Taylor
committed
Gigg, Martyn Anthony
committed
/// Creates an instance of a concrete subclass of Base, which is
/// not wrapped in a boost shared_ptr
virtual Base *createUnwrappedInstance() const = 0;
Gigg, Martyn Anthony
committed
Russell Taylor
committed
private:
/// Private copy constructor
AbstractInstantiator(const AbstractInstantiator &);
Russell Taylor
committed
/// Private assignment operator
AbstractInstantiator &operator=(const AbstractInstantiator &);
Russell Taylor
committed
};
// A template class for the easy instantiation of
// instantiators.
Russell Taylor
committed
//
// For the Instantiator to work, the class of which
// instances are to be instantiated must have a no-argument
// constructor.
template <class C, class Base>
class DLLExport Instantiator : public AbstractInstantiator<Base> {
Russell Taylor
committed
public:
/// Creates the Instantiator.
Instantiator() = default;
/** Creates an instance of a concrete subclass of Base.
Russell Taylor
committed
* @return A pointer to the base type
*/
boost::shared_ptr<Base> createInstance() const override {
Russell Taylor
committed
}
Gigg, Martyn Anthony
committed
/** Creates an instance of a concrete subclass of Base that is not wrapped in
* a boost shared_ptr.
Gigg, Martyn Anthony
committed
* @return A bare pointer to the base type
*/
Base *createUnwrappedInstance() const override {
Gigg, Martyn Anthony
committed
}
Russell Taylor
committed
};
Russell Taylor
committed
} // namespace Kernel
Russell Taylor
committed
} // namespace Mantid
Russell Taylor
committed
#endif /*MANTID_KERNEL_INSTANTIATOR_H_*/