source: PSPA/madxPSPA/tools/numdiff/src/context.h @ 430

Last change on this file since 430 was 430, checked in by touze, 11 years ago

import madx-5.01.00

File size: 1.6 KB
Line 
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
26struct utest;
27struct context;
28struct constraint;
29
30// ----- interface
31
32#define T struct context
33#define C struct constraint
34
35T*       context_alloc  (int n_);
36void     context_clear  (T*); // reset + erase constraints
37void     context_free   (T*);
38
39// populate with constraints, invoke grow on need
40T*       context_add     (T*, const C*);
41
42// return 0 if no constraint are found, getInc requires increasing (row,col)
43const C* context_getAt   (T*, int row, int col);
44const C* context_getInc  (T*, int row, int col);
45
46// return the contraint at the index
47const C* context_getIdx  (const T*, int idx);
48// return the index of the contraint
49int      context_findIdx (const T*, const C*); // -1 for invalid constraint
50// return the line of the contraint
51int      context_findLine(const T*, const C*); // -1 for invalid constraint
52
53// input/output context of (registered) constraints
54T*       context_scan (      T*, FILE *fp);
55void     context_print(const T*, FILE *fp); // for debug
56
57#undef T
58#undef C
59
60// ----- testsuite
61
62#ifndef NTEST
63
64void context_utest (struct utest*);
65
66#endif // NTEST
67#endif
Note: See TracBrowser for help on using the repository browser.