aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/plugger.h47
-rw-r--r--src/test/xmlreadtest.cpp8
-rw-r--r--src/test/xmlwritetest.cpp10
3 files changed, 42 insertions, 23 deletions
diff --git a/src/plugger.h b/src/plugger.h
index 5f7df6d..aad8b9a 100644
--- a/src/plugger.h
+++ b/src/plugger.h
@@ -13,35 +13,54 @@ typedef struct PluginInfo
13 const char *sAuthor; 13 const char *sAuthor;
14 unsigned short nVersion; 14 unsigned short nVersion;
15 unsigned short nRevision; 15 unsigned short nRevision;
16 class Plugin *(*createPlugin)(); 16 void *(*createPlugin)();
17 void (*destroyPlugin)( class Plugin * ); 17 void (*destroyPlugin)( void * );
18} PluginInfo; 18} PluginInfo;
19 19
20typedef struct PluginReg
21{
22 bool bBuiltin;
23 void *dlHandle;
24 PluginInfo *pInfo;
25} PluginReg;
26
20#define PluginInterface( classname, baseclass, name, ver, rev ) \ 27#define PluginInterface( classname, baseclass, name, ver, rev ) \
21extern "C" { \ 28extern "C" { \
22 class baseclass *create ##classname() \ 29 baseclass *create ##classname() \
23 { \ 30 { \
24 return new classname(); \ 31 return new classname(); \
25 } \ 32 } \
26 void destroy ##classname( class baseclass *pCls ) \ 33 void destroy ##classname( baseclass *pCls ) \
27 { \ 34 { \
28 delete pCls; \ 35 delete pCls; \
29 } \ 36 } \
30 PluginInfo classname = { #classname, name, ver, rev, \ 37 PluginInfo classname = { \
38 #classname, name, ver, rev, \
31 create ##classname, destroy ##classname }; \ 39 create ##classname, destroy ##classname }; \
32} 40}
33 41
34typedef struct PluginReg 42#define PluginInterface2( pluginname, classname, baseclass, name, ver, rev ) \
35{ 43extern "C" { \
36 bool bBuiltin; 44 baseclass *create ##classname() \
37 void *dlHandle; 45 { \
38 PluginInfo *pInfo; 46 return new classname(); \
39} PluginReg; 47 } \
48 void destroy ##classname( baseclass *pCls ) \
49 { \
50 delete pCls; \
51 } \
52 PluginInfo pluginname = { \
53 #pluginname, name, ver, rev, \
54 (void *(*)())(create ##classname), \
55 (void (*)( void * ))(destroy ##classname) }; \
56}
40 57
41template<class T> 58template<class T>
42class Plugger 59class Plugger
43{ 60{
44public: 61public:
62
63public:
45 Plugger() : 64 Plugger() :
46 hPlugin( new HashFunctionString(), 11 ), 65 hPlugin( new HashFunctionString(), 11 ),
47 hObj( new HashFunctionInt(), 11 ) 66 hObj( new HashFunctionInt(), 11 )
@@ -96,9 +115,9 @@ public:
96 if( pReg == NULL ) 115 if( pReg == NULL )
97 return NULL; 116 return NULL;
98 117
99 T *p = pReg->pInfo->createPlugin(); 118 T *p = (T *)pReg->pInfo->createPlugin();
100 hObj.insert( p, pReg ); 119 hObj.insert( p, pReg );
101 printf("pReg: %08X, pPlug: %08X\n", pReg, p ); 120 //printf("pReg: %08X, pPlug: %08X\n", pReg, p );
102 121
103 return p; 122 return p;
104 } 123 }
@@ -106,7 +125,7 @@ public:
106 void destroy( T *pPlug ) 125 void destroy( T *pPlug )
107 { 126 {
108 PluginReg *pReg = (PluginReg *)hObj[pPlug]; 127 PluginReg *pReg = (PluginReg *)hObj[pPlug];
109 printf("pReg: %08X, pPlug: %08X\n", pReg, pPlug ); 128 //printf("pReg: %08X, pPlug: %08X\n", pReg, pPlug );
110 if( pReg == NULL ) 129 if( pReg == NULL )
111 return; 130 return;
112 131
diff --git a/src/test/xmlreadtest.cpp b/src/test/xmlreadtest.cpp
index f6d8d8b..e2d2a0a 100644
--- a/src/test/xmlreadtest.cpp
+++ b/src/test/xmlreadtest.cpp
@@ -14,14 +14,14 @@ int main( int argc, char *argv[] )
14 if( argv[1][0] == 'f' ) 14 if( argv[1][0] == 'f' )
15 { 15 {
16 XmlFileReader r( argv[2], true ); 16 XmlFileReader r( argv[2], true );
17 XmlFileWriter w( argv[3], "\t", r.detatchRoot() ); 17// XmlFileWriter w( argv[3], "\t", r.detatchRoot() );
18 w.write(); 18// w.write();
19 } 19 }
20 else if( argv[1][0] == 's' ) 20 else if( argv[1][0] == 's' )
21 { 21 {
22 XmlStringReader r( argv[2], true ); 22 XmlStringReader r( argv[2], true );
23 XmlWriter w( argv[3], "\t", r.detatchRoot() ); 23// XmlWriter w( argv[3], "\t", r.detatchRoot() );
24 w.write(); 24// w.write();
25 } 25 }
26 26
27 return 0; 27 return 0;
diff --git a/src/test/xmlwritetest.cpp b/src/test/xmlwritetest.cpp
index 340c9a3..2986c35 100644
--- a/src/test/xmlwritetest.cpp
+++ b/src/test/xmlwritetest.cpp
@@ -28,14 +28,14 @@ void fillItIn( XmlWriter &w )
28int main() 28int main()
29{ 29{
30 printf("Testing XmlWriter...\n"); 30 printf("Testing XmlWriter...\n");
31 XmlFileWriter wf("test.xml", "\t"); 31 //XmlFileWriter wf("test.xml", "\t");
32 32
33 fillItIn( wf ); 33 //fillItIn( wf );
34 34
35 XmlStringWriter ws("\t"); 35 //XmlStringWriter ws("\t");
36 fillItIn( ws ); 36 //fillItIn( ws );
37 37
38 printf("Now the string version:\n\n%s\n", ws.getString().c_str() ); 38 //printf("Now the string version:\n\n%s\n", ws.getString().c_str() );
39 39
40 return 0; 40 return 0;
41} 41}