• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

sharedlib.h

Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
00003 //   Foundation, Inc
00004 // 
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00019 #ifndef GNASH_SHAREDLIB_H
00020 #define GNASH_SHAREDLIB_H
00021 
00022 #ifdef HAVE_CONFIG_H
00023 #include "gnashconfig.h"
00024 #endif
00025 
00026 #include <boost/thread/mutex.hpp>
00027 #include <string>
00028 #include "dsodefs.h" // DSOEXPORT
00029 
00030 #ifdef _WIN32
00031 #undef DLL_EXPORT
00032 #define LIBLTDL_DLL_IMPORT 1
00033 #endif
00034 
00035 #include <ltdl.h>
00036 
00037 // Used on Darwin for basename
00038 #ifdef HAVE_LIBGEN_H
00039 #include <libgen.h>
00040 #endif
00041 
00042 namespace gnash {
00043     class as_object;
00044 }
00045 
00046 namespace gnash {
00047 
00049 class SharedLib
00050 {
00051     typedef boost::mutex::scoped_lock scoped_lock;
00052 
00053 public:
00054     // Typedefs for function pointers to keep the code readable
00055     typedef bool entrypoint (void *obj);
00056     typedef void initentry(as_object &obj);
00057     
00058     SharedLib(const std::string& filespec);
00059     DSOEXPORT SharedLib(const std::string& filespec, const std::string& envvar);
00060     ~SharedLib();
00061 
00062     DSOEXPORT bool openLib();
00063     bool openLib(const std::string &filespec);
00064     
00065     // Get a C symbol from the shared library based on the name
00066     entrypoint *getDllSymbol (const std::string& symbol);
00067     DSOEXPORT initentry *getInitEntry (const std::string& symbol);
00068     
00069 private:
00070 
00071     bool closeLib();
00072 
00073     lt_dlhandle _dlhandle;
00074     std::string _filespec;
00075     boost::mutex _libMutex;    
00076 };
00077 
00078 } // end of gnash namespace
00079 
00080 // GNASH_SHAREDLIB_H
00081 #endif
00082 
00083 // Local Variables:
00084 // mode: C++
00085 // indent-tabs-mode: t
00086 // End:

Generated on Thu Sep 30 2010 14:35:02 for Gnash by  doxygen 1.7.1