From bb89d10df665ee6f853aa07bed6989a3df5dc96e Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Thu, 28 Aug 2014 14:27:58 +0400 Subject: [PATCH] Make example more demonstrative --- example/tutorial2/my_plugin_aggregator.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/example/tutorial2/my_plugin_aggregator.cpp b/example/tutorial2/my_plugin_aggregator.cpp index bbacb5e..ff9ce68 100644 --- a/example/tutorial2/my_plugin_aggregator.cpp +++ b/example/tutorial2/my_plugin_aggregator.cpp @@ -18,9 +18,9 @@ namespace my_namespace { class my_plugin_aggregator : public my_plugin_api { float aggr_; -public: my_plugin_aggregator() : aggr_(0) {} +public: float version() const { return 1.0; } @@ -33,13 +33,20 @@ public: aggr_ += x + y; return aggr_; } + + // Factory method + static boost::shared_ptr create() { + return boost::shared_ptr( + new my_plugin_aggregator() + ); + } }; -boost::shared_ptr create_plugin_aggregator() { - return boost::make_shared(); -} -BOOST_PLUGIN_ALIAS(my_namespace::create_plugin_aggregator, create_plugin) +BOOST_PLUGIN_ALIAS( + my_namespace::my_plugin_aggregator::create, + create_plugin +) } // namespace my_namespace