1 /*****************************************************************************/
2 /* Software Testing Automation Framework (STAF)                              */
3 /* (C) Copyright IBM Corp. 2001                                              */
4 /*                                                                           */
5 /* This software is licensed under the Eclipse Public License (EPL) V1.0.    */
6 /*****************************************************************************/
7 
8 #ifndef STAF_DynamicLibrary
9 #define STAF_DynamicLibrary
10 
11 #include "STAFString.h"
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 /* Begin C language definitions */
18 
19 typedef struct STAFDynamicLibraryImplementation *STAFDynamicLibrary_t;
20 
21 /***********************************************************************/
22 /* STAFDynamicLibraryOpen - Creates a STAF Mutex sempahore             */
23 /*                                                                     */
24 /* Accepts: (Out) Pointer to a dynamic library                         */
25 /*          (In)  The name of the dynamic library                      */
26 /*          (Out) Pointer to STAFString_t (if RC=kSTAFBaseOSError,     */
27 /*                this will contain an OS dependent message, in which  */
28 /*                case it must be freed with STAFStringDestruct().     */
29 /*                                                                     */
30 /* Returns:  kSTAFOk, on success                                       */
31 /*           other on error                                            */
32 /***********************************************************************/
33 STAFRC_t STAFDynamicLibraryOpen(STAFDynamicLibrary_t *pDynaLib,
34                                 const char *name, STAFString_t *osMessage);
35 
36 /***********************************************************************/
37 /* STAFDynamicLibraryGetAddress - Retrieves an address from a dynamic  */
38 /*                                library by name.                     */
39 /*                                                                     */
40 /* Accepts: (In)  A dynamic library                                    */
41 /*          (In)  The name of the address to get                       */
42 /*          (Out) A pointer to the address to be set                   */
43 /*          (Out) Pointer to STAFString_t (if RC=1, this will contain  */
44 /*                an OS dependent message, in which case it must be    */
45 /*                with STAFStringDestruct().                           */
46 /*                an OS dependent message. This must be freed with     */
47 /*                freed with STAFStringDestruct().                     */
48 /*                                                                     */
49 /* Returns:  kSTAFOk, on success                                       */
50 /*           other on error                                            */
51 /***********************************************************************/
52 STAFRC_t STAFDynamicLibraryGetAddress(STAFDynamicLibrary_t dynaLib,
53                                       const char *name, void **address,
54                                       STAFString_t *osMessage);
55 
56 /***********************************************************************/
57 /* STAFDynamicLibraryClose - Closes a Dynamic Library                  */
58 /*                                                                     */
59 /* Accepts: (In)  Pointer to a dynamic library                         */
60 /*          (Out) Pointer to STAFString_t (if RC=1, this will contain  */
61 /*                an OS dependent message, in which case it must be    */
62 /*                freed with STAFStringDestruct().                     */
63 /*                                                                     */
64 /* Returns:  kSTAFOk, on success                                       */
65 /*           other on error                                            */
66 /***********************************************************************/
67 STAFRC_t STAFDynamicLibraryClose(STAFDynamicLibrary_t *pDynaLib,
68                                  STAFString_t *osMessage);
69 
70 /* End C language definitions */
71 
72 #ifdef __cplusplus
73 }
74 
75 // Begin C++ language definitions
76 
77 #include "STAFException.h"
78 
79 // STAFDynamicLibrary - This class provides a C++ wrapper around the STAF
80 //                      Dynamic Library C APIs.
81 
82 class STAFDynamicLibrary
83 {
84 public:
85 
86     STAFDynamicLibrary(const char *libraryName);
87 
88     void *getAddress(const char *name);
89 
90     ~STAFDynamicLibrary();
91 
92 private:
93 
94     // Don't allow copy or assignment
95     STAFDynamicLibrary(const STAFDynamicLibrary &);
96     STAFDynamicLibrary &operator=(const STAFDynamicLibrary &);
97 
98     STAFDynamicLibrary_t fDynaLibImpl;
99 };
100 
101 
102 // Now include inline definitions
103 
104 #ifndef STAF_NATIVE_COMPILER
105 #include "STAFDynamicLibraryInlImpl.cpp"
106 #endif
107 
108 // End C++ language definitions
109 
110 // End #ifdef __cplusplus
111 #endif
112 
113 #endif
114