oaCommonSharedLib.h

Go to the documentation of this file.
00001 // *****************************************************************************
00002 // *****************************************************************************
00003 // oaCommonSharedLib.h
00004 //
00005 // This file contains the definition of the SharedLib and supporting classes. 
00006 //
00007 // SharedLib
00008 //      This is class represents a shared library. It is used to 
00009 //      programmatically load shared libraries and to obtain symbols. 
00010 //
00011 // *****************************************************************************
00012 // Except as specified in the OpenAccess terms of use of Cadence or Silicon
00013 // Integration Initiative, this material may not be copied, modified,
00014 // re-published, uploaded, executed, or distributed in any way, in any medium,
00015 // in whole or in part, without prior written permission from Cadence.
00016 //
00017 //                Copyright 2002-2005 Cadence Design Systems, Inc.
00018 //                           All Rights Reserved.
00019 //
00020 //  $Author: icftcm $
00021 //  $Revision: #1 $
00022 //  $Date: 2010/08/09 $
00023 //  $State$
00024 // *****************************************************************************
00025 // *****************************************************************************
00026 
00027 
00028 
00029 #if !defined(oaCommonSharedLib_P)
00030 #define oaCommonSharedLib_P
00031 
00032 
00033 
00034 // *****************************************************************************
00035 // Nested includes
00036 // *****************************************************************************
00037 #include "oaCommonTypes.h"
00038 
00039 #if defined(OA_WINDOWS)
00040 #include <WinSock2.h>
00041 #else
00042 #include <sys/times.h>
00043 #include <utility>
00044 #include <dlfcn.h>
00045 #include <unistd.h>
00046 #endif
00047 
00048 #if defined(HPUX)
00049 #include <dl.h>
00050 #endif
00051 
00052 #include <string>
00053 
00054 
00055 
00056 // *****************************************************************************
00057 // Declare and define types in the oaCommon namespace
00058 // *****************************************************************************
00059 BEGIN_OA_COMMON_NAMESPACE
00060 
00061 
00062 
00063 // *****************************************************************************
00064 // SharedLibHandle
00065 // *****************************************************************************
00066 #if defined(OA_WINDOWS)
00067 typedef HINSTANCE SharedLibHandle;
00068 #else
00069 typedef void *SharedLibHandle;
00070 #endif
00071 
00072 
00073 
00074 // *****************************************************************************
00075 // SharedLib
00076 // *****************************************************************************
00077 class OA_COMMON_DLL_API SharedLib {
00078 public:
00079                             SharedLib(const char *baseNameIn);
00080 
00081     oa::oaBoolean           isOpen() const;
00082     const char              *getPath() const;
00083     void                    getName(std::string &name) const;
00084 
00085     void                    open();
00086     void                    close();
00087     void                    *getSymbol(const char *symbol) const;
00088 
00089 protected:
00090     std::string             baseName;
00091     mutable std::string     path;
00092     SharedLibHandle         lib;
00093 };
00094 
00095 
00096 
00097 END_OA_COMMON_NAMESPACE
00098 
00099 #endif

Return to top of page