1 | /* |
---|
2 | * ---------------------------------------------------------------------- |
---|
3 | * OPTIMIZER PLUG-IN: Pgapack |
---|
4 | * |
---|
5 | * This code connects Pgapack into the Rappture Optimization |
---|
6 | * infrastructure. |
---|
7 | * |
---|
8 | * ====================================================================== |
---|
9 | * AUTHOR: Michael McLennan, Purdue University |
---|
10 | * Copyright (c) 2008 Purdue Research Foundation |
---|
11 | * |
---|
12 | * See the file "license.terms" for information on usage and |
---|
13 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
14 | * ====================================================================== |
---|
15 | */ |
---|
16 | #include "rp_optimizer_plugin.h" |
---|
17 | |
---|
18 | typedef struct PgapackData { |
---|
19 | int foo; /* data used by Pgapack... */ |
---|
20 | } PgapackData; |
---|
21 | |
---|
22 | RpTclOption PgapackOptions[] = { |
---|
23 | {"-foo", RP_OPTION_INT, NULL, Rp_Offset(PgapackData,foo)}, |
---|
24 | {NULL, NULL, NULL, 0} |
---|
25 | }; |
---|
26 | |
---|
27 | /* |
---|
28 | * ---------------------------------------------------------------------- |
---|
29 | * PgapackInit() |
---|
30 | * |
---|
31 | * This routine is called whenever a new optimization object is created |
---|
32 | * to initialize Pgapack. Returns a pointer to PgapackData that is |
---|
33 | * used in later routines. |
---|
34 | * ---------------------------------------------------------------------- |
---|
35 | */ |
---|
36 | ClientData |
---|
37 | PgapackInit() |
---|
38 | { |
---|
39 | PgapackData *dataPtr; |
---|
40 | dataPtr = (PgapackData*)malloc(sizeof(PgapackData)); |
---|
41 | dataPtr->foo = 1; |
---|
42 | return (ClientData)dataPtr; |
---|
43 | } |
---|
44 | |
---|
45 | /* |
---|
46 | * ---------------------------------------------------------------------- |
---|
47 | * PgapackCleanup() |
---|
48 | * |
---|
49 | * This routine is called whenever an optimization object is deleted |
---|
50 | * to clean up data associated with the object. Frees the data |
---|
51 | * allocated in PgapackInit. |
---|
52 | * ---------------------------------------------------------------------- |
---|
53 | */ |
---|
54 | void |
---|
55 | PgapackCleanup(cdata) |
---|
56 | ClientData cdata; /* data from to be cleaned up */ |
---|
57 | { |
---|
58 | PgapackData *dataPtr = (PgapackData*)cdata; |
---|
59 | dataPtr->foo = 0; |
---|
60 | free(dataPtr); |
---|
61 | } |
---|