root / CCV-HAND / libs / poco / include / Poco / SharedLibrary.h @ 59

View | Annotate | Download (3.9 KB)

1
//
2
// SharedLibrary.h
3
//
4
// $Id: //poco/1.3/Foundation/include/Poco/SharedLibrary.h#1 $
5
//
6
// Library: Foundation
7
// Package: SharedLibrary
8
// Module:  SharedLibrary
9
//
10
// Definition of the SharedLibrary class.
11
//
12
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
13
// and Contributors.
14
//
15
// Permission is hereby granted, free of charge, to any person or organization
16
// obtaining a copy of the software and accompanying documentation covered by
17
// this license (the "Software") to use, reproduce, display, distribute,
18
// execute, and transmit the Software, and to prepare derivative works of the
19
// Software, and to permit third-parties to whom the Software is furnished to
20
// do so, all subject to the following:
21
// 
22
// The copyright notices in the Software and this entire statement, including
23
// the above license grant, this restriction and the following disclaimer,
24
// must be included in all copies of the Software, in whole or in part, and
25
// all derivative works of the Software, unless such copies or derivative
26
// works are solely in the form of machine-executable object code generated by
27
// a source language processor.
28
// 
29
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
32
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
33
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
34
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
35
// DEALINGS IN THE SOFTWARE.
36
//
37
38
39
#ifndef Foundation_SharedLibrary_INCLUDED
40
#define Foundation_SharedLibrary_INCLUDED
41
42
43
#include "Poco/Foundation.h"
44
45
46
#if defined(hpux) || defined(_hpux)
47
#include "Poco/SharedLibrary_HPUX.h"
48
#elif defined(POCO_OS_FAMILY_UNIX)
49
#include "Poco/SharedLibrary_UNIX.h"
50
#elif defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
51
#include "Poco/SharedLibrary_WIN32U.h"
52
#elif defined(POCO_OS_FAMILY_WINDOWS)
53
#include "Poco/SharedLibrary_WIN32.h"
54
#elif defined(POCO_OS_FAMILY_VMS)
55
#include "Poco/SharedLibrary_VMS.h"
56
#endif
57
58
59
namespace Poco {
60
61
62
class Foundation_API SharedLibrary: private SharedLibraryImpl
63
        /// The SharedLibrary class dynamically 
64
        /// loads shared libraries at run-time.
65
{
66
public:
67
        SharedLibrary();
68
                /// Creates a SharedLibrary object.
69
                
70
        SharedLibrary(const std::string& path);
71
                /// Creates a SharedLibrary object and loads a library
72
                /// from the given path.
73
74
        virtual ~SharedLibrary();
75
                /// Destroys the SharedLibrary. The actual library
76
                /// remains loaded.
77
78
        void load(const std::string& path);
79
                /// Loads a shared library from the given path.
80
                /// Throws a LibraryAlreadyLoadedException if
81
                /// a library has already been loaded.
82
                /// Throws a LibraryLoadException if the library
83
                /// cannot be loaded.
84
85
        void unload();
86
                /// Unloads a shared library.
87
88
        bool isLoaded() const;
89
                /// Returns true iff a library has been loaded.
90
91
        bool hasSymbol(const std::string& name);
92
                /// Returns true iff the loaded library contains
93
                /// a symbol with the given name.
94
95
        void* getSymbol(const std::string& name);
96
                /// Returns the address of the symbol with
97
                /// the given name. For functions, this
98
                /// is the entry point of the function.
99
                /// Throws a NotFoundException if the symbol
100
                /// does not exist.
101
                
102
        const std::string& getPath() const;
103
                /// Returns the path of the library, as
104
                /// specified in a call to load() or the 
105
                /// constructor.
106
                
107
        static std::string suffix();
108
                /// Returns the platform-specific filename suffix
109
                /// for shared libraries (including the period).
110
                /// In debug mode, the suffix also includes a
111
                /// "d" to specify the debug version of a library.
112
                
113
private:
114
        SharedLibrary(const SharedLibrary&);
115
        SharedLibrary& operator = (const SharedLibrary&);
116
};
117
118
119
} // namespace Poco
120
121
122
#endif // Foundation_SharedLibrary_INCLUDED