source: PSPA/madxPSPA/src/mad_table.h @ 478

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

import madx-5.01.00

File size: 4.8 KB
Line 
1#ifndef MAD_TABLE_H
2#define MAD_TABLE_H
3
4// types
5
6struct int_array;
7struct char_p_array;
8
9struct node;
10struct in_cmd;
11struct sequence;
12struct name_list;
13struct command_list;
14
15struct table
16{
17  char name[NAME_L],
18       type[NAME_L];            /* like "twiss", "survey" etc. */
19  int  max,                     /* max. # rows */
20       curr,                    /* current # rows */
21       num_cols,                /* total # columns - fixed */
22       org_cols,                /* original # columns from definition */
23       dynamic,                 /* if != 0, values taken from current row */
24       origin;                  /* 0 if created in job, 1 if read */
25  struct char_p_array* header;  /* extra lines for file header */
26  struct int_array* col_out;    /* column no.s to be written (in this order) */
27  struct int_array* row_out;    /* flag for row: 1 write, 0 don't */
28  struct char_p_array* node_nm; /* names of nodes at each row */
29  struct char_p_array** l_head; /* extra lines to be put in front of a line */
30  struct node** p_nodes;        /* pointers to nodes at each row */
31  char*** s_cols;               /* string columns */
32  double** d_cols;              /* double precision columns */
33  int stamp;
34  struct name_list* columns;    /* names + types (in inform):
35                                   1 double, 3 string */
36  struct sequence* org_sequ;    /* pointer to sequence it refers to */
37};
38
39struct table_list
40{
41  char name[NAME_L];
42  int  max,                     /* max. pointer array size */
43       curr;                    /* current occupation */
44  struct name_list* names;      /* index list of tables */
45  struct table** tables;
46  int stamp;
47};
48
49struct table_list_list
50{
51  char name[NAME_L];
52  int  max,                     /* max. pointer array size */
53       curr;                    /* current occupation */
54  struct table_list** table_lists;
55  int stamp;
56};
57
58// interface
59
60struct table*           make_table(char* name, char* type, char** table_cols, int* table_types, int rows);
61struct table*           new_table(char* name, char* type, int rows, struct name_list* cols);
62struct table_list*      new_table_list(int size);
63struct table_list_list* new_table_list_list(int size);
64struct table*           delete_table(struct table*);
65struct table*           read_table(struct in_cmd*);
66struct table*           read_my_table(struct in_cmd*);
67
68void    check_table(char* string);
69void    check_tabstring(char* string);
70double  table_value(void);
71void    add_to_table_list(struct table*, struct table_list*);
72void    add_vars_to_table(struct table*);
73void    set_vars_from_table(struct table*);
74void    double_table(char* table);
75void    grow_table(struct table*); /* doubles number of rows */
76void    print_table(struct table*);
77void    make_map_table(int* map_table_max_rows);
78int     get_table_range(char* range, struct table*, int* rows);
79void    out_table(char* tname, struct table*, char* filename);
80void    reset_count(char* table); /* resets table counter to zero */
81void    sector_out(char* sector_table_name, double* pos, double* kick, double* rmatrix, double* tmatrix);
82void    table_range(char* table, char* range, int* rows);
83
84void    augment_count(char* table);
85void    augmentcountonly(char* table);
86
87//int     str_from_table     (const char* table, const char* name, int* row, char* val);
88//int     str_from_tablet    (struct table *tbl, const char* name, int* row, char* val);
89//int     nodename_from_table_row(const char* table, /* no name   */ const int* row, char* string);
90
91int     table_length(const char* table);
92int     table_exists(const char* table);
93int     table_column_exists(const char* table, const char* name);
94int     table_header_exists(const char* table, const char *name);
95
96int     double_from_table_header(const char* table, const char* name, double* val);
97
98int     double_from_table_row(const char* table, const char* name, const int* row, double* val);
99int     string_from_table_row(const char* table, const char* name, const int* row, char* string);
100
101int     double_to_table_row  (const char* table, const char* name, const int* row, const double* val);
102int     string_to_table_row  (const char* table, const char* name, const int* row, const char* string);
103
104int     double_to_table_curr (const char* table, const char* name, const double* val);
105int     vector_to_table_curr (const char* table, const char* name, const double* vals, const int* nval);
106int     string_to_table_curr (const char* table, const char* name, const char* string);
107int     comment_to_table_curr(const char* table, const char* comment, const int* length);
108
109double  get_table_value(const char* table_s, const char *row_s, const char *col_s);
110void    set_table_value(const char* table_s, const char *row_s, const char *col_s, double *val);
111
112struct column_info{
113  void* data;
114  int length;
115  char datatype;
116  char datasize;
117};
118
119struct column_info  table_get_column(char* table_name,char* column_name);
120
121#endif // MAD_TABLE_H
122
Note: See TracBrowser for help on using the repository browser.