]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/dynamic.h
Removed deprecated class 'packet'
[user/henk/code/inspircd.git] / include / dynamic.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17
18 #ifndef __DLL_H
19 #define __DLL_H
20
21
22 class DLLManager
23 {
24  public:
25         DLLManager( const char *fname );
26         virtual ~DLLManager();
27
28
29         bool GetSymbol( void **, const char *sym_name );
30
31         const char *LastError() 
32         {
33                  return err;
34         }
35         
36  protected:
37         void *h;
38         const char *err;
39 };
40
41
42 class DLLFactoryBase : public DLLManager
43 {
44  public:
45         DLLFactoryBase(const char *fname, const char *func_name = 0);
46         virtual ~DLLFactoryBase();
47         void * (*factory_func)(void);   
48 };
49
50
51 template <class T> class DLLFactory : public DLLFactoryBase
52 {
53  public:
54         DLLFactory(const char *fname, const char *func_name=0) : DLLFactoryBase(fname,func_name)
55         {
56                 if (factory_func)
57                         factory = (T*)factory_func();
58                 else
59                         factory = 0;
60         }
61         
62         ~DLLFactory()
63         {
64                 delete factory;
65         }
66
67         T *factory;
68 };
69
70
71
72
73
74
75 #endif