diff options
author | Dan Goodliffe <daniel.goodliffe@pressassociation.com> | 2015-09-16 10:21:01 +0100 |
---|---|---|
committer | Dan Goodliffe <daniel.goodliffe@pressassociation.com> | 2015-09-16 10:21:01 +0100 |
commit | b99891a2d93c419ea848c7b6bff85c63cc99ea07 (patch) | |
tree | 35afeaf5873d10049f2b80f8da40628316734244 /libadhocutil/factory.h | |
parent | Remove rogue debug (diff) | |
download | libadhocutil-b99891a2d93c419ea848c7b6bff85c63cc99ea07.tar.bz2 libadhocutil-b99891a2d93c419ea848c7b6bff85c63cc99ea07.tar.xz libadhocutil-b99891a2d93c419ea848c7b6bff85c63cc99ea07.zip |
Add doxygen comments
Diffstat (limited to 'libadhocutil/factory.h')
-rw-r--r-- | libadhocutil/factory.h | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/libadhocutil/factory.h b/libadhocutil/factory.h index 28fce62..f1998a7 100644 --- a/libadhocutil/factory.h +++ b/libadhocutil/factory.h @@ -5,24 +5,47 @@ #include "visibility.h" namespace AdHoc { + /** + * Base class for factories creating instances of Base. + */ template <typename Base, typename ... Params> class DLL_PUBLIC Factory { public: virtual ~Factory() = 0; - virtual Base * create(const Params & ...) const = 0; + /** + * Create a new instance of Base, overridden in a subclass to construct a new specific class. + * @param p The parameters passed to Impl constructor. + */ + virtual Base * create(const Params & ... p) const = 0; + /** + * A factory for a concrete implementation of Base + */ template <typename Impl, typename _ = Factory<Base, Params...>> class DLL_PUBLIC For : public _ { public: + /** + * Create a new instance of Base implemented in Impl. + * @param p The parameters passed to Impl constructor. + */ Base * create(const Params & ... p) const override { return new Impl(p...); } }; + /** + * Helper to get the factory for a specific implementation. + * @param name The name of the implementation. + */ static const Factory * get(const std::string & name); + /** + * Helper to create a new instance from a specific factory. + * @param name The name of the implementation. + * @param p The parameters to pass to the constructor. + */ static Base * create(const std::string & name, const Params & ... p); }; } |