ClickHouse/base/poco/Foundation/include/Poco/Instantiator.h
Robert Schulze b79ead9c84
Move poco to base/poco/ (#46075)
* Replicate poco into base/poco/

* De-register poco submodule

* Build poco from ClickHouse

* Exclude poco from stylecheck

* Exclude poco from whitespace check

* Exclude poco from typo check

* Remove x bit from sources/headers (the style check complained)

* Exclude poco from duplicate include check

* Fix fasttest

* Remove contrib/poco-cmake/*

* Simplify poco build descriptions

* Remove poco stuff not used by ClickHouse

* Glob poco sources

* Exclude poco from clang-tidy
2023-02-08 12:04:11 +01:00

83 lines
1.5 KiB
C++

//
// Instantiator.h
//
// Library: Foundation
// Package: Core
// Module: Instantiator
//
// Definition of the Instantiator class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef Foundation_Instantiator_INCLUDED
#define Foundation_Instantiator_INCLUDED
#include "Poco/Foundation.h"
namespace Poco {
template <class Base>
class AbstractInstantiator
/// The common base class for all Instantiator instantiations.
/// Used by DynamicFactory.
{
public:
AbstractInstantiator()
/// Creates the AbstractInstantiator.
{
}
virtual ~AbstractInstantiator()
/// Destroys the AbstractInstantiator.
{
}
virtual Base* createInstance() const = 0;
/// Creates an instance of a concrete subclass of Base.
private:
AbstractInstantiator(const AbstractInstantiator&);
AbstractInstantiator& operator = (const AbstractInstantiator&);
};
template <class C, class Base>
class Instantiator: public AbstractInstantiator<Base>
/// A template class for the easy instantiation of
/// instantiators.
///
/// For the Instantiator to work, the class of which
/// instances are to be instantiated must have a no-argument
/// constructor.
{
public:
Instantiator()
/// Creates the Instantiator.
{
}
virtual ~Instantiator()
/// Destroys the Instantiator.
{
}
Base* createInstance() const
{
return new C;
}
};
} // namespace Poco
#endif // Foundation_Instantiator_INCLUDED