~ubuntu-branches/ubuntu/vivid/mygui/vivid

« back to all changes in this revision

Viewing changes to MyGUIEngine/include/MyGUI_DynLib.h

  • Committer: Package Import Robot
  • Author(s): Scott Howard, Bret Curtis, Scott Howard
  • Date: 2014-09-18 17:57:48 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140918175748-dd8va78mvpw1jbes
Tags: 3.2.1-1
[ Bret Curtis ]
* Updated license for majority of files from LGPL to Expat (MIT)

[ Scott Howard ]
* New upstream release
* Updated patch to add build option for system GLEW libraries
* All patches accepted upstream except shared_libraries.patch
* Bumped SONAME due to dropped symbols, updated *.symbols and package
  names
* Updated license of debian/* to Expat with permission of all authors
* Don't install Doxygen autogenerated md5 and map files (thanks
  lintian)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*!
2
 
        @file
3
 
        @author         Denis Koronchik
4
 
        @author         Georgiy Evmenov
5
 
        @date           09/2007
6
 
*/
7
 
/*
8
 
        This file is part of MyGUI.
9
 
 
10
 
        MyGUI is free software: you can redistribute it and/or modify
11
 
        it under the terms of the GNU Lesser General Public License as published by
12
 
        the Free Software Foundation, either version 3 of the License, or
13
 
        (at your option) any later version.
14
 
 
15
 
        MyGUI is distributed in the hope that it will be useful,
16
 
        but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 
        GNU Lesser General Public License for more details.
19
 
 
20
 
        You should have received a copy of the GNU Lesser General Public License
21
 
        along with MyGUI.  If not, see <http://www.gnu.org/licenses/>.
22
 
*/
23
 
 
24
 
#ifndef __MYGUI_DYNLIB_H__
25
 
#define __MYGUI_DYNLIB_H__
26
 
 
27
 
#include "MyGUI_Prerequest.h"
28
 
#include <string>
29
 
 
30
 
 
31
 
#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
32
 
#    define MYGUI_DYNLIB_HANDLE hInstance
33
 
#    define MYGUI_DYNLIB_LOAD( a ) LoadLibrary( a )
34
 
#    define MYGUI_DYNLIB_GETSYM( a, b ) GetProcAddress( a, b )
35
 
#    define MYGUI_DYNLIB_UNLOAD( a ) !FreeLibrary( a )
36
 
 
37
 
struct HINSTANCE__;
38
 
typedef struct HINSTANCE__* hInstance;
39
 
 
40
 
#elif MYGUI_PLATFORM == MYGUI_PLATFORM_LINUX
41
 
#    define MYGUI_DYNLIB_HANDLE void*
42
 
#    define MYGUI_DYNLIB_LOAD( a ) dlopen( a, RTLD_LAZY | RTLD_GLOBAL)
43
 
#    define MYGUI_DYNLIB_GETSYM( a, b ) dlsym( a, b )
44
 
#    define MYGUI_DYNLIB_UNLOAD( a ) dlclose( a )
45
 
 
46
 
#elif MYGUI_PLATFORM == MYGUI_PLATFORM_APPLE
47
 
#    include <CoreFoundation/CFBundle.h>
48
 
#    define MYGUI_DYNLIB_HANDLE CFBundleRef
49
 
#    define MYGUI_DYNLIB_LOAD( a ) mac_loadExeBundle( a )
50
 
#    define MYGUI_DYNLIB_GETSYM( a, b ) mac_getBundleSym( a, b )
51
 
#    define MYGUI_DYNLIB_UNLOAD( a ) mac_unloadExeBundle( a )
52
 
#endif
53
 
 
54
 
namespace MyGUI
55
 
{
56
 
 
57
 
        /*! @brief Resource holding data about a dynamic library.
58
 
 
59
 
                @remarks
60
 
                This class holds the data required to get symbols from
61
 
                libraries loaded at run-time (i.e. from DLL's for so's)
62
 
        */
63
 
        class MYGUI_EXPORT DynLib
64
 
        {
65
 
                friend class DynLibManager;
66
 
 
67
 
        protected:
68
 
                DynLib(const std::string& name);
69
 
 
70
 
                ~DynLib();
71
 
 
72
 
        public:
73
 
 
74
 
                /*! Load the library
75
 
                */
76
 
                bool load();
77
 
 
78
 
                /*! Unload the library
79
 
                */
80
 
                void unload();
81
 
 
82
 
                //! Get the name of the library
83
 
                std::string getName(void) const;
84
 
 
85
 
                /**
86
 
                        Returns the address of the given symbol from the loaded library.
87
 
                        @param
88
 
                                strName The name of the symbol to search for
89
 
                        @returns
90
 
                                If the function succeeds, the returned value is a handle to the symbol.
91
 
                                If the function fails, the returned value is <b>nullptr</b>.
92
 
                */
93
 
                void* getSymbol( const std::string& strName ) const throw();
94
 
 
95
 
        protected:
96
 
                //! Gets the last loading error
97
 
                std::string dynlibError() const;
98
 
 
99
 
        protected:
100
 
                //!     Name of library
101
 
                std::string mName;
102
 
 
103
 
                //! Handle to the loaded library.
104
 
                MYGUI_DYNLIB_HANDLE mInstance;
105
 
        };
106
 
 
107
 
} // namespace MyGUI
108
 
 
109
 
#endif // __MYGUI_DYNLIB_H__
 
1
/*
 
2
 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
 
3
 * Distributed under the MIT License
 
4
 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
 
5
 */
 
6
 
 
7
#ifndef __MYGUI_DYNLIB_H__
 
8
#define __MYGUI_DYNLIB_H__
 
9
 
 
10
#include "MyGUI_Prerequest.h"
 
11
#include <string>
 
12
 
 
13
 
 
14
#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
 
15
#    define MYGUI_DYNLIB_HANDLE hInstance
 
16
#    define MYGUI_DYNLIB_LOAD( a ) LoadLibrary( a )
 
17
#    define MYGUI_DYNLIB_GETSYM( a, b ) GetProcAddress( a, b )
 
18
#    define MYGUI_DYNLIB_UNLOAD( a ) !FreeLibrary( a )
 
19
 
 
20
struct HINSTANCE__;
 
21
typedef struct HINSTANCE__* hInstance;
 
22
 
 
23
#elif MYGUI_PLATFORM == MYGUI_PLATFORM_LINUX
 
24
#    define MYGUI_DYNLIB_HANDLE void*
 
25
#    define MYGUI_DYNLIB_LOAD( a ) dlopen( a, RTLD_LAZY | RTLD_GLOBAL)
 
26
#    define MYGUI_DYNLIB_GETSYM( a, b ) dlsym( a, b )
 
27
#    define MYGUI_DYNLIB_UNLOAD( a ) dlclose( a )
 
28
 
 
29
#elif MYGUI_PLATFORM == MYGUI_PLATFORM_APPLE
 
30
#    include <CoreFoundation/CFBundle.h>
 
31
#    define MYGUI_DYNLIB_HANDLE CFBundleRef
 
32
#    define MYGUI_DYNLIB_LOAD( a ) mac_loadExeBundle( a )
 
33
#    define MYGUI_DYNLIB_GETSYM( a, b ) mac_getBundleSym( a, b )
 
34
#    define MYGUI_DYNLIB_UNLOAD( a ) mac_unloadExeBundle( a )
 
35
#endif
 
36
 
 
37
namespace MyGUI
 
38
{
 
39
 
 
40
        /*! @brief Resource holding data about a dynamic library.
 
41
 
 
42
                @remarks
 
43
                This class holds the data required to get symbols from
 
44
                libraries loaded at run-time (i.e. from DLL's for so's)
 
45
        */
 
46
        class MYGUI_EXPORT DynLib
 
47
        {
 
48
                friend class DynLibManager;
 
49
 
 
50
        protected:
 
51
                DynLib(const std::string& name);
 
52
 
 
53
                ~DynLib();
 
54
 
 
55
        public:
 
56
 
 
57
                /*! Load the library
 
58
                */
 
59
                bool load();
 
60
 
 
61
                /*! Unload the library
 
62
                */
 
63
                void unload();
 
64
 
 
65
                //! Get the name of the library
 
66
                std::string getName(void) const;
 
67
 
 
68
                /**
 
69
                        Returns the address of the given symbol from the loaded library.
 
70
                        @param
 
71
                                strName The name of the symbol to search for
 
72
                        @returns
 
73
                                If the function succeeds, the returned value is a handle to the symbol.
 
74
                                If the function fails, the returned value is <b>nullptr</b>.
 
75
                */
 
76
                void* getSymbol( const std::string& strName ) const throw();
 
77
 
 
78
        protected:
 
79
                //! Gets the last loading error
 
80
                std::string dynlibError() const;
 
81
 
 
82
        protected:
 
83
                //!     Name of library
 
84
                std::string mName;
 
85
 
 
86
                //! Handle to the loaded library.
 
87
                MYGUI_DYNLIB_HANDLE mInstance;
 
88
        };
 
89
 
 
90
} // namespace MyGUI
 
91
 
 
92
#endif // __MYGUI_DYNLIB_H__