Scine::Swoose  2.1.0
This is the SCINE module Swoose.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
MockModule.h
Go to the documentation of this file.
1 
8 #ifndef SWOOSE_MOCK_MODULE_H
9 #define SWOOSE_MOCK_MODULE_H
10 
11 #include <Core/Module.h>
12 #include <boost/dll/alias.hpp>
13 #include <memory>
14 
15 namespace Scine {
16 namespace Swoose {
17 
22  public:
23  std::string name() const noexcept final;
24 
25  boost::any get(const std::string& interface, const std::string& model) const final;
26 
27  bool has(const std::string& interface, const std::string& model) const noexcept final;
28 
29  std::vector<std::string> announceInterfaces() const noexcept final;
30 
31  std::vector<std::string> announceModels(const std::string& interface) const noexcept final;
32 
33  static std::shared_ptr<Scine::Core::Module> make();
34 };
35 
36 // Shared library entry point creating pointers to all contained modules
37 std::vector<std::shared_ptr<Scine::Core::Module>> moduleFactory();
38 
39 } // namespace Swoose
40 } // namespace Scine
41 
42 #ifdef __MINGW32__
43 /* MinGW builds are problematic. We build with default visibility, and adding
44  * an attribute __dllexport__ specifically for this singular symbol leads to the
45  * loss of all other weak symbols. Essentially, here we have just expanded the
46  * BOOST_DLL_ALIAS macro in order to declare the type-erased const void*
47  * 'moduleFactory' without any symbol visibility attribute additions that could
48  * confuse the MinGW linker, which per Boost DLL documentation is unable to mix
49  * weak attributes and __dllexport__ correctly.
50  *
51  * If ever the default visibility for this translation unit is changed, we
52  * will have to revisit this bit of code for the MinGW platform again.
53  *
54  * Additionally, more recent Boost releases may have fixed this problem.
55  * See the macro BOOST_DLL_FORCE_ALIAS_INSTANTIATIONS as used in the library's
56  * example files.
57  */
58 extern "C" {
59 const void* moduleFactory = reinterpret_cast<const void*>(reinterpret_cast<intptr_t>(&sample_namespace::moduleFactory));
60 }
61 #else
62 BOOST_DLL_ALIAS(Scine::Swoose::moduleFactory, moduleFactory)
63 #endif
64 
65 #endif // SWOOSE_MOCK_MODULE_H
Mock module for QM/MM tests.
Definition: MockModule.h:21