grasp_settings.h
Go to the documentation of this file.
1 /*
2  * Copyright 2016 CNRS & Universite Lille 1. All rights reserved.
3  *
4  * Licensed under the GRASP Open Source License V1.0 (see LICENSE file)
5  */
6 
17 #ifndef _GRASP_SETTINGS_H
18 #define _GRASP_SETTINGS_H
19 
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 #include <stdbool.h>
26 #include "yamlsettings/yamlsettings_dictionary.h"
27 #include "mod_par_OS.inc"
28 #include "mod_par_inv.inc"
29 #include "../retrieval/constants_set/mod_globals.inc"
30 #include "../input/grasp_input_settings.h"
31 #include "../controller/grasp_controller_settings.h"
32 #include "../output/grasp_output_settings.h"
33 #include "../settings/grasp_products.h"
34 #include "../global/grasp_parameters.h"
35 
36 #ifndef RESOURCES_PREFIX
37 #define RESOURCES_PREFIX "/usr/local/grasp-resources/"
38 #endif
39 
40 #include "grasp_settings_t.h"
41 #include "../output/grasp_output_stream_t.h"
42 
45  yamlsettings_parameter *parameters;
47 
48 // Return a dictionary assig
49 yamlsettings_dictionary_t *grasp_settings_dictionary_get(grasp_settings *settings);
50 
51 
52 // Function that read Retrieval INput structure (RIN) from a Yaml file. Arguments:
53 // grasp_settings **settings pointer to settings that it will be allocated and returned
54 // inputFile filename of input YML configuration
55 // Return -1 if file can't be open or is a malformed YAML
56 // Return -2 if Reached maximum of imported files. This can occur with a recursive importation
57 // Return 0 if everything is ok
58 // Return a number greater than 0 thats means the number of errors when data is validated
59 // nparameter is the number of extra parameters
60 // parameters is an array of parameters in string format (example: retrieval.number_wavelengths=3)
61 int grasp_settings_read(grasp_output_stream *controller_stream, yamlsettings_dictionary_t **dictionary, int nparameters, char const *parameters[], yamlsettings_parser_settings_file_mode settings_file_mode);
62 
63 // Return an array of parameter allocated
65 
66 // Deallocate current x parameter array
68 
69 // This function will print help information (parameter name + description) in a defined stream
71 
72 // Free memory from settings
74 
75 // Function which is called after process settings. This function will call other functions in order to set properly all settings structure
76 void grasp_settings_postprocess_function(yamlsettings_dictionary_t *dictionary);
77 
78 int grasp_settings_to_yaml_string(char content[], grasp_settings *settings, bool print_defaults, bool force_arrays);
79 
80 int grasp_settings_description_json(char *json, int json_length);
81 
82 int grasp_settings_dump(char *stream_pattern, grasp_settings *settings, bool print_defaults, bool force_arrays);
83 
84 // Total number of wavelenght is a parameter calculated inside retrieval code but
85 // for some actions it is needed to have it before (validators, assigments, post-processing, ...)
86 // this function implement an algorithm to deduct the value of nwl at dictionary level.
87 int grasp_settings_deduct_nwl(yamlsettings_dictionary_t *dictionary);
88 
89 // Returns an allocated string with the list (delimited by ';') of all parameters
90 // that are paths. Example: global.resources;retrieval.general.path_to_internal_files;...;
92 
93 // Return the content of a file like a simple string. It fails for files >4Gb (it is not a limitation for settings files ;-) )
94 // It returned an allocated string that has to be free
95 char *grasp_settings_to_string(const char *filename);
96 
97 #ifdef __cplusplus
98 }
99 #endif
100 
101 #endif /*_GRASP_SETTINGS_H */
Definition: grasp_output_stream_t.h:24
void grasp_settings_destroy(grasp_settings *settings)
Definition: grasp_settings.c:697
struct grasp_settings_parameter_array_ grasp_settings_parameter_array
int nparameters
Definition: grasp_settings.h:44
int grasp_settings_deduct_nwl(yamlsettings_dictionary_t *dictionary)
Definition: grasp_settings.c:770
char * grasp_settings_to_string(const char *filename)
Definition: grasp_settings.c:678
char * grasp_settings_list_paths()
Definition: grasp_settings.c:634
int grasp_settings_to_yaml_string(char content[], grasp_settings *settings, bool print_defaults, bool force_arrays)
Definition: grasp_settings.c:428
grasp_settings_parameter_array * grasp_settings_parameter_array_allocate(int nelements)
Definition: grasp_settings.c:701
yamlsettings_parameter * parameters
Definition: grasp_settings.h:45
yamlsettings_dictionary_t * grasp_settings_dictionary_get(grasp_settings *settings)
Definition: grasp_settings.c:38
int grasp_settings_dump(char *stream_pattern, grasp_settings *settings, bool print_defaults, bool force_arrays)
Definition: grasp_settings.c:476
Definition: grasp_settings.h:43
void grasp_settings_parameter_array_destroy(grasp_settings_parameter_array *x)
Definition: grasp_settings.c:716
void grasp_settings_postprocess_function(yamlsettings_dictionary_t *dictionary)
Definition: grasp_settings.c:417
int grasp_settings_description_json(char *json, int json_length)
Definition: grasp_settings.c:449
void grasp_settings_help(grasp_output_stream *controller_stream, const char *filter)
Definition: grasp_settings.c:614
grasp_output_stream controller_stream
Definition: grasp_controller.c:30
Definition: grasp_settings_t.h:409
int grasp_settings_read(grasp_output_stream *controller_stream, yamlsettings_dictionary_t **dictionary, int nparameters, char const *parameters[], yamlsettings_parser_settings_file_mode settings_file_mode)
Definition: grasp_settings.c:513