Click here to Skip to main content
15,886,110 members
Articles / Programming Languages / C++

A Method to Implement Plug-In Functionality

Rate me:
Please Sign up or sign in to vote.
3.86/5 (8 votes)
29 Jan 2009CPOL5 min read 44K   331   33  
This article deals with the ability to support multiple communication protocols through the use of Plug-In Libraries
//*****************************************************************************
//                                                                            *
// Filename : plugin.h                                                        *
// Author   : Eric M Solliday                                                 *
// Date     : January 26, 2009                                                *
// Copyright: 2009, Sherric Group, LLC                                        *
//                                                                            *
// Description:                                                               *
// This is the interface file for the PluginDemo project.                     *
// This file describes the commands that are made available to the core app   *
// by the plug-in library.  The commands included in this file are for        *
// example purposes only.                                                     *
//                                                                            *
// This file is provided under the Code Project Open License (CPOL).          *
// No other warrenties are given or inferred.                                 *
//                                                                            *
//*****************************************************************************

#ifndef PLUGIN_H
#define PLUGIN_H

// Always include windows.h
#include <windows.h>

// Typedefs for the service functions (function pointers)
// In a more meaningful implementation, the signatures here would
// reflect valid data being passed to the service function as arguments.
typedef void (*svcSerialOpen)();
typedef void (*svcSerialClose)();
typedef void (*svcSerialRead)();
typedef void (*svcSerialWrite)();

// Service function lookup structure
typedef struct
{
   svcSerialOpen        SerialOpenFP;
   svcSerialClose       SerialCloseFP;
   svcSerialRead        SerialReadFP;
   svcSerialWrite       SerialWriteFP;
}
tServiceLookup;

// Typedefs for the plugin command functions (function pointers)
// In a more meaningful implementation, the signatures here would
// reflect valid data being passed to the command functions as arguments.
typedef void (*pluginInitFunct)( HWND, tServiceLookup* );
typedef void (*pluginFunct)( HWND );

// Plugin Function pointers
pluginInitFunct   PluginInitFP;
pluginFunct       DeviceResetFP;
pluginFunct       DeviceReadDataFP;
pluginFunct       DeviceWriteDataFP;

// Plugin Functions
extern "C" __declspec(dllexport) void plugin_PluginInit(HWND, tServiceLookup*);
extern "C" __declspec(dllexport) void plugin_DeviceReset(HWND);
extern "C" __declspec(dllexport) void plugin_DeviceWriteData(HWND);
extern "C" __declspec(dllexport) void plugin_DeviceReadData(HWND);



#endif // PLUGIN_H

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Tester / Quality Assurance Formerly IGA Worldwide
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions