root/OpenSceneGraph/trunk/include/osgDB/DynamicLibrary @ 13041

Revision 13041, 2.6 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSGDB_DYNAMICLIBRARY
15#define OSGDB_DYNAMICLIBRARY 1
16
17#include <osg/Referenced>
18#include <osgDB/Export>
19
20#include <string>
21
22
23namespace osgDB {
24
25/** DynamicLibrary - encapsulates the loading and unloading of dynamic libraries,
26    typically used for loading ReaderWriter plug-ins.
27*/
28class OSGDB_EXPORT DynamicLibrary : public osg::Referenced
29{
30    public:
31
32        typedef void*   HANDLE;
33        typedef void*   PROC_ADDRESS;
34
35        /** returns a pointer to a DynamicLibrary object on successfully
36          * opening of library returns NULL on failure.
37          */
38        static DynamicLibrary* loadLibrary(const std::string& libraryName);
39
40        /** return name of library stripped of path.*/
41        const std::string& getName() const     { return _name; }
42
43        /** return name of library including full path to it.*/
44        const std::string& getFullName() const { return _fullName; }
45
46        /** return handle to .dso/.dll dynamic library itself.*/
47        HANDLE             getHandle() const   { return _handle; }
48
49        /** return address of function located in library.*/
50        PROC_ADDRESS       getProcAddress(const std::string& procName);
51
52    protected:
53
54        /** get handle to library file */
55        static HANDLE getLibraryHandle( const std::string& libraryName);
56
57        /** disallow default constructor.*/
58        DynamicLibrary():osg::Referenced() {}
59        /** disallow copy constructor.*/
60        DynamicLibrary(const DynamicLibrary&):osg::Referenced() {}
61        /** disallow copy operator.*/
62        DynamicLibrary& operator = (const DynamicLibrary&) { return *this; }
63
64        /** Disallow public construction so that users have to go
65          * through loadLibrary() above which returns NULL on
66          * failure, a valid DynamicLibrary object on success.
67          */
68        DynamicLibrary(const std::string& name,HANDLE handle);
69        ~DynamicLibrary();
70
71        HANDLE          _handle;
72        std::string     _name;
73        std::string     _fullName;
74
75};
76
77}
78
79#endif // __DYNAMIC_LIBRARY_H
Note: See TracBrowser for help on using the browser.