EPICS Base
7.0.6.1
|
Channel filter simplified plugins. More...
Go to the source code of this file.
Classes | |
struct | chfPluginIf |
Channel filter simplified plugin interface. More... | |
struct | chfPluginEnumType |
struct | chfPluginArgDef |
Enumerations | |
enum | chfPluginArg { chfPluginArgInvalid =0, chfPluginArgBoolean, chfPluginArgInt32, chfPluginArgDouble, chfPluginArgString, chfPluginArgEnum } |
Functions | |
DBCORE_API const char * | chfPluginEnumString (const chfPluginEnumType *Enums, int i, const char *def) |
Return the string associated with Enum index 'i'. More... | |
DBCORE_API int | chfPluginRegister (const char *key, const chfPluginIf *pif, const chfPluginArgDef *opts) |
Register a plugin. More... | |
Utility layer to allow an easier (reduced) interface for channel filter plugins.
Parsing the configuration arguments of a channel filter plugin is done according to an argument description table provided by the plugin. The parser stores the results directly into a user supplied structure after appropriate type conversion.
To specify the arguments, a chfPluginArgDef table must be defined for the user structure. This table has to be specified when the plugin registers.
The plugin is responsible to register an init function using epicsExportRegistrar() and the accompanying registrar() directive in the dbd, and call chfPluginRegister() from within the init function.
For example:
typedef struct myStruct { ... other stuff char mode; epicsInt32 ival; double dval; epicsInt32 ival2; int enumval; char strval[20]; char boolval; } myStruct;
static const chfPluginEnumType colorEnum[] = { {"Red",1}, {"Green",2}, {"Blue",3}, {NULL,0} };
static const chfPluginDef myStructDef[] = { chfTagInt32(myStruct, ival, "Integer" , ival2, 3, 0, 0), chfInt32 (myStruct, ival2, "Second" , 1, 0), chfDouble (myStruct, dval, "Double" , 1, 0), chfString (myStruct, strval , "String" , 1, 0), chfEnum (myStruct, enumval, "Color" , 1, 0, colorEnum), chfBoolean (myStruct, boolval, "Bool" , 1, 0), chfPluginEnd };
Note: The 4th argument specifies the parameter to be required (1) or optional (0), the 5th whether converting to the required type is allowed (1), or type mismatches are an error (0). Note: The "Tag" version has two additional arguments. the 4th arg specifies the tag field (integer type) inside the structure to be set, the 5th arg specifies the value to set the tag field to. Arguments 6 and 7 specify "required" and "conversion" as described above.
Definition in file chfPlugin.h.
#define chfInt32 | ( | Struct, | |
Member, | |||
Name, | |||
Req, | |||
Conv | |||
) |
Definition at line 251 of file chfPlugin.h.
#define chfBoolean | ( | Struct, | |
Member, | |||
Name, | |||
Req, | |||
Conv | |||
) |
Definition at line 255 of file chfPlugin.h.
#define chfDouble | ( | Struct, | |
Member, | |||
Name, | |||
Req, | |||
Conv | |||
) |
Definition at line 259 of file chfPlugin.h.
#define chfString | ( | Struct, | |
Member, | |||
Name, | |||
Req, | |||
Conv | |||
) |
Definition at line 263 of file chfPlugin.h.
#define chfEnum | ( | Struct, | |
Member, | |||
Name, | |||
Req, | |||
Conv, | |||
Enums | |||
) |
Definition at line 267 of file chfPlugin.h.
#define chfTagInt32 | ( | Struct, | |
Member, | |||
Name, | |||
Tag, | |||
Choice, | |||
Req, | |||
Conv | |||
) |
Definition at line 273 of file chfPlugin.h.
#define chfTagBoolean | ( | Struct, | |
Member, | |||
Name, | |||
Tag, | |||
Choice, | |||
Req, | |||
Conv | |||
) |
Definition at line 277 of file chfPlugin.h.
#define chfTagDouble | ( | Struct, | |
Member, | |||
Name, | |||
Tag, | |||
Choice, | |||
Req, | |||
Conv | |||
) |
Definition at line 281 of file chfPlugin.h.
#define chfTagString | ( | Struct, | |
Member, | |||
Name, | |||
Tag, | |||
Choice, | |||
Req, | |||
Conv | |||
) |
Definition at line 285 of file chfPlugin.h.
#define chfTagEnum | ( | Struct, | |
Member, | |||
Name, | |||
Tag, | |||
Choice, | |||
Req, | |||
Conv, | |||
Enums | |||
) |
Definition at line 289 of file chfPlugin.h.
DBCORE_API const char* chfPluginEnumString | ( | const chfPluginEnumType * | Enums, |
int | i, | ||
const char * | def | ||
) |
Enums | A null-terminated array of string/integer pairs. |
i | An Enum index. |
def | String to be returned when 'i' isn't a valid Enum index. |
DBCORE_API int chfPluginRegister | ( | const char * | key, |
const chfPluginIf * | pif, | ||
const chfPluginArgDef * | opts | ||
) |
key | The plugin name key that clients will use. |
pif | Pointer to the plugin's interface. |
opts | Pointer to the configuration argument description table. |