source: trunk/packages/optimizer/src/rp_tcloptions.h @ 1062

Last change on this file since 1062 was 898, checked in by mmc, 16 years ago

Optimization part is getting better. Fleshed out the plug-in for
PGApack, and integrated a first cut that includes the data handling.

File size: 3.0 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    int offset;                /* location of data within struct */
52} RpTclOption;
53
54/*
55 *  Built-in types defined in rp_tcloptions.c
56 */
57extern RpTclOptionType RpOption_Boolean;
58#define RP_OPTION_BOOLEAN &RpOption_Boolean
59
60extern RpTclOptionType RpOption_Int;
61#define RP_OPTION_INT &RpOption_Int
62
63extern RpTclOptionType RpOption_Double;
64#define RP_OPTION_DOUBLE &RpOption_Double
65
66extern RpTclOptionType RpOption_String;
67#define RP_OPTION_STRING &RpOption_String
68
69extern RpTclOptionType RpOption_List;
70#define RP_OPTION_LIST &RpOption_List
71
72extern RpTclOptionType RpOption_Choices;
73#define RP_OPTION_CHOICES &RpOption_Choices
74
75/*
76 *  Here are the functions in the API:
77 */
78EXTERN int RpTclOptionsProcess _ANSI_ARGS_((Tcl_Interp *interp,
79    int objc, Tcl_Obj *CONST objv[], RpTclOption *options,
80    ClientData cdata));
81
82EXTERN int RpTclOptionGet _ANSI_ARGS_((Tcl_Interp *interp,
83    RpTclOption *options, ClientData cdata, char *desiredOpt));
84
85EXTERN void RpTclOptionsCleanup _ANSI_ARGS_((RpTclOption *options,
86    ClientData cdata));
87
88#endif
Note: See TracBrowser for help on using the repository browser.