1 // Copyright 2014 Renato Tegon Forti, Antony Polukhin. 2 // Copyright 2015-2019 Antony Polukhin. 3 // 4 // Distributed under the Boost Software License, Version 1.0. 5 // (See accompanying file LICENSE_1_0.txt 6 // or copy at http://www.boost.org/LICENSE_1_0.txt) 7 8 #include <iostream> 9 10 11 //[plugcpp_my_plugin_sum 12 #include <boost/config.hpp> // for BOOST_SYMBOL_EXPORT 13 #include "../tutorial_common/my_plugin_api.hpp" 14 15 namespace my_namespace { 16 17 class my_plugin_sum : public my_plugin_api { 18 public: my_plugin_sum()19 my_plugin_sum() { 20 std::cout << "Constructing my_plugin_sum" << std::endl; 21 } 22 name() const23 std::string name() const { 24 return "sum"; 25 } 26 calculate(float x,float y)27 float calculate(float x, float y) { 28 return x + y; 29 } 30 ~my_plugin_sum()31 ~my_plugin_sum() { 32 std::cout << "Destructing my_plugin_sum ;o)" << std::endl; 33 } 34 }; 35 36 // Exporting `my_namespace::plugin` variable with alias name `plugin` 37 // (Has the same effect as `BOOST_DLL_ALIAS(my_namespace::plugin, plugin)`) 38 extern "C" BOOST_SYMBOL_EXPORT my_plugin_sum plugin; 39 my_plugin_sum plugin; 40 41 } // namespace my_namespace 42 43 //] 44