1 /* 2 * gretl -- Gnu Regression, Econometrics and Time-series Library 3 * Copyright (C) 2001 Allin Cottrell and Riccardo "Jack" Lucchetti 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 20 #ifndef OBJSTACK_H 21 #define OBJSTACK_H 22 23 /* Note: the following enumeration may be added to, but the 24 existing entries up to GRETL_OBJ_SCALARS must not be 25 moved. 26 */ 27 28 typedef enum { 29 GRETL_OBJ_NULL, 30 GRETL_OBJ_EQN, 31 GRETL_OBJ_SYS, 32 GRETL_OBJ_VAR, 33 GRETL_OBJ_DSET, 34 GRETL_OBJ_INFO, 35 GRETL_OBJ_STATS, 36 GRETL_OBJ_CORR, 37 GRETL_OBJ_SCRIPT, 38 GRETL_OBJ_NOTES, 39 GRETL_OBJ_MODTAB, 40 GRETL_OBJ_GPAGE, 41 GRETL_OBJ_GRAPH, 42 GRETL_OBJ_PLOT, 43 GRETL_OBJ_TEXT, 44 GRETL_OBJ_MATRIX, 45 GRETL_OBJ_SCALARS, 46 GRETL_OBJ_BUNDLE, 47 GRETL_OBJ_ANY, 48 GRETL_OBJ_MAX 49 } GretlObjType; 50 51 typedef enum { 52 IN_GUI_SESSION = 1 << 0, 53 IN_NAMED_STACK = 1 << 1, 54 IN_MODEL_TABLE = 1 << 2, 55 IS_LAST_MODEL = 1 << 3, 56 IN_GRAPH_PAGE = 1 << 4 57 } SavedObjectFlags; 58 59 enum { 60 OBJ_ACTION_NONE, 61 OBJ_ACTION_INVALID, 62 OBJ_ACTION_NULL, 63 OBJ_ACTION_SHOW, 64 OBJ_ACTION_FREE 65 }; 66 67 void set_as_last_model (void *ptr, GretlObjType type); 68 69 int gretl_model_protect (MODEL *pmod); 70 71 int gretl_model_unprotect (MODEL *pmod); 72 73 void *get_last_model (GretlObjType *type); 74 75 GretlObjType get_last_model_type (void); 76 77 void *get_genr_model (GretlObjType *type); 78 79 int get_genr_model_ID (void); 80 81 MODEL *get_model_by_name (const char *mname); 82 83 MODEL *get_model_by_ID (int ID); 84 85 GRETL_VAR *get_VAR_by_name (const char *vname); 86 87 GRETL_VAR *get_VECM_by_name (const char *vname); 88 89 equation_system *get_equation_system_by_name (const char *sname); 90 91 void *gretl_get_object_by_name (const char *name); 92 93 void *get_model_object_and_type (const char *name, 94 GretlObjType *type); 95 96 void *gretl_get_object_and_type (const char *name, 97 GretlObjType *type); 98 99 GretlType saved_object_get_data_type (const char *name, 100 ModelDataIndex idx); 101 102 int object_is_on_stack (const void *ptr); 103 104 int gretl_stack_object (void *ptr, GretlObjType type); 105 106 int gretl_stack_object_as (void *ptr, GretlObjType type, const char *name); 107 108 void gretl_object_remove_from_stack (void *ptr, GretlObjType type); 109 110 void remove_model_from_stack_on_exit (MODEL *pmod); 111 112 MODEL *maybe_stack_model (MODEL *pmod, CMD *cmd, PRN *prn, int *err); 113 114 int maybe_stack_var (GRETL_VAR *var, CMD *cmd); 115 116 void gretl_object_ref (void *ptr, GretlObjType type); 117 118 void gretl_object_unref (void *ptr, GretlObjType type); 119 120 double saved_object_get_scalar (const char *oname, int idx, 121 DATASET *dset, int *err); 122 123 int saved_object_print_scalar (const char *oname, const char *key, PRN *prn); 124 125 int saved_object_get_series (double *x, const char *oname, 126 int idx, const DATASET *dset); 127 128 gretl_matrix * 129 saved_object_get_matrix (const char *oname, int idx, int *err); 130 131 gretl_matrix * 132 saved_object_build_matrix (const char *oname, int idx, 133 const DATASET *dset, int *err); 134 135 gretl_matrix * 136 last_model_get_irf_matrix (int targ, int shock, double alpha, 137 const DATASET *dset, int *err); 138 139 void *saved_object_get_array (const char *oname, int idx, 140 const DATASET *dset, 141 int *err); 142 143 gretl_matrix *last_model_get_boot_ci (int cnum, const DATASET *dset, 144 int B, double alpha, 145 int method, int studentize, 146 int *err); 147 148 double last_model_get_boot_pval (int cnum, 149 const DATASET *dset, 150 int B, int method, 151 int *err); 152 153 void *last_model_get_data (const char *key, GretlType *type, 154 int *size, int *copied, int *err); 155 156 char *last_model_get_vcv_type (void); 157 158 int *saved_object_get_list (const char *oname, int idx, int *err); 159 160 char *saved_object_get_string (const char *oname, int idx, 161 const DATASET *dset, int *err); 162 163 int gretl_object_rename (void *p, GretlObjType type, const char *oname); 164 165 int gretl_object_compose_name (void *p, GretlObjType type); 166 167 int gretl_object_compose_unique_name (void *p, GretlObjType type); 168 169 char *gretl_object_get_name (void *p, GretlObjType type); 170 171 int parse_object_command (const char *s, char *name, char **cmd); 172 173 int match_object_command (const char *s); 174 175 int last_model_test_ok (int ci, gretlopt opt, const DATASET *dset, 176 PRN *prn); 177 178 int last_model_test_uhat (DATASET *dset, gretlopt opt, PRN *prn); 179 180 void set_genr_model (void *ptr, GretlObjType type); 181 182 void unset_genr_model (void); 183 184 int highest_numbered_var_in_saved_object (const DATASET *dset); 185 186 int check_variable_deletion_list (int *list, const DATASET *dset); 187 188 int check_models_for_subsample (char *newmask, int *ndropped); 189 190 int n_stacked_models (void); 191 192 void set_gui_model_list_callback (GList *(*callback)()); 193 194 void gretl_saved_objects_cleanup (void); 195 196 #endif 197 198