Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:02:04

0001 #ifndef MAD_TABLE_H
0002 #define MAD_TABLE_H
0003 
0004 // types
0005 
0006 struct int_array;
0007 struct char_p_array;
0008 
0009 struct node;
0010 struct in_cmd;
0011 struct sequence;
0012 struct name_list;
0013 struct command_list;
0014 
0015 struct table
0016 {
0017   char name[NAME_L],
0018        type[NAME_L];            /* like "twiss", "survey" etc. */
0019   int  max,                     /* max. # rows */
0020        curr,                    /* current # rows */
0021        num_cols,                /* total # columns - fixed */
0022        org_cols,                /* original # columns from definition */
0023        dynamic,                 /* if != 0, values taken from current row */
0024        origin;                  /* 0 if created in job, 1 if read */
0025   struct char_p_array* header;  /* extra lines for file header */
0026   struct int_array* col_out;    /* column no.s to be written (in this order) */
0027   struct int_array* row_out;    /* flag for row: 1 write, 0 don't */
0028   struct char_p_array* node_nm; /* names of nodes at each row */
0029   struct char_p_array** l_head; /* extra lines to be put in front of a line */
0030   struct node** p_nodes;        /* pointers to nodes at each row */
0031   char*** s_cols;               /* string columns */
0032   double** d_cols;              /* double precision columns */
0033   int stamp;
0034   struct name_list* columns;    /* names + types (in inform):
0035                                    1 double, 3 string */
0036   struct sequence* org_sequ;    /* pointer to sequence it refers to */
0037 };
0038 
0039 struct table_list
0040 {
0041   char name[NAME_L];
0042   int  max,                     /* max. pointer array size */
0043        curr;                    /* current occupation */
0044   struct name_list* names;      /* index list of tables */
0045   struct table** tables;
0046   int stamp;
0047 };
0048 
0049 struct table_list_list
0050 {
0051   char name[NAME_L];
0052   int  max,                     /* max. pointer array size */
0053        curr;                    /* current occupation */
0054   struct table_list** table_lists;
0055   int stamp;
0056 };
0057 
0058 // interface
0059 
0060 struct table*           make_table(const char* name, const char* type, const char* const *table_cols, const int* table_types, int rows);
0061 struct table*           make_table2(char* name, char* type, char** table_cols, int* table_types, int rows);
0062 struct table*           new_table(const char* name, const char* type, int rows, struct name_list* cols);
0063 struct table_list*      new_table_list(int size);
0064 struct table_list_list* new_table_list_list(int size);
0065 struct table*           delete_table(struct table*);
0066 void                    read_table(struct in_cmd*);
0067 struct table*           find_table(const char* name);
0068 
0069 void    check_table(char* string);
0070 void    check_tabindex(char* string);
0071 void    check_tabstring(char* string);
0072 double  table_value(void);
0073 void    table_add_header(struct table*, const char* format, ...);
0074 void    add_to_table_list(struct table*, struct table_list*);
0075 void    add_vars_to_table(struct table*, double scale);
0076 void    set_vars_from_table(struct table*);
0077 void    double_table(char* table);
0078 void    grow_table(struct table*); /* doubles number of rows */
0079 void    print_table(struct table*);
0080 void    make_map_table(int* map_table_max_rows);
0081 int     get_table_range(const char* range, struct table*, int* rows);
0082 void    out_table(const char* tname, struct table*, const char* filename);
0083 void    reset_count(const char* table); /* resets table counter to zero */
0084 void    sector_out(char* sector_table_name, double* pos, double* kick, double* rmatrix, double* tmatrix);
0085 void    table_range(char* table, char* range, int* rows);
0086 
0087 void    rename_table(struct table *tbl, const char *name );
0088 int     remove_table_from_table_list(const char *name, struct table_list* tl);
0089 struct table *detach_table_from_table_list(const char *name, struct table_list* tl);
0090 
0091 void    augment_count(const char* table);
0092 void    augmentcountonly(const char* table);
0093 
0094 //int     str_from_table     (const char* table, const char* name, int* row, char* val);
0095 //int     str_from_tablet    (struct table *tbl, const char* name, int* row, char* val);
0096 //int     nodename_from_table_row(const char* table, /* no name   */ const int* row, char* string);
0097 
0098 int     table_length(const char* table);
0099 int     table_exists(const char* table);
0100 int     table_column_exists(const char* table, const char* name);
0101 int     table_cell_exists(const char* table, const char* name, const int* row);
0102 int     table_header_exists(const char* table, const char *name);
0103 
0104 int     double_from_table_header(const char* table, const char* name, double* val);
0105 
0106 int     double_from_table_row(const char* table, const char* name, const int* row, double* val);
0107 int     string_from_table_row(const char* table, const char* name, const int* row, char* string);
0108 
0109 int     double_to_table_row  (const char* table, const char* name, const int* row, const double* val);
0110 int     string_to_table_row  (const char* table, const char* name, const int* row, const char* string);
0111 
0112 int     double_to_table_curr (const char* table, const char* name, const double* val);
0113 int     double_to_table_curr2(const char* table, const char* name, const double* val);
0114 int     vector_to_table_curr (const char* table, const char* name, const double* vals, const int* nval);
0115 int     string_to_table_curr (const char* table, const char* name, const char* string);
0116 int     comment_to_table_curr(const char* table, const char* comment, const int* length);
0117 int     name_to_table_curr   (const char* table, int *ending);
0118 // double  get_table_value(const char* table_s, const char *row_s, const char *col_s); // not used
0119 // void    set_table_value(const char* table_s, const char *row_s, const char *col_s, double *val); // not used
0120 
0121 struct column_info{
0122   void* data;
0123   int   length;
0124   char  datatype;
0125   char  datasize;
0126 };
0127 
0128 struct column_info   table_get_column(char* table_name,char* column_name);
0129 struct char_p_array *table_get_header(char* table_name);
0130 
0131 #endif // MAD_TABLE_H
0132