Scopira 20080306

dll.h

00001 
00002 /*
00003  *  Copyright (c) 2002-2004    National Research Council
00004  *
00005  *  All rights reserved.
00006  *
00007  *  This material is confidential and proprietary information of
00008  *  National Research Council Canada ("Confidential Information").
00009  *  This Confidential Information may only be used and reproduced
00010  *  in accordance with the terms of the license agreement.
00011  *
00012  */
00013 
00014 #ifndef __INCLUDED_SCOPIRA_TOOL_DLL_H__
00015 #define __INCLUDED_SCOPIRA_TOOL_DLL_H__
00016 
00017 #include <string>
00018 
00019 #include <scopira/tool/platform.h>
00020 #include <scopira/tool/object.h>
00021 #include <scopira/tool/export.h>
00022 
00023 namespace scopira
00024 {
00025   namespace tool
00026   {
00027     class dll;
00028 
00030     SCOPIRA_EXPORT extern const char *dll_ext_c;
00031   }
00032 }
00033 
00039 class scopira::tool::dll : public virtual scopira::tool::object
00040 {
00041   protected:
00042 #ifdef PLATFORM_win32
00043     typedef HINSTANCE LIB_HANDLE;
00044 #else
00045     typedef void* LIB_HANDLE;
00046 #endif
00047     
00048     mutable LIB_HANDLE dm_handle;
00049     bool dm_open;
00050     const char * dm_lasterror;
00051 
00052   public:
00053 
00054     typedef void (*voidfunc_t)(void);
00055 
00057     SCOPIRA_EXPORT dll(void);
00059     SCOPIRA_EXPORT virtual ~dll();
00060 
00068     SCOPIRA_EXPORT bool load_dll(std::string _name);
00069 
00077     SCOPIRA_EXPORT void * get_sym(const std::string & _name) const;
00078 
00083     const char *get_error(void) const { return dm_lasterror; }
00084 
00085   protected:
00086 
00088     SCOPIRA_EXPORT virtual bool dll_init(const std::string & _name);
00090     SCOPIRA_EXPORT virtual void dll_close(void);
00092     SCOPIRA_EXPORT void check_error(void);
00093 };
00094 
00095 #endif
00096