fw4spl
Native.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2016.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #ifndef __FWRUNTIME_DL_NATIVE_HPP__
8 #define __FWRUNTIME_DL_NATIVE_HPP__
9 
10 #include "fwRuntime/config.hpp"
11 #include "fwRuntime/RuntimeException.hpp"
12 
13 #include <boost/filesystem/path.hpp>
14 #include <boost/regex.hpp>
15 
16 namespace fwRuntime
17 {
18 
19 
20 struct Bundle;
21 
22 
23 namespace dl
24 {
25 
26 
31 struct Native
32 {
33  friend struct ::fwRuntime::Bundle;
34 
35 
41  Native( const boost::filesystem::path & modulePath) noexcept;
42 
46  virtual ~Native() noexcept;
47 
48 
54  virtual bool isLoaded() const noexcept = 0;
55 
63  virtual void * getSymbol( const std::string& name ) const = 0;
64 
68  virtual void load() = 0;
69 
73  virtual void unload() = 0;
74 
84  const boost::filesystem::path getFullPath( const bool _bMustBeFile = false ) const;
85 
93  const boost::filesystem::path getPath() const;
94 
100  void setBundle( const ::fwRuntime::Bundle * bundle ) noexcept;
101 
106  const ::boost::regex getNativeName() const;
107 
108  private:
109 
115  const ::boost::filesystem::path getBundleLocation() const;
116 
120  const boost::filesystem::path m_modulePath;
121 
125  const Bundle * m_bundle;
126 
127 
133  void operator=( const Native & ) noexcept;
134 
135 };
136 
137 
138 
139 } // namesapce dl
140 
141 } // namespace fwRuntime
142 
143 
144 #endif // __FWRUNTIME_DL_NATIVE_HPP__
virtual ~Native() noexcept
Destructor : does nothing.
Definition: Native.cpp:35
virtual bool isLoaded() const noexcept=0
Tells if the module is loaded.
virtual void * getSymbol(const std::string &name) const =0
Retrieves the address of a symbol specified by its name.
Native(const boost::filesystem::path &modulePath) noexcept
Constructor.
Definition: Native.cpp:27
const boost::filesystem::path getFullPath(const bool _bMustBeFile=false) const
Retrieves the file path of the library including the owning bundle&#39;s path.
Definition: Native.cpp:52
Defines the abstract class for native module implementors.
Definition: Native.hpp:31
The namespace fwRuntime contains classes to manage bundle, configuration element, extension point in ...
virtual void load()=0
Loads the module.
const boost::filesystem::path getPath() const
Retrieves the file path of the native library.
Definition: Native.cpp:103
const ::boost::regex getNativeName() const
Retrieves the pattern of the dynamic library file name given the host OS.
Definition: Native.cpp:79
Defines the bundle class.
Definition: Bundle.hpp:45
virtual void unload()=0
Undloads the module.
void setBundle(const ::fwRuntime::Bundle *bundle) noexcept
Set the bundle the library is attached to.
Definition: Native.cpp:131