Selaa lähdekoodia

r.li.daemon: use a function prototype, new modules do not need to modify the daemon code

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@59091 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 11 vuotta sitten
vanhempi
commit
8ca2b81cbb

+ 1 - 1
raster/r.li/r.li.daemon/daemon.c

@@ -41,7 +41,7 @@
 #define random rand
 #endif
 
-int calculateIndex(char *file, int f(int, char **, struct area_entry *, double *),
+int calculateIndex(char *file, rli_func *f,
 		   char **parameters, char *raster, char *output)
 {
 

+ 12 - 4
raster/r.li/r.li.daemon/daemon.h

@@ -119,7 +119,16 @@ struct area_entry
     char *mask_name;
 };
 
-
+/**
+ * \brief function prototype for index calculation
+ * \param fd file descripter of opened raster map
+ * \param par optional parameters
+ * \param ad definition of the sample area
+ * \param result pointer to store the result
+ * \return RLI_ERRORE error occurs in calculating index
+ * \return RLI_OK  otherwise
+ */
+typedef int rli_func(int fd, char **par, struct area_entry *ad, double *result);
 
 
 /**
@@ -132,7 +141,7 @@ struct area_entry
  * \return 1  otherwise
  */
 
-int calculateIndex(char *file, int f(int, char **, struct area_entry *, double *),
+int calculateIndex(char *file, rli_func *f,
 		   char **parameters, char *raster, char *output);
 
 /**
@@ -199,7 +208,7 @@ int error_Output(int out, msg m);
  * \param f the function used for index computing
  * \param result where to put the result of index computing
  */
-void worker_init(char *raster, int f(int, char **, struct area_entry *, double *),
+void worker_init(char *raster, rli_func *f,
 		 char **parameters);
 void worker_process(msg * ret, msg * m);
 void worker_end(void);
@@ -267,4 +276,3 @@ DCELL *RLI_get_dcell_raster_row(int fd, int row, struct area_entry * ad);
   */
 FCELL *RLI_get_fcell_raster_row(int fd, int row, struct area_entry * ad);
 
-#include "index.h"

+ 0 - 50
raster/r.li/r.li.daemon/index.h

@@ -1,50 +0,0 @@
-/*
- * \file index.h
- *
- * \brief declaration of functions for r.li raster analysis
- *  
- * \author Claudio Porta, Lucio Davide Spano, Serena Pallecchi students of Computer Science University of Pisa (Italy)
- *                      Commission from Faunalia Pontedera (PI) www.faunalia.it
- *        Luca Delucchi and Duccio Rocchini, Fondazione Edmund Mach, Italy: r.li.pielou, r.li.renyi
- *
- *
- * This program is free software under the GPL (>=v2)
- * Read the COPYING file that comes with GRASS for details.
- * 
- * \version 1.1
- *
- */
-
-
- /* #################################################
-    ADD HERE INDEX DECLARATIONS
-    ################################################# */
-
-
-
- /**
-  * \brief calculate patch density index on selected area
-  * the abstract function is patch_density= patch_number / area
-  */
-int patch_density(int fd, char **par, struct area_entry *ad, double *result);
-
-int patch_number(int fd, char **par, struct area_entry *ad, double *result);
-int shape_index(int fd, char **par, struct area_entry *ad, double *result);
-int shannon(int fd, char **par, struct area_entry *ad, double *result);
-
-int pielou(int fd, char **par, struct area_entry *ad, double *result);
-int renyi(int fd, char **par, struct area_entry *ad, double *result);
-
-int simpson(int fd, char **par, struct area_entry *ad, double *result);
-int meanPatchSize(int fd, char **par, struct area_entry *ad, double *result);
-int meanPixelAttribute(int fd, char **par, struct area_entry *ad, double *result);
-int contrastWeightedEdgeDensity(int fd, char **par, struct area_entry *ad,
-				double *result);
-int edgedensity(int fd, char **valore, struct area_entry *ad, double *result);
-int patchAreaDistributionCV(int fd, char **par, struct area_entry *ad, double *result);
-int patchAreaDistributionMN(int fd, char **par, struct area_entry *ad, double *result);
-int patchAreaDistributionSD(int fd, char **par, struct area_entry *ad, double *result);
-int patchAreaDistributionRANGE(int fd, char **par, struct area_entry *ad,
-			       double *result);
-int dominance(int fd, char **par, struct area_entry *ad, double *result);
-int richness(int fd, char **par, struct area_entry *ad, double *result);

+ 2 - 2
raster/r.li/r.li.daemon/worker.c

@@ -49,9 +49,9 @@ static dcell_manager dm;
 static fcell_manager fm;
 static char *raster;
 static char **parameters;
-static int (*func) (int, char **, struct area_entry *, double *);
+static rli_func *func;
 
-void worker_init(char *r, int f(int, char **, struct area_entry *, double *), char **p)
+void worker_init(char *r, rli_func *f, char **p)
 {
     cm = G_malloc(sizeof(struct cell_memory_entry));
     fm = G_malloc(sizeof(struct fcell_memory_entry));