grasp_output_stream.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_STREAM_H
18 #define GRASP_STREAM_H
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 #include <stdio.h>
25 #include "../settings/grasp_settings.h"
26 #include "../input/grasp_input.h"
27 #include "../output/grasp_output.h"
28 
29 
52  char *grasp_output_stream_filename(grasp_output_stream *gs, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
53 
59  bool grasp_output_stream_filename_validation(const char *original_name);
60 
61 
67  void grasp_output_stream_initialize(const char *filename, grasp_output_stream *gs);
68 
82  FILE *grasp_output_stream_open(grasp_output_stream *gs, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
83 
90 
97 
103 
107 #define gos_fprintf(f_, s_, ...) \
108  do { \
109  if((f_)->writable==true) fprintf(((f_)->file), (s_), ## __VA_ARGS__); \
110  } while (0)
111 
115 #define gos_fprintf_flushed(f_, s_, ...) \
116  do { \
117  if((f_)->writable==true) fprintf(((f_)->file), (s_), ## __VA_ARGS__); \
118  fflush(((f_)->file)); \
119  } while (0)
120 
124 #define gos_benchmark_print_stream(f_, label_, benchmark_) \
125  do { \
126  if((f_)->writable==true) fprintf(((f_)->file), ("%s:%d: %s: clock_time: %f cpu_time: %f\n"), __FILE__,__LINE__,label_,(benchmark_)->delta_ct, (benchmark_)->delta_ut); \
127  fflush(((f_)->file)); \
128  } while (0)
129 
130 
136 
143 
156  char *grasp_output_stream_filename_generator(const char *original_name, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
157 
161  typedef char *(*grasp_output_stream_filename_generate_by)(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
162 
164  const char *token;
167 
181  char *grasp_output_stream_filename_generate_by_auto(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
182 
196  char *grasp_output_stream_filename_generate_by_icol(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
197 
211  char *grasp_output_stream_filename_generate_by_irow(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
212 
226  char *grasp_output_stream_filename_generate_by_itime(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
227 
241  char *grasp_output_stream_filename_generate_by_iinversion(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
242 
256  char *grasp_output_stream_filename_generate_by_segment_nx(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
257 
271  char *grasp_output_stream_filename_generate_by_segment_ny(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
272 
286  char *grasp_output_stream_filename_generate_by_segment_nt(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
287 
301  char *grasp_output_stream_filename_generate_by_tile_from(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
302 
316  char *grasp_output_stream_filename_generate_by_tile_to(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
317 
331  char *grasp_output_stream_filename_generate_by_tile_corner_column(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
332 
346  char *grasp_output_stream_filename_generate_by_tile_corner_row(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
347 
361  char *grasp_output_stream_filename_generate_by_tile_center_longitude(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
362 
376  char *grasp_output_stream_filename_generate_by_tile_center_latitude(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
377 
391  char *grasp_output_stream_filename_generate_by_tile_coordinate_x(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
392 
406  char *grasp_output_stream_filename_generate_by_tile_coordinate_y(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
407 
421  char *grasp_output_stream_filename_generate_by_tile_width(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
422 
436  char *grasp_output_stream_filename_generate_by_tile_height(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
437 
451  char *grasp_output_stream_filename_generate_by_segment_corner_column(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
452 
466  char *grasp_output_stream_filename_generate_by_segment_corner_row(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
467 
481  char *grasp_output_stream_filename_generate_by_settings_filename(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
482 
496  char *grasp_output_stream_filename_generate_by_branch(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
497 
511  char *grasp_output_stream_filename_generate_by_commit(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
512 
526  char *grasp_output_stream_filename_generate_by_constants_set(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
527 
541  char *grasp_output_stream_filename_generate_by_version(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
542 
556  char *grasp_output_stream_filename_generate_by_segment_first_date(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
557 
558 
572  char *grasp_output_stream_filename_generate_by_segment_last_date(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
573 
587  char *grasp_output_stream_filename_generate_by_iteration(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
588 
602  char *grasp_output_stream_filename_generate_by_pwd(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
603 
617  char *grasp_output_stream_filename_generate_by_yml(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
618 
632  char *grasp_output_stream_filename_generate_by_token(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime);
633 
634 
635 #ifdef __cplusplus
636 }
637 #endif
638 
639 #endif /* GRASP_STREAM_H */
640 
char * grasp_output_stream_filename_generate_by_iteration(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
version: Return number of iterations of current retrieval
Definition: grasp_output_stream.c:1011
char * grasp_output_stream_filename_generate_by_tile_height(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
tile_height(N): Number of Y elements in tile with N zeros at the left
Definition: grasp_output_stream.c:880
char * grasp_output_stream_filename_generate_by_version(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
version: Return version of grasp if it is compiled with saving this information
Definition: grasp_output_stream.c:1057
Definition: grasp_output_stream_t.h:24
char * grasp_output_stream_filename_generate_by_yml(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
yml: this is replaced by current folder of main configuration file and it is only valid at the beginn...
Definition: grasp_output_stream.c:1123
char * grasp_output_stream_filename_generate_by_tile_width(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
tile_width(N): Number of X elements in tile with N zeros at the left
Definition: grasp_output_stream.c:851
char * grasp_output_stream_filename_generate_by_icol(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
icol(N): current column number with N zeros at the left
Definition: grasp_output_stream.c:423
char * grasp_output_stream_filename_generate_by_segment_ny(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
segment_ny(N): number of Y elements per segment with N zeros at the left
Definition: grasp_output_stream.c:567
Definition: grasp_input_tile_description.h:22
char * grasp_output_stream_filename_generate_by_tile_corner_row(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
tile_corner_row(N): number of the corner of (row) the tile defined in settings file....
Definition: grasp_output_stream.c:708
char * grasp_output_stream_filename_generate_by_constants_set(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
constants_set: Return constants set used in compilation time
Definition: grasp_output_stream.c:1096
char * grasp_output_stream_filename_generate_by_irow(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
irow(N): current column number with N zeros at the left
Definition: grasp_output_stream.c:451
char * grasp_output_stream_filename_generate_by_tile_center_longitude(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
tile_center_longitude(FORMAT): longitude of the center of the tile defined in settings file....
Definition: grasp_output_stream.c:738
FILE * grasp_output_stream_open(grasp_output_stream *gs, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
Open a stream returning FILE pointer. Open a stream returning FILE pointer. You should use grasp_stre...
Definition: grasp_output_stream.c:320
char * grasp_output_stream_filename_generate_by_segment_corner_column(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
segment_corner_column(N): number of column of the segment corner with N zeros at the left....
Definition: grasp_output_stream.c:909
void grasp_output_stream_debug(grasp_output_stream *gs, FILE *f)
Dump debug information of current grasp output stream.
Definition: grasp_output_stream.c:377
char * grasp_output_stream_filename_generate_by_pwd(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
pwd: this is replaced by current folder and is only valid at the beginning of the stream definition
Definition: grasp_output_stream.c:1109
struct grasp_output_stream_filename_generate_by_template_ grasp_output_stream_filename_generate_by_template
bool grasp_output_stream_writable_file(const grasp_output_stream *gs)
Return true if the stream is writable file (only if is a file)
Definition: grasp_output_stream.c:352
char * grasp_output_stream_filename_generate_by_token(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
When the token is known this function is called and will return a copy of input token.
Definition: grasp_output_stream.c:1137
void grasp_output_stream_close(grasp_output_stream *gs)
Close current open stream.
Definition: grasp_output_stream.c:360
char * grasp_output_stream_filename_generate_by_segment_corner_row(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
segment_corner_row(N): number of row of the segment corner with N zeros at the left Requirement: Inpu...
Definition: grasp_output_stream.c:938
Definition: grasp_output_segment_result.h:498
char * grasp_output_stream_filename_generate_by_segment_nt(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
segment_nt(N): number of T elements per segment with N zeros at the left
Definition: grasp_output_stream.c:596
char *(* grasp_output_stream_filename_generate_by)(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
Definition: grasp_output_stream.h:161
char * grasp_output_stream_filename_generator(const char *original_name, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
Definition: grasp_output_stream.c:53
void grasp_output_stream_destroy(grasp_output_stream *gs)
Deallocate memory taken by grasp output stream.
Definition: grasp_output_stream.c:373
char * grasp_output_stream_filename_generate_by_tile_coordinate_x(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
tile_coordinate_x(I): x input reference of center of the tile defined in settings file....
Definition: grasp_output_stream.c:797
char * grasp_output_stream_filename_generate_by_itime(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
itime(N): current time number with N zeros at the left
Definition: grasp_output_stream.c:480
char * grasp_output_stream_filename_generate_by_tile_corner_column(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
tile_corner_column(N): number of the corner (column) of the tile defined in settings file....
Definition: grasp_output_stream.c:679
char * grasp_output_stream_filename_generate_by_segment_last_date(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
version: Return last date present in specific segment
Definition: grasp_output_stream.c:989
char * grasp_output_stream_filename_generate_by_tile_to(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
tile_to(FORMAT): final tile date in FORMAT. By default FORMAT is FTH_M_SZ
Definition: grasp_output_stream.c:652
void grasp_output_stream_initialize(const char *filename, grasp_output_stream *gs)
Initilize gs stream argument with filename string.
Definition: grasp_output_stream.c:280
char * grasp_output_stream_filename(grasp_output_stream *gs, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
Return a allocated string created from original_name replacing the special pattern wildcards.
Definition: grasp_output_stream.c:129
const char * token
Definition: grasp_output_stream.h:164
char * grasp_output_stream_filename_generate_by_tile_coordinate_y(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
tile_coordinate_y(I): y input reference of center of the tile defined in settings file....
Definition: grasp_output_stream.c:824
Definition: grasp_input_segment.h:243
char * grasp_output_stream_filename_generate_by_settings_filename(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
settings_filename: the name of settings file used to run the retrieval
Definition: grasp_output_stream.c:1043
char * grasp_output_stream_filename_generate_by_tile_from(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
tile_from(FORMAT): start tile date in FORMAT. By default FORMAT is FTH_M_SZ
Definition: grasp_output_stream.c:625
char * grasp_output_stream_filename_generate_by_segment_first_date(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
version: Return first date present in specific segment
Definition: grasp_output_stream.c:967
char * grasp_output_stream_filename_generate_by_segment_nx(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
segment_nx(N): number of X elements per segment with N zeros at the left
Definition: grasp_output_stream.c:538
char * grasp_output_stream_filename_generate_by_auto(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
auto(N): itimexicolxirow with N zeros at the left
Definition: grasp_output_stream.c:387
Definition: grasp_output_stream.h:163
char * grasp_output_stream_filename_generate_by_branch(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
branch: git branch of grasp if it is compiled with saving this information
Definition: grasp_output_stream.c:1070
char * grasp_output_stream_filename_generate_by_tile_center_latitude(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
tile_center_latitude(FORMAT): latitude of the center of the tile defined in settings file....
Definition: grasp_output_stream.c:767
char * grasp_output_stream_filename_generate_by_commit(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
commit: Return commit reference of grasp if it is compiled with saving this information
Definition: grasp_output_stream.c:1083
char * grasp_output_stream_filename_generate_by_iinversion(const char *token, const char *format, const grasp_settings *settings, const grasp_segment_t *segment, const output_segment_general *output, const grasp_tile_dimensions_t *tile_description, int icol, int irow, int itime)
iinversion(N): current inversion id with N zeros at the left
Definition: grasp_output_stream.c:509
bool grasp_output_stream_writable(const grasp_output_stream *gs)
Return true if the stream is writable.
Definition: grasp_output_stream.c:348
Definition: grasp_settings_t.h:409
bool grasp_output_stream_filename_validation(const char *original_name)
Validate if filename is well-formed.
Definition: grasp_output_stream.c:144