@@ -24,25 +24,10 @@ namespace HttpServer
2424 #endif
2525
2626 public:
27- Module (): lib_handle(nullptr )
28- {
29-
30- }
31-
32- Module (const std::string &libPath): lib_handle(nullptr )
33- {
34- open (libPath);
35- }
36-
37- Module (const Module &module ) : lib_handle(module .lib_handle)
38- {
39-
40- }
41-
42- Module (Module &&module ) : lib_handle(module .lib_handle)
43- {
44- module .lib_handle = nullptr ;
45- }
27+ Module ();
28+ Module (const std::string &libPath);
29+ Module (const Module &module );
30+ Module (Module &&module );
4631
4732 ~Module () = default ;
4833
@@ -51,84 +36,23 @@ namespace HttpServer
5136 return nullptr != lib_handle;
5237 }
5338
54- inline bool open (const std::string &libPath)
55- {
56- #ifdef WIN32
57- lib_handle = ::LoadLibrary (libPath.c_str () );
58- #elif POSIX
59- lib_handle = ::dlopen (libPath.c_str (), RTLD_NOW);
60- #else
61- #error "Undefine platform"
62- #endif
63-
64- return (nullptr != lib_handle);
65- }
66-
67- inline void close ()
68- {
69- if (lib_handle)
70- {
71- #ifdef WIN32
72- ::FreeLibrary (lib_handle);
73- #elif POSIX
74- ::dlclose (lib_handle);
75- #else
76- #error "Undefine platform"
77- #endif
39+ bool open (const std::string &libPath);
40+ void close ();
7841
79- lib_handle = nullptr ;
80- }
81- }
42+ bool find (const std::string &symbolName, void *(**addr)(void *) ) const ;
43+ bool find (const char *symbolName, void *(**addr)(void *) ) const ;
8244
83- inline bool find (const std::string &symbolName, void **addr ) const
45+ inline bool operator == (const Module & module ) const
8446 {
85- if (lib_handle)
86- {
87- #ifdef WIN32
88- *addr = ::GetProcAddress (lib_handle, symbolName.c_str () );
89-
90- return nullptr != *addr;
91- #elif POSIX
92- ::dlerror ();
93-
94- *addr = ::dlsym (lib_handle, symbolName.c_str () );
95-
96- char *error = ::dlerror ();
97-
98- return nullptr == error;
99- #else
100- #error "Undefine platform"
101- #endif
102- }
103-
104- return false ;
47+ return lib_handle == module .lib_handle ;
10548 }
10649
107- inline bool find (const char *symbolName, void **addr ) const
50+ inline bool operator != (const Module & module ) const
10851 {
109- if (lib_handle)
110- {
111- #ifdef WIN32
112- *addr = ::GetProcAddress (lib_handle, symbolName);
113-
114- return nullptr != *addr;
115- #elif POSIX
116- *addr = ::dlsym (lib_handle, symbolName);
117-
118- char *error = ::dlerror ();
119-
120- return nullptr == error;
121- #else
122- #error "Undefine platform"
123- #endif
124- }
125-
126- return false ;
52+ return lib_handle != module .lib_handle ;
12753 }
12854
129- inline bool operator ==(const Module &module ) const
130- {
131- return lib_handle == module .lib_handle ;
132- }
55+ Module &operator =(const Module &);
56+ Module &operator =(Module &&);
13357 };
13458};
0 commit comments