OSFI-C++  3.10.0
OpenSF Integration Library
ConFM.h
Go to the documentation of this file.
1 /*
2  * openSF Integration Libraries (OSFI)
3  * Deimos Space, S.L.U.
4  *
5  * This file is part of OSFI. OSFI is free software; you can redistribute it
6  * and/or modify it under the terms of the 'ESA Software Community Licence Permissive' as
7  * published by the European Space Agency; either version 2.4 of the License,
8  * or (at your option) any later version. You should have received a
9  * copy of the 'ESA Software Community Licence Permissive - v2.4' along with this program
10  * or one can be found at <http://eop-cfi.esa.int/index.php/docs-and-mission-data/licensing-documents>.
11  */
12 
23 #ifndef OSFI_FFI_CONFM_H
24 #define OSFI_FFI_CONFM_H
25 
26 #include "ffi_base.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 // TODO: documentation! especially pre- and post- conditions, and what happens in
32 // case of a C++ exception.
33 
59 OSFI_FFI_DEPRECATED("Use the create_noval constructor instead and then call validate.")
60 OSFI_ParamReader* osfi_param_reader_create(const char* fileName, const char* schema);
66 
75 };
79 enum osfi_ffi_confm_val_res osfi_param_reader_valagainst(const OSFI_ParamReader* obj, const char* xsdFile);
80 
84 bool osfi_confm_exist_parameter(const OSFI_ParamReader* obj, const char *paramName);
87 const OSFI_Parameter* osfi_confm_get_param(const OSFI_ParamReader* obj, const char *paramName);
88 // Nonexisting, because Parameter instances are held by ParamReader
89 // void osfi_parameter_destroy(OSFI_Parameter** obj);
90 
101 };
102 
103 #define OSFI_DECL_SCALAR_GETTER_simple(Tname, Ttype) \
104  \
105  bool osfi_confm_get_scalar_##Tname(const OSFI_Parameter* obj, Ttype* value)
106 #define OSFI_DECL_SCALAR_GETTER_str(Tname, Ttype) \
107  \
108  int osfi_confm_get_scalar_##Tname(const OSFI_Parameter* obj, Ttype buf, int bufSz)
109 
110 // Declare getter functions: this macro declares the vector type, the available operations on it and
111 // the functions that get vector objects from a parameter object. Also, declare the scalar getter.
112 #define OSFI_DECL_GETTERS(Tname, Ttype, kind) \
113  OSFI_DECL_SCALAR_GETTER_ ## kind(Tname, Ttype); \
114  OSFI_DECL_VECTOR(Tname, Ttype, kind); \
115  \
116  OSFI_VEC_T(Tname) * osfi_confm_get_vector_##Tname##_vals(const OSFI_Parameter* obj, int* size); \
117  \
118  OSFI_VEC_T(Tname) * osfi_confm_get_leaf_vector_##Tname##_vals(const OSFI_Parameter* obj, const int node[], int depth, int* size); \
119  \
121  OSFI_VEC_T(Tname) * osfi_confm_get_matrix_##Tname##_vals(const OSFI_Parameter* obj, enum osfi_confm_arrayorder aeo, int* size);
122 
123 OSFI_DECL_GETTERS(boolean, bool, simple);
124 OSFI_DECL_GETTERS(integer, int, simple);
125 OSFI_DECL_GETTERS(double, double, simple);
126 OSFI_DECL_GETTERS(time, OSFI_TimeValue, simple);
127 OSFI_DECL_GETTERS(file, char*, str); // NOTE: this could use the same type as OSFI_Vec_Tstring
128 OSFI_DECL_GETTERS(string, char*, str);
129 
131 OSFI_VEC_T(boolean) * osfi_confm_file_exist(const OSFI_Parameter* p, enum osfi_confm_arrayorder aeo, int *size);
132 
133 // Parameter information
135 int osfi_param_get_local_name(const OSFI_Parameter* obj, char* buf, int bufSz);
137 int osfi_param_get_path(const OSFI_Parameter* obj, char* buf, int bufSz);
139 int osfi_param_get_description(const OSFI_Parameter* obj, char* buf, int bufSz);
141 int osfi_param_get_min_value(const OSFI_Parameter* obj, char* buf, int bufSz);
143 int osfi_param_get_max_value(const OSFI_Parameter* obj, char* buf, int bufSz);
145 int osfi_param_get_units(const OSFI_Parameter* obj, char* buf, int bufSz);
147 int osfi_param_get_raw_value(const OSFI_Parameter* obj, char* buf, int bufSz);
148 
151 enum OSFI_ParamElemType {
152  OSFI_PET_INTEGER = 1,
153  OSFI_PET_FLOAT,
154  OSFI_PET_BOOLEAN,
155  OSFI_PET_STRING,
156  OSFI_PET_FILE,
157  OSFI_PET_FOLDER,
158  OSFI_PET_TIME,
159 };
162 
164 bool osfi_param_is_array(const OSFI_Parameter* obj);
165 
172 int osfi_confm_get_dimension(const OSFI_Parameter* obj, int index);
179 int osfi_confm_get_node_dimension(const OSFI_Parameter* obj, const int node[], int depth);
182 bool osfi_confm_is_leaf(const OSFI_Parameter* obj, const int node[], int depth);
183 
184 // Miscellaneous Parameter-related functions
186 OSFI_FFI_DEPRECATED("unsafe function, writes into unknown-sized char buffers")
187 void osfi_confm_get_parameter(const OSFI_Parameter* obj, char *name, char *description, char* value,
188  char *units, int dims[3], char *max, char *min, int *type);
195 OSFI_VEC_T(string) * osfi_confm_list_all_params(const OSFI_ParamReader* obj);
199 OSFI_VEC_T(string) * osfi_confm_list_child_params(const OSFI_ParamReader* obj, const char* parentGrp);
200 
208 
211 #ifdef __cplusplus
212 } // For the extern "C"
213 #endif
214 
215 #endif /* OSFI_FFI_CONFM_H */
OSFI_Vec_Tboolean * osfi_confm_file_exist(const OSFI_Parameter *p, enum osfi_confm_arrayorder aeo, int *size)
OSFI_ParamReader * osfi_param_reader_create_noval(const char *fileName)
struct OSFI_Parameter_t OSFI_Parameter
Definition: ConFM.h:53
OSFI_ParamElemType
Definition: ConFM.h:150
int osfi_confm_get_dimension(const OSFI_Parameter *obj, int index)
bool osfi_param_is_array(const OSFI_Parameter *obj)
osfi_ffi_confm_val_res
Definition: ConFM.h:68
@ OSFI_FFI_CONFM_VAL_ERRORS
Definition: ConFM.h:74
@ OSFI_FFI_CONFM_VAL_INVALID
Definition: ConFM.h:72
@ OSFI_FFI_CONFM_VAL_PASSED
Definition: ConFM.h:70
int osfi_param_get_description(const OSFI_Parameter *obj, char *buf, int bufSz)
bool osfi_confm_is_leaf(const OSFI_Parameter *obj, const int node[], int depth)
OSFI_Vec_Tstring * osfi_confm_list_all_params(const OSFI_ParamReader *obj)
Wraps ParamReader::getParameters()
void osfi_confm_print_parameters(const OSFI_ParamReader *obj)
void osfi_confm_get_parameter(const OSFI_Parameter *obj, char *name, char *description, char *value, char *units, int dims[3], char *max, char *min, int *type)
int osfi_param_get_local_name(const OSFI_Parameter *obj, char *buf, int bufSz)
struct OSFI_ParamReader_t OSFI_ParamReader
Definition: ConFM.h:52
OSFI_Vec_Tstring * osfi_confm_list_child_params(const OSFI_ParamReader *obj, const char *parentGrp)
Wraps ParamReader::getParameters(std::string)
int osfi_param_get_max_value(const OSFI_Parameter *obj, char *buf, int bufSz)
int osfi_param_get_min_value(const OSFI_Parameter *obj, char *buf, int bufSz)
int osfi_param_get_units(const OSFI_Parameter *obj, char *buf, int bufSz)
osfi_confm_arrayorder
Definition: ConFM.h:92
@ OSFI_CONFM_AO_LAST_CONTIG
Definition: ConFM.h:96
@ OSFI_CONFM_AO_FIRST_CONTIG
Definition: ConFM.h:100
void osfi_param_reader_destroy(OSFI_ParamReader **obj)
int osfi_confm_get_num_dims(const OSFI_Parameter *obj)
bool osfi_confm_exist_parameter(const OSFI_ParamReader *obj, const char *paramName)
const OSFI_Parameter * osfi_confm_get_param(const OSFI_ParamReader *obj, const char *paramName)
void osfi_confm_print_parameter(const OSFI_Parameter *obj)
OSFI_ParamReader * osfi_param_reader_create(const char *fileName, const char *schema)
enum osfi_ffi_confm_val_res osfi_param_reader_valagainst(const OSFI_ParamReader *obj, const char *xsdFile)
int osfi_confm_get_node_dimension(const OSFI_Parameter *obj, const int node[], int depth)
int osfi_param_get_path(const OSFI_Parameter *obj, char *buf, int bufSz)
enum OSFI_ParamElemType osfi_param_get_element_type(const OSFI_Parameter *obj)
int osfi_confm_compare_timevalue(const OSFI_TimeValue *a, const OSFI_TimeValue *b)
int osfi_param_get_raw_value(const OSFI_Parameter *obj, char *buf, int bufSz)
Internal header used by the foreign-function interface to OSFI-C++.
#define OSFI_FFI_DECL_PLACEHOLDER(name)
Definition: ffi_base.h:52
struct OSFI_TimeValue_t OSFI_TimeValue
Definition: ffi_base.h:102