InspIRCd  3.0
dynamic.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  * Copyright (C) 2013, 2019-2020 Sadie Powell <[email protected]>
5  * Copyright (C) 2012 Robby <[email protected]>
6  * Copyright (C) 2012 ChrisTX <[email protected]>
7  * Copyright (C) 2009-2010 Daniel De Graaf <[email protected]>
8  * Copyright (C) 2007 Oliver Lupton <[email protected]>
9  * Copyright (C) 2007 Dennis Friis <[email protected]>
10  * Copyright (C) 2006 Craig Edwards <[email protected]>
11  *
12  * This file is part of InspIRCd. InspIRCd is free software: you can
13  * redistribute it and/or modify it under the terms of the GNU General Public
14  * License as published by the Free Software Foundation, version 2.
15  *
16  * This program is distributed in the hope that it will be useful, but WITHOUT
17  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19  * details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <http://www.gnu.org/licenses/>.
23  */
24 
25 
26 #pragma once
27 
31 class CoreExport DLLManager : public classbase
32 {
33  private:
35  std::string err;
36 
38 #ifdef _WIN32
39  HMODULE lib;
40 #else
41  void* lib;
42 #endif
43 
45  const std::string libname;
46 
48  void RetrieveLastError();
49 
50  public:
54  DLLManager(const std::string& name);
55 
57  ~DLLManager();
58 
62  Module* CallInit();
63 
68  void* GetSymbol(const char* name) const;
69 
74  template <typename TReturn>
75  TReturn* GetSymbol(const char* name) const
76  {
77  return static_cast<TReturn*>(GetSymbol(name));
78  }
79 
81  const char* GetVersion() const { return GetSymbol<const char>(MODULE_STR_VERSION); }
82 
84  const std::string& LastError() const { return err; }
85 
87  const std::string& LibraryName() const { return libname; }
88 };
DLLManager::LibraryName
const std::string & LibraryName() const
Definition: dynamic.h:87
classbase
Definition: base.h:47
DLLManager::LastError
const std::string & LastError() const
Definition: dynamic.h:84
DLLManager::GetSymbol
TReturn * GetSymbol(const char *name) const
Definition: dynamic.h:75
Module
Definition: modules.h:316
DLLManager::GetVersion
const char * GetVersion() const
Definition: dynamic.h:81
DLLManager
Definition: dynamic.h:31