Patterns in static

Apophenia

settings.h

Go to the documentation of this file.
00001 
00002 /* Copyright (c) 2009 by Ben Klemens.  Licensed under the modified GNU GPL v2; see COPYING and COPYING2.  */
00003 #ifndef __apop_settings_h__
00004 #define __apop_settings_h__
00005 
00006 #include "types.h"
00007 #include "asst.h"
00008 
00009 #ifdef    __cplusplus
00010 extern "C" {
00011 #endif
00012 
00013 void * apop_settings_get_group(apop_model *m, char *type);
00014 void apop_settings_rm_group(apop_model *m, char *delme);
00015 void apop_settings_copy_group(apop_model *outm, apop_model *inm, char *copyme);
00016 void *apop_settings_group_alloc(apop_model *model, char *type, void *free_fn, void *copy_fn, void *the_group);
00017 
00020 #define Apop_settings_get_group(m, type) apop_settings_get_group(m, #type)
00021 
00023 #define Apop_settings_rm_group(m, type) apop_settings_rm_group(m, #type)
00024 
00030 #define Apop_model_add_group(model, type, ...)  \
00031     apop_settings_group_alloc(model, #type, type ## _settings_free, type ## _settings_copy, type ##_settings_init ((type ## _settings) {__VA_ARGS__})); 
00032 
00033 /* A convenience for your settings group init functions. 
00034  Gives the output item either the defaut value if there is one, or the value you specify. */
00035 #define apop_varad_setting(in, out, name, value) (out)->name = (in).name ? (in).name : (value);
00036 
00040 #define Apop_settings_add_group(model, type, ...)  \
00041     apop_settings_group_alloc(model, #type, type ## _settings_free, type ## _settings_copy, type ##_settings_alloc (__VA_ARGS__)); 
00042 
00044 #define Apop_settings_get(model, type, setting)  \
00045     (((type ## _settings *) apop_settings_get_group(model, #type))->setting)
00046 
00048 #define Apop_settings_set(model, type, setting, data)  \
00049     do { type ## _settings *apop_tmp_settings = apop_settings_get_group(model, #type);  \
00050     apop_assert_void(apop_tmp_settings, 0, 's', "You're trying to modify a setting in " \
00051                         #model "'s setting group of type " #type " but that model doesn't have such a group."); \
00052     apop_tmp_settings->setting = (data);    \
00053     } while (0);
00054 /*#define Apop_settings_set(model, type, setting, data)  \
00055     do {                                                \
00056     apop_assert_void(apop_settings_get_group(model, #type), 0, 's', "You're trying to modify a setting in " \
00057                         #model "'s setting group of type " #type " but that model doesn't have such a group."); \
00058     ((type ## _settings *) apop_settings_get_group(model, #type))->setting = (data);    \
00059     } while (0);*/
00060 
00061 #define Apop_settings_add Apop_settings_set
00062 #define APOP_SETTINGS_ADD Apop_settings_set
00063 #define APOP_SETTINGS_GET Apop_settings_get
00064 #define APOP_MODEL_ADD_GROUP Apop_model_add_group
00065 #define APOP_SETTINGS_ADD_GROUP Apop_settings_add_group
00066 #define APOP_SETTINGS_GET_GROUP Apop_settings_get_group
00067 #define APOP_SETTINGS_RM_GROUP Apop_settings_rm_group
00068 
00069 #define Apop_settings_declarations(ysg) \
00070    ysg##_settings * ysg##_settings_init(ysg##_settings); \
00071    void * ysg##_settings_copy(ysg##_settings *); \
00072    void ysg##_settings_free(ysg##_settings *);
00073 
00075 typedef struct {
00076     int destroy_data; 
00077     gsl_vector *weights; 
00078     apop_data *instruments; 
00079     char want_cov; 
00080     char want_expected_value; 
00081 } apop_ls_settings;
00082 
00083 Apop_settings_declarations(apop_ls)
00084 
00085 // Find apop_category_settings routines in apop_probit.c
00092 typedef struct {
00093     apop_data *factors; 
00094     char source_type; 
00095     char source_column; 
00096     apop_data *source_data; 
00097 } apop_category_settings;
00098 
00099 Apop_settings_declarations(apop_category)
00100 apop_category_settings *apop_category_settings_alloc(apop_data *d, int source_column, char source_type);
00101 
00107 typedef struct {
00108     char rank_data;
00109 } apop_rank_settings;
00110 
00111 //in apop_exponential.c
00112 Apop_settings_declarations(apop_rank)
00113 apop_rank_settings *apop_rank_settings_alloc(void *ignoreme);
00114 
00115 #include <gsl/gsl_histogram.h>
00116 typedef struct{
00117     apop_data           *data;
00118     gsl_histogram       *pdf;
00119     gsl_histogram_pdf   *cdf;
00120     apop_model          *histobase;
00121     apop_model          *kernelbase;
00122 } apop_histogram_settings;
00123 
00124 #define apop_kernel_density_settings apop_histogram_settings
00125 
00126 //Apop_settings_declarations(apop_histogram)
00127 void * apop_histogram_settings_copy(apop_histogram_settings *); 
00128 void apop_histogram_settings_free(apop_histogram_settings *);
00129 apop_histogram_settings *apop_histogram_settings_alloc(apop_data *data, int bins);
00130 
00131 
00135 typedef struct{
00136     apop_data *data;
00137     apop_data *starting_pt; 
00138     long int periods; 
00139     double burnin; 
00141     int histosegments; 
00142     char method;
00143 } apop_update_settings;
00144 
00145 apop_update_settings *apop_update_settings_alloc(apop_data *d);
00146 apop_update_settings *apop_update_settings_init(apop_update_settings);
00147 #define apop_update_settings_copy NULL
00148 #define apop_update_settings_free NULL
00149 
00150 apop_histogram_settings *apop_kernel_density_settings_alloc(apop_data *data, 
00151         apop_model *histobase, apop_model *kernelbase, void (*set_params)(double, apop_model*));
00152 
00153 #define apop_kernel_density_settings_copy apop_histogram_settings_copy
00154 #define apop_kernel_density_settings_free apop_histogram_settings_free
00155 
00156 #ifdef    __cplusplus
00157 }
00158 #endif
00159 #endif

SourceForge.net Logo

Autogenerated by doxygen on 28 Sep 2009.