/
libraryfile.h
102 lines (89 loc) · 3.09 KB
/
libraryfile.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* The Doomsday Engine Project -- libdeng2
*
* Copyright (c) 2009-2012 Jaakko Keränen <jaakko.keranen@iki.fi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LIBDENG2_LIBRARYFILE_H
#define LIBDENG2_LIBRARYFILE_H
#include "../File"
namespace de
{
class Library;
/**
* Provides a way to load and unload a shared library. The Library will be
* loaded automatically when someone attempts to use it. Unloading the
* library occurs when the LibraryFile instance is deleted, or when
* unload() is called.
*
* @see Library
*
* @ingroup fs
*/
class DENG2_PUBLIC LibraryFile : public File
{
public:
/// Attempted to load a shared library from a source file with unsupported type.
/// @ingroup errors
DENG2_ERROR(UnsupportedSourceError);
public:
/**
* Constructs a new LibraryFile instance.
*
* @param source Library file. Ownership transferred to LibraryFile.
*/
LibraryFile(File* source);
/**
* When the LibraryFile is deleted the library is gets unloaded.
*/
virtual ~LibraryFile();
/**
* Determines whether the library is loaded and ready for use.
*
* @return @c true, if the library has been loaded.
*/
bool loaded() const { return _library != 0; }
/**
* Provides access to the loaded library. Automatically attempts to load
* the library if it hasn't been loaded yet.
*
* @return The library.
*/
Library& library();
/**
* Unloads the library.
*/
void clear();
/**
* Checks whether the name of the library file matches. An "underscore
* name" is a convention used for some plugins where the name of the
* plugin is prefixed by, e.g., "audio_". The "underscore name" is the
* part of the file that follows the underscore.
*
* @param nameAfterUnderscore Part of the name following underscore.
*/
bool hasUnderscoreName(const String& nameAfterUnderscore) const;
public:
/**
* Determines whether a file appears suitable for use with LibraryFile.
*
* @param file File whose content to recognize.
*/
static bool recognize(const File& file);
private:
Library* _library;
};
}
#endif /* LIBDENG2_LIBRARYFILE_H */