Lunchbox  1.9.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dso.h
1 
2 /* Copyright (c) 2009, Cedric Stalder <cedric.stalder@gmail.com>
3  * 2009-2014, Stefan Eilemann <eile@equalizergraphics.com>
4  *
5  * This library is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU Lesser General Public License version 2.1 as published
7  * by the Free Software Foundation.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef LUNCHBOX_DSO_H
20 #define LUNCHBOX_DSO_H
21 
22 #include <lunchbox/api.h>
23 #include <boost/noncopyable.hpp>
24 #include <string>
25 
26 namespace lunchbox
27 {
28 namespace detail { class DSO; }
29 
35 class DSO : public boost::noncopyable
36 {
37 public:
39  LUNCHBOX_API DSO();
40 
42  LUNCHBOX_API explicit DSO( const std::string& name );
43 
45  LUNCHBOX_API ~DSO();
46 
54  LUNCHBOX_API bool open( const std::string& fileName );
55 
60  LUNCHBOX_API void close();
61 
67  LUNCHBOX_API
68  void* getFunctionPointer( const std::string& functionName ) const;
69 
75  template< class F > F getFunctionPointer( const std::string& func ) const
76  { return (F)(getFunctionPointer( func )); }
77 
79  LUNCHBOX_API bool isOpen() const;
80 
85  LUNCHBOX_API bool operator == ( const DSO& rhs ) const;
86 
91  bool operator != ( const DSO& rhs ) const { return !( *this == rhs ); }
92 
93 private:
94  detail::DSO* const _impl;
95 };
96 
97 }
98 
99 #endif //LUNCHBOX_DSO_H
LUNCHBOX_API void * getFunctionPointer(const std::string &functionName) const
Helper to access dynamic shared objects (DSO)
Definition: dso.h:35
F getFunctionPointer(const std::string &func) const
Definition: dso.h:75
Defines export visibility macros for Lunchbox.
LUNCHBOX_API ~DSO()
Destruct this DSO handle.
LUNCHBOX_API bool isOpen() const
LUNCHBOX_API DSO()
Construct a new dynamic shared object.
LUNCHBOX_API bool operator==(const DSO &rhs) const
bool operator!=(const DSO &rhs) const
Definition: dso.h:91
LUNCHBOX_API bool open(const std::string &fileName)
Open a dynamic shared object.
LUNCHBOX_API void close()
Close the DSO, invalidates retrieved function pointers.