1 | #ifndef CONTEXT_H |
---|
2 | #define CONTEXT_H |
---|
3 | |
---|
4 | /* |
---|
5 | o---------------------------------------------------------------------o |
---|
6 | | |
---|
7 | | Numdiff |
---|
8 | | |
---|
9 | | Copyright (c) 2012+ laurent.deniau@cern.ch |
---|
10 | | Gnu General Public License |
---|
11 | | |
---|
12 | o---------------------------------------------------------------------o |
---|
13 | |
---|
14 | Purpose: |
---|
15 | manage contexts of constraints |
---|
16 | print, scan contexts from file |
---|
17 | |
---|
18 | o---------------------------------------------------------------------o |
---|
19 | */ |
---|
20 | |
---|
21 | #include <stdio.h> |
---|
22 | #include "types.h" |
---|
23 | |
---|
24 | // ----- types |
---|
25 | |
---|
26 | struct utest; |
---|
27 | struct context; |
---|
28 | struct constraint; |
---|
29 | |
---|
30 | // ----- interface |
---|
31 | |
---|
32 | #define T struct context |
---|
33 | #define C struct constraint |
---|
34 | |
---|
35 | T* context_alloc (int n_); |
---|
36 | void context_clear (T*); // reset + erase constraints |
---|
37 | void context_free (T*); |
---|
38 | |
---|
39 | // populate with constraints, invoke grow on need |
---|
40 | T* context_add (T*, const C*); |
---|
41 | |
---|
42 | // return 0 if no constraint are found, getInc requires increasing (row,col) |
---|
43 | const C* context_getAt (T*, int row, int col); |
---|
44 | const C* context_getInc (T*, int row, int col); |
---|
45 | |
---|
46 | // return the contraint at the index |
---|
47 | const C* context_getIdx (const T*, int idx); |
---|
48 | // return the index of the contraint |
---|
49 | int context_findIdx (const T*, const C*); // -1 for invalid constraint |
---|
50 | // return the line of the contraint |
---|
51 | int context_findLine(const T*, const C*); // -1 for invalid constraint |
---|
52 | |
---|
53 | // input/output context of (registered) constraints |
---|
54 | T* context_scan ( T*, FILE *fp); |
---|
55 | void context_print(const T*, FILE *fp); // for debug |
---|
56 | |
---|
57 | #undef T |
---|
58 | #undef C |
---|
59 | |
---|
60 | // ----- testsuite |
---|
61 | |
---|
62 | #ifndef NTEST |
---|
63 | |
---|
64 | void context_utest (struct utest*); |
---|
65 | |
---|
66 | #endif // NTEST |
---|
67 | #endif |
---|