static_plugin.cpp 992 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. //[plugcpp_my_plugin_staic_impl
  8. #include "static_plugin.hpp" // this is essential, BOOST_SYMBOL_ALIAS must be seen in this file
  9. #include <boost/make_shared.hpp>
  10. #include <iostream>
  11. namespace my_namespace {
  12. class my_plugin_static : public my_plugin_api {
  13. public:
  14. my_plugin_static() {
  15. std::cout << "Constructing my_plugin_static" << std::endl;
  16. }
  17. std::string name() const {
  18. return "static";
  19. }
  20. float calculate(float x, float y) {
  21. return x - y;
  22. }
  23. ~my_plugin_static() {
  24. std::cout << "Destructing my_plugin_static" << std::endl;
  25. }
  26. };
  27. boost::shared_ptr<my_plugin_api> create_plugin() {
  28. return boost::make_shared<my_plugin_static>();
  29. }
  30. } // namespace my_namespace
  31. //]