my_cpp_plugin.hpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright 2016 Antony Polukhin.
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt
  5. // or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_DLL_MY_CPP_PLUGIN_API_HPP
  7. #define BOOST_DLL_MY_CPP_PLUGIN_API_HPP
  8. //[cppplug
  9. #include <string>
  10. namespace space {
  11. class BOOST_SYMBOL_EXPORT my_plugin
  12. {
  13. std::string _name;
  14. public:
  15. std::string name() const;
  16. float calculate(float x, float y);
  17. int calculate(int, x, int y);
  18. static std::size_t size();
  19. my_plugin(const std::string & name);
  20. my_plugin();
  21. ~my_plugin_api();
  22. static int value;
  23. };
  24. }
  25. //]
  26. std::string space::my_plugin_api::name() const {return _name;}
  27. float space::my_plugin::calculate(float x, float y) {return x/y;}
  28. int space::my_plugin::calculate(int, x, int y) {return x/y;}
  29. std::size_t my_plugin::size() {return sizeof(my_plugin);}
  30. space::my_plugin::my_plugin(const std::string & name) : _name(name) {}
  31. space::my_plugin::my_plugin() : _name("Empty") {}
  32. space::my_plugin::~my_plugin_api() {}
  33. int space::my_plugin::value = 42;
  34. #endif // BOOST_DLL_MY_PLUGIN_API_HPP