Click here to Skip to main content
15,899,025 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: What does this do? Pin
David Crow10-Oct-03 5:49
David Crow10-Oct-03 5:49 
GeneralRe: What does this do? Pin
FlyingDancer11-Oct-03 4:48
FlyingDancer11-Oct-03 4:48 
GeneralRe: An interesting code Pin
Anthony_Yio10-Oct-03 1:45
Anthony_Yio10-Oct-03 1:45 
GeneralRe: An interesting code Pin
TW10-Oct-03 2:30
TW10-Oct-03 2:30 
GeneralRe: An interesting code Pin
Earl Allen10-Oct-03 20:07
Earl Allen10-Oct-03 20:07 
GeneralRe: An interesting code Pin
Steve S12-Oct-03 22:37
Steve S12-Oct-03 22:37 
GeneralForm and Button like MS Office assistance in vc++ Pin
sunju9-Oct-03 20:11
sunju9-Oct-03 20:11 
Generaltemplate question Pin
Steve Messer9-Oct-03 19:48
Steve Messer9-Oct-03 19:48 
I am trying to use a struct as a parameter to a template. I am trying to use the struct as an abstract interface to a plugin architecture. The problem is that I can't seem to instantiate it correctly. Here is the code below. Any ideas what I am doing wrong. All the example for templates seems to exclusively use stack for there example.

// Here is how I am trying to instantiate it

CPlugin<I_Plugin>PLUGIN;
PLUGIN.Load("HTPCPlugin.dll", "GetPlugin"); // compiler pukes here

Compiling...
HTPCCOREDlg.cpp
d:\htpccore\htpccoredlg.cpp(117) : error C2143: syntax error : missing ';' before '.'
d:\htpccore\htpccoredlg.cpp(117) : error C2501: 'PLUGIN' : missing storage-class or type specifiers
d:\htpccore\htpccoredlg.cpp(117) : error C2371: 'PLUGIN' : redefinition; different basic types
d:\htpccore\htpccoredlg.cpp(115) : see declaration of 'PLUGIN'
d:\htpccore\htpccoredlg.cpp(117) : error C2143: syntax error : missing ';' before '.'
Error executing cl.exe.
Creating browse info file...

HTPCCORE.exe - 4 error(s), 0 warning(s)

// Below is the template and interface

struct I_Plugin
{
public:
virtual ~I_Plugin() { }

virtual void Initialize() = 0; // We'll use this to initialize the object
virtual void Destroy() = 0; // We'll use this to destroy the object
virtual void Config() = 0;
virtual void Release() = 0;
virtual void SendMessage( CString ModuleName , UINT Msg, WPARAM wParam, LPARAM lParam ) = 0;
};

template<typename T>
class CPlugin
{
public:

CPlugin():m_hLibrary(0), m_pPlugin(0){}
~CPlugin(){}

T* Load( const char* szDLLName, const char* szFunction )
{
LOADPLUGIN pfnLoad;
// Load our plugin
m_hLibrary = (HINSTANCE)::LoadLibrary( szDLLName );
// Handle errors
if( m_hLibrary == NULL )
return 0;

// Get Address of our plugin accessing function
pfnLoad = (LOADPLUGIN)::GetProcAddress( m_hLibrary, szFunction );
// Get our plugin
if( pfnLoad)
{
pfnLoad( &m_pPlugin );
}
return m_pPlugin;
}

void Release()
{
if( m_pPlugin == 0 )
return;

m_pPlugin->Release();
::FreeLibrary( m_hLibrary );
}

private:

T* m_pPlugin;
typedef void (*LOADPLUGIN)(T**);
HINSTANCE m_hLibrary;
};
GeneralRe: template question Pin
Joaquín M López Muñoz9-Oct-03 20:05
Joaquín M López Muñoz9-Oct-03 20:05 
GeneralRe: template question Pin
Steve Messer9-Oct-03 20:49
Steve Messer9-Oct-03 20:49 
GeneralRe: template question Pin
Joaquín M López Muñoz9-Oct-03 20:53
Joaquín M López Muñoz9-Oct-03 20:53 
GeneralRe: template question Pin
Steve Messer9-Oct-03 21:04
Steve Messer9-Oct-03 21:04 
GeneralRe: template question Pin
Joaquín M López Muñoz9-Oct-03 21:08
Joaquín M López Muñoz9-Oct-03 21:08 
GeneralRe: template question Pin
Steve Messer9-Oct-03 21:11
Steve Messer9-Oct-03 21:11 
GeneralRe: template question Pin
Joaquín M López Muñoz9-Oct-03 21:23
Joaquín M López Muñoz9-Oct-03 21:23 
GeneralRe: template question Pin
Steve Messer9-Oct-03 21:30
Steve Messer9-Oct-03 21:30 
GeneralRe: template question Pin
Steve Messer9-Oct-03 21:08
Steve Messer9-Oct-03 21:08 
GeneralStrange things with parameters. Pin
esepich9-Oct-03 19:10
esepich9-Oct-03 19:10 
GeneralRe: Strange things with parameters. Pin
Anand Paranjpe9-Oct-03 19:52
Anand Paranjpe9-Oct-03 19:52 
GeneralDefine triangle class Pin
Anonymous9-Oct-03 18:40
Anonymous9-Oct-03 18:40 
GeneralRe: Define triangle class Pin
W. Hammer -sledge-11-Oct-03 9:29
W. Hammer -sledge-11-Oct-03 9:29 
GeneralHello &#213;&#226;&#202;&#199;&#202;&#178;&#195;&#180;&#209;&#189;&#163;&#191; Pin
hy_huangh9-Oct-03 18:36
hy_huangh9-Oct-03 18:36 
GeneralRe: Hello ÕâÊÇʲôѽ£¿ Pin
David Stone9-Oct-03 18:56
sitebuilderDavid Stone9-Oct-03 18:56 
GeneralFloating point calculation Pin
act_x9-Oct-03 18:20
act_x9-Oct-03 18:20 
GeneralRe: Floating point calculation Pin
Anand Paranjpe9-Oct-03 20:05
Anand Paranjpe9-Oct-03 20:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.