• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

/home/pascal/depot/filedata/src/epr/epr_bitmask.h

00001 /*
00002  * $Id: epr__bitmask_8h_source.html,v 1.11 2013/02/14 16:57:53 pascal Exp $
00003  *
00004  * Copyright (C) 2002 by Brockmann Consult (info@brockmann-consult.de)
00005  *
00006  * This program is free software; you can redistribute it and/or modify it
00007  * under the terms of the GNU General Public License as published by the
00008  * Free Software Foundation. This program is distributed in the hope it will
00009  * be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
00010  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00011  * See the GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program; if not, write to the Free Software
00015  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00016  */
00017 
00018 #ifndef EPR_BITMASK_H_INCL
00019 #define EPR_BITMASK_H_INCL
00020 
00021 #ifdef __cplusplus
00022 extern "C"
00023 {
00024 #endif
00025 
00026 
00027 #define FLAG_MASK_NOT_COMPUTED ((ulong) -1)
00028 
00029 typedef struct EPR_BmTerm               EPR_SBmTerm;
00030 typedef struct EPR_BmEvalContext        EPR_SBmEvalContext;
00031 typedef struct EPR_BmFlagDataset        EPR_SBmFlagDataset;
00032 typedef enum   EPR_BmOpCode             EPR_EBmOpCode;
00033 
00034 
00035 /* private implementations */
00036 
00037 
00038 enum EPR_BmOpCode {
00039     BMT_UNKNOWN = 0,
00040     BMT_REF,
00041     BMT_AND,
00042     BMT_OR,
00043     BMT_NOT
00044 };
00045 
00046 
00047 enum EPR_Tok {
00048     BME_UNKNOWN = 0,
00049     BME_EOS,
00050     BME_SPECIAL,
00051     BME_NAME
00052 };
00053 
00063 struct EPR_BmTerm {
00064     EPR_EBmOpCode op_code;
00065     union {
00066         struct /*BMT_REF*/ {
00067             char* band_name;
00068             char* flag_name;
00069             ulong flag_mask;
00070             EPR_SRaster* flag_raster;
00071         } ref;
00072         struct /*BMT_NOT*/ {
00073             EPR_SBmTerm* arg;
00074         } unary;
00075         struct /*BMT_AND and BMT_OR*/ {
00076             EPR_SBmTerm* arg1;
00077             EPR_SBmTerm* arg2;
00078         } binary;
00079     } op;
00080 };
00081 
00082 
00095 struct EPR_BmEvalContext
00096 {
00100     EPR_SProductId* product_id;
00101 
00105     int offset_x;
00106 
00110     int offset_y;
00111 
00115     EPR_SRaster* bitmask_raster;
00116 
00120     EPR_SPtrArray* flag_band_ids;
00121 
00125     EPR_SPtrArray* flag_rasters;
00126 };
00127 
00128 
00133 struct EPR_BmFlagDataset {
00134     /*The name of bitmask dataset*/
00135     char* name;
00136     /*The value of bitmask dataset (the number of the relevant bit in bitmask)*/
00137     uint bit_index;
00138     /*The description of bitmask dataset*/
00139     char* description;
00140 };
00141 
00142 
00154 EPR_SBmEvalContext* epr_create_bm_eval_context(EPR_SProductId* product_id,
00155                                                int offset_x,
00156                                                int offset_y,
00157                                                EPR_SRaster* raster);
00158 
00159 
00167 void epr_free_bm_eval_context(EPR_SBmEvalContext* context);
00168 
00169 
00219 int epr_read_bitmask_data(const EPR_SProductId* product_id,
00220                           const char* bm_expr,
00221                           int xo,
00222                           int yo,
00223                           int raster_width,
00224                           int raster_height,
00225                           int s_x,
00226                           int s_y,
00227                           void* raster_buffer);
00228 
00229 
00230 
00238 boolean epr_eval_bm_term(EPR_SBmEvalContext* context,
00239                          EPR_SBmTerm* term,
00240                          int x,
00241                          int y);
00242 
00243 
00244 
00298 EPR_SBmTerm* epr_parse_bm_expr_str(const char* bm_expr);
00299 
00300 
00301 struct EPR_ParseInfo {
00302     const char* bm_expr;
00303     int bm_expr_pos;
00304     boolean pushed_back;
00305     int token_type;
00306     char* token;
00307     char* err_message;
00308 };
00309 
00310 
00311 typedef struct EPR_ParseInfo EPR_SParseInfo;
00312 
00322 EPR_SBmTerm* epr_parse_bm_expr(EPR_SParseInfo* parse_info, boolean term_required);
00323 EPR_SBmTerm* epr_parse_bm_OR_expr(EPR_SParseInfo* parse_info, boolean term_required);
00324 EPR_SBmTerm* epr_parse_bm_AND_expr(EPR_SParseInfo* parse_info, boolean term_required);
00325 EPR_SBmTerm* epr_parse_bm_unary_expr(EPR_SParseInfo* parse_info, boolean term_required);
00326 EPR_SBmTerm* epr_parse_bm_primary_expr(EPR_SParseInfo* parse_info, boolean term_required);
00337 boolean epr_is_bm_OR_keyword(EPR_SParseInfo* parse_info);
00338 boolean epr_is_bm_AND_keyword(EPR_SParseInfo* parse_info);
00339 boolean epr_is_bm_NOT_keyword(EPR_SParseInfo* parse_info);
00350 boolean epr_is_bm_AND_operator(EPR_SParseInfo* parse_info);
00351 boolean epr_is_bm_OR_operator(EPR_SParseInfo* parse_info);
00352 boolean epr_is_bm_NOT_operator(EPR_SParseInfo* parse_info);
00362 boolean epr_is_bm_name_token(EPR_SParseInfo* parse_info);
00363 
00371 boolean epr_is_bm_EOS_token(EPR_SParseInfo* parse_info);
00372 
00380 boolean epr_is_bm_expr_error(EPR_SParseInfo* parse_info);
00381 
00389 int epr_get_token_char(EPR_SParseInfo* parse_info);
00390 
00398 char* epr_consume_token(EPR_SParseInfo* parse_info);
00399 
00405 void epr_next_bm_expr_token(EPR_SParseInfo* parse_info);
00406 
00407 void epr_push_back_bm_expr_token(EPR_SParseInfo* parse_info);
00408 
00409 void epr_set_bm_expr_error(EPR_SParseInfo* parse_info, const char* message);
00410 
00411 int epr_tokenize_bm_expr(const char* bm_expr, int* bm_expr_pos, char** token);
00412 
00416 EPR_SBmTerm* epr_create_bm_term(EPR_EBmOpCode op_code);
00417 
00421 EPR_SBmTerm* epr_create_bm_REF_term(char* ds_name, char* flag_name);
00422 
00426 EPR_SBmTerm* epr_create_bm_NOT_term(EPR_SBmTerm* arg);
00427 
00431 EPR_SBmTerm* epr_create_bm_OR_term(EPR_SBmTerm* arg1, EPR_SBmTerm* arg2);
00432 
00436 EPR_SBmTerm* epr_create_bm_AND_term(EPR_SBmTerm* arg1, EPR_SBmTerm* arg2);
00437 
00441 void epr_free_bm_term(EPR_SBmTerm* term);
00442 
00443 
00451 char* epr_create_bm_expr(EPR_SBmTerm* term);
00455 void epr_print_bm_term(EPR_SBmTerm* term);
00456 
00460 void epr_write_bm_term(EPR_SBmTerm* term, FILE* ostream);
00461 
00469 EPR_SPtrArray* epr_create_flag_coding(EPR_SProductId* product_id, const char* str);
00475 EPR_SFlagDef* epr_create_flag_def();
00479 void epr_free_flag_def(EPR_SFlagDef* flag_def);
00480 
00484 void epr_free_flag_coding(EPR_SPtrArray* flag_coding);
00485 
00486 #ifdef __cplusplus
00487 } /* extern "C" */
00488 #endif
00489 
00490 #endif
00491 /* #ifndef EPR_BITMASK_H_INCL */

Generated on Thu Feb 14 2013 17:59:03 for filedata.kdevelop by  doxygen 1.7.1