source: trunk/optimizer/src/rp_tcloptions.h @ 897

Last change on this file since 897 was 897, checked in by mmc, 15 years ago

Improved the Rappture optimization API to include Tcl bindings.
Added standard build/test stuff for Tcl libraries. Created a
plugin hook for optimization libraries like pgapack. The plugin
support still needs some work.

File size: 2.9 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  rp_tcloptions
4 *
5 *  This library is used to implement configuration options for the
6 *  Tcl API used in Rappture.  It lets you define a series of
7 *  configuration options like the ones used for Tk widgets, and
8 *  provides functions to process them.
9 *
10 * ======================================================================
11 *  AUTHOR:  Michael McLennan, Purdue University
12 *  Copyright (c) 2008  Purdue Research Foundation
13 *
14 *  See the file "license.terms" for information on usage and
15 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
16 * ======================================================================
17 */
18#ifndef RP_TCLOPTIONS
19#define RP_TCLOPTIONS
20
21#include <tcl.h>
22
23/*
24 * These data structures are used to define configuration options
25 * associated with parameters and optimizer cores.  They work just
26 * like Tk widget options, but for objects that are not widgets.
27 */
28#ifdef offsetof
29#define Rp_Offset(type, field) ((int) offsetof(type, field))
30#else
31#define Rp_Offset(type, field) ((int) ((char *) &((type *) 0)->field))
32#endif
33
34typedef int (RpCustomTclOptionParse)_ANSI_ARGS_((Tcl_Interp *interp,
35    Tcl_Obj *valObj, ClientData cdata, int offset));
36typedef int (RpCustomTclOptionGet)_ANSI_ARGS_((Tcl_Interp *interp,
37    ClientData cdata, int offset));
38typedef void (RpCustomTclOptionCleanup)_ANSI_ARGS_((ClientData cdata,
39    int offset));
40
41typedef struct RpTclOptionType {
42    char *type;                            /* name describing this type */
43    RpCustomTclOptionParse *parseProc;     /* procedure to parse new values */
44    RpCustomTclOptionGet *getProc;         /* procedure to report cur value */
45    RpCustomTclOptionCleanup *cleanupProc; /* procedure to free up value */
46} RpTclOptionType;
47
48typedef struct RpTclOption {
49    char *optname;             /* name of option: -switch */
50    RpTclOptionType *typePtr;  /* type of this switch */
51    ClientData extraInfo;      /* extra data needed for switch type */
52    int offset;                /* location of data within struct */
53} RpTclOption;
54
55/*
56 *  Built-in types defined in rp_tcloptions.c
57 */
58extern RpTclOptionType RpOption_Int;
59#define RP_OPTION_INT &RpOption_Int
60
61extern RpTclOptionType RpOption_Double;
62#define RP_OPTION_DOUBLE &RpOption_Double
63
64extern RpTclOptionType RpOption_String;
65#define RP_OPTION_STRING &RpOption_String
66
67extern RpTclOptionType RpOption_List;
68#define RP_OPTION_LIST &RpOption_List
69
70/*
71 *  Here are the functions in the API:
72 */
73EXTERN int RpTclOptionsProcess _ANSI_ARGS_((Tcl_Interp *interp,
74    int objc, Tcl_Obj *CONST objv[], RpTclOption *options,
75    ClientData cdata));
76
77EXTERN int RpTclOptionGet _ANSI_ARGS_((Tcl_Interp *interp,
78    RpTclOption *options, ClientData cdata, char *desiredOpt));
79
80EXTERN void RpTclOptionsCleanup _ANSI_ARGS_((RpTclOption *options,
81    ClientData cdata));
82
83#endif
Note: See TracBrowser for help on using the repository browser.