/Users/huttone/Devel/sedflux-new/sedflux/trunk/ew/sed/sed_process.h

Go to the documentation of this file.
00001 //---
00002 //
00003 // This file is part of sedflux.
00004 //
00005 // sedflux is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 2 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // sedflux is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with sedflux; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 //
00019 //---
00020 
00021 #ifndef PROCESS_H
00022 # define PROCESS_H
00023 
00024 #include <glib.h>
00025 #include "utils/utils.h"
00026 
00027 #include "sed_cube.h"
00028 
00029 #define PROCESS_ALWAYS    ( 1 << 3 )
00030 #define PROCESS_REGULAR   ( 1 << 2 )
00031 #define PROCESS_IRREGULAR ( 1 << 1 )
00032 #define PROCESS_SPECIFIED ( 1 << 0 )
00033 
00034 #define SED_MAX_LOG_FILES (2)
00035 
00036 #define SED_ERROR_MULTIPLE_PROCS      (1<<0)
00037 #define SED_ERROR_PROC_ABSENT         (1<<1)
00038 #define SED_ERROR_INACTIVE            (1<<2)
00039 #define SED_ERROR_NOT_ALWAYS          (1<<3)
00040 #define SED_ERROR_ABSENT_PARENT       (1<<4)
00041 #define SED_ERROR_INACTIVE_PARENT     (1<<5)
00042 #define SED_ERROR_MULTIPLE_PARENTS    (1<<6)
00043 #define SED_ERROR_INACTIVE_CHILDREN   (1<<7)
00044 #define SED_ERROR_DT_MISMATCH         (1<<8)
00045 
00046 #define SED_PROC_DEFAULT        (0)
00047 #define SED_PROC_UNIQUE         (1<<0)
00048 #define SED_PROC_ACTIVE         (1<<1)
00049 #define SED_PROC_ALWAYS         (1<<2)
00050 #define SED_PROC_ACTIVE_PARENT  (1<<3)
00051 #define SED_PROC_ACTIVE_CHILD   (1<<4)
00052 #define SED_PROC_UNIQUE_PARENT  (1<<5)
00053 #define SED_PROC_UNIQUE_CHILD   (1<<6)
00054 #define SED_PROC_SAME_INTERVAL  (1<<7)
00055 
00056 new_handle( Sed_process       );
00057 new_handle( Sed_process_queue );
00058 
00059 typedef struct
00060 {
00061 // Public
00062    double   mass_added;
00063    double   mass_lost;
00064    gboolean error;
00065 }
00066 Sed_process_info;
00067 
00068 typedef struct
00069 {
00070    const gchar* parent;
00071    const gchar* child;
00072 }
00073 Sed_process_family;
00074 
00075 typedef struct
00076 {
00077    const gchar* parent;
00078    const gchar* child;
00079    gint         flags;
00080 }
00081 Sed_process_check;
00082 
00083 const static Sed_process_info __empty_info = { 0,0,FALSE };
00084 
00085 #define SED_EMPTY_INFO __empty_info
00086 
00087 typedef gboolean         (*init_func    )  ( Sed_process , Eh_symbol_table , GError** );
00088 typedef Sed_process_info (*run_func     )  ( Sed_process , Sed_cube );
00089 typedef gboolean         (*destroy_func )  ( Sed_process );
00090 
00091 typedef gboolean         (Sed_proc_init   ) ( Sed_process , Eh_symbol_table , GError** );
00092 typedef Sed_process_info (Sed_proc_run    ) ( Sed_process , Sed_cube );
00093 typedef gboolean         (Sed_proc_destroy) ( Sed_process );
00094 
00095 
00096 //typedef gboolean         (*init_func)  (Eh_symbol_table,gpointer);
00097 //typedef Sed_process_info (*run_func)   (gpointer,Sed_cube);
00098 
00099 typedef gboolean         (*load_func)  (gpointer,FILE*);
00100 typedef gboolean         (*dump_func)  (gpointer,FILE*);
00101 
00102 typedef struct
00103 {
00104    gchar*       name;      //< The name of the process
00105    init_func    init_f;    //< Function that initialize the process
00106    run_func     run_f;     //< Function that runs the process
00107    destroy_func destroy_f; //< Function that destroys the process
00108 }
00109 Sed_process_init_t;
00110 
00111 typedef enum
00112 {
00113    SED_PROC_ERROR_BAD_INIT_FILE  ,
00114    SED_PROC_ERROR_NOT_FOUND      ,
00115    SED_PROC_ERROR_MISSING_PARENT
00116 }
00117 Sed_process_error;
00118 
00119 #define SED_PROC_ERROR sed_process_error_quark()
00120 
00121 Sed_process    sed_process_create         ( const char*  name   ,
00122                                             init_func    f_init ,
00123                                             run_func     f_run  ,
00124                                             destroy_func f_destroy );
00125 Sed_process    sed_process_copy           ( Sed_process d    , Sed_process s );
00126 Sed_process    sed_process_dup            ( Sed_process s );
00127 Sed_process    sed_process_destroy        ( Sed_process p );
00128 void           sed_process_clean          ( Sed_process p );
00129 double         sed_process_next_event     ( Sed_process p );
00130 Sed_process    sed_process_set_next_event ( Sed_process p    , double new_next_event );
00131 gboolean       sed_process_is_on          ( Sed_process p    , double time );
00132 gboolean       sed_process_array_run      ( GPtrArray *a     , Sed_cube );
00133 gboolean       sed_process_run            ( Sed_process      , Sed_cube );
00134 gboolean       sed_process_run_at_end     ( Sed_process      , Sed_cube );
00135 gboolean       sed_process_run_now        ( Sed_process      , Sed_cube );
00136 void           sed_process_init           ( Sed_process a    , Eh_symbol_table symbol_table , GError** error );
00137 GList*         sed_process_scan           ( Eh_key_file k    , Sed_process p , GError** error );
00138 gssize         sed_process_fprint         ( FILE* fp         , Sed_process p );
00139 gssize         sed_process_queue_fprint   ( FILE* fp         , Sed_process_queue q );
00140 gssize         sed_process_queue_summary  ( FILE* fp         , Sed_process_queue q );
00141 gssize         sed_process_queue_size     ( Sed_process_queue q );
00142 gssize         sed_process_queue_n_active ( Sed_process_queue q );
00143 gssize         sed_process_queue_n_absent ( Sed_process_queue q );
00144 gssize         sed_process_queue_n_inactive( Sed_process_queue q );
00145 
00146 gpointer       sed_process_data           ( Sed_process p );
00147 void           sed_process_provide        ( Sed_process p , GQuark key , gpointer data );
00148 void           sed_process_withhold       ( Sed_process p , GQuark key );
00149 gpointer       sed_process_use            ( Sed_process p , GQuark key );
00150 
00151 #define sed_process_new_user_data( p , t ) ( (t*)sed_process_malloc_user_data(p,sizeof(t)) )
00152 
00153 Sed_process    sed_process_child              ( Sed_process p , const gchar* child_s );
00154 Sed_process    sed_process_append_child       ( Sed_process p , Sed_process c );
00155 gboolean       sed_process_is_parent          ( Sed_process p );
00156 double         sed_process_interval           ( Sed_process p );
00157 gboolean       sed_process_interval_is_always ( Sed_process p );
00158 gboolean       sed_process_interval_is_at_end ( Sed_process p );
00159 gchar*         sed_process_name               ( Sed_process p );
00160 gint           sed_process_run_count          ( Sed_process p );
00161 gboolean       sed_process_is_set             ( Sed_process p );
00162 gpointer       sed_process_user_data          ( Sed_process p );
00163 gpointer       sed_process_malloc_user_data   ( Sed_process p , gssize n_bytes );
00164 gboolean       sed_process_name_is_same       ( Sed_process a , Sed_process b );
00165 gboolean       sed_process_is_active          ( Sed_process p );
00166 
00167 gssize         sed_process_fprint_info( FILE* fp , Sed_process p );
00168 gssize         sed_process_summary    ( FILE* fp , Sed_process p );
00169 gboolean       sed_process_error      ( Sed_process p );
00170 
00171 int            sed_process_queue_check_item  ( Sed_process_queue , const gchar* );
00172 int            sed_process_queue_check_family( Sed_process_queue ,
00173                                                const gchar* parent ,
00174                                                const gchar* child  );
00175 double         sed_process_queue_item_interval( Sed_process_queue q , const gchar* name );
00176 
00177 Sed_process_queue sed_process_queue_new     ( void );
00178 Sed_process_queue sed_process_queue_dup     ( Sed_process_queue );
00179 Sed_process_queue sed_process_queue_copy    ( Sed_process_queue , Sed_process_queue );
00180 Sed_process_queue sed_process_queue_destroy ( Sed_process_queue );
00181 Sed_process_queue sed_process_queue_init    ( const gchar*        file       ,
00182                                               Sed_process_init_t* p_list     ,
00183                                               Sed_process_family  p_family[] ,
00184                                               Sed_process_check   p_check[]  ,
00185                                               GError**            error );
00186 Sed_process_queue sed_process_queue_set_families( Sed_process_queue q , Sed_process_family f[] , GError** error );
00187 Sed_process_queue sed_process_queue_scan    ( Sed_process_queue , Eh_key_file , GError** );
00188 Sed_process_queue sed_process_queue_remove  ( Sed_process_queue , gchar*   );
00189 Sed_process_queue sed_process_queue_delete  ( Sed_process_queue , const gchar* );
00190 Sed_process_queue sed_process_queue_run     ( Sed_process_queue , Sed_cube );
00191 Sed_process_queue sed_process_queue_run_until( Sed_process_queue q , Sed_cube p , double t_total );
00192 Sed_process_queue sed_process_queue_run_at_end ( Sed_process_queue q , Sed_cube p );
00193 Sed_process_queue sed_process_queue_run_process_now( Sed_process_queue q    ,
00194                                                      const gchar*      name ,
00195                                                      Sed_cube          cube );
00196 
00197 Sed_process       sed_process_queue_find_nth_obj( Sed_process_queue q ,
00198                                                   const gchar* name   ,
00199                                                   gssize n );
00200 Sed_process_queue sed_process_queue_push        ( Sed_process_queue q ,
00201                                                   Sed_process_init_t init );
00202 gpointer*         sed_process_queue_obj_data( Sed_process_queue q , const char* name );
00203 Sed_process_queue sed_process_queue_activate  ( Sed_process_queue q ,
00204                                                 const gchar* name );
00205 Sed_process_queue sed_process_queue_deactivate( Sed_process_queue q ,
00206                                                 const gchar* name );
00207 Sed_process_queue sed_process_queue_set_active( Sed_process_queue q ,
00208                                                 const gchar* name   ,
00209                                                 gboolean val );
00210 gboolean          sed_process_queue_validate  ( Sed_process_queue q , Sed_process_check check[] , GError** error );
00211 
00212 #define sed_process_new(name,type,f_init,f_run) ( \
00213    sed_process_create( name , sizeof(type) , f_init , f_run ) )
00214 #define sed_process_data_val(p,member,type) ( ((type*)(sed_process_data(p)))->member )
00215 
00216 //#define sed_new_process(name,type,f_init,f_run,f_load,f_dump) ( sed_process_create(name,sizeof(type),f_init,f_run,f_load,f_dump) )
00217 
00218 //#define sed_process_data_val(p,member,type) ( ((type*)((p)->data))->member )
00219 
00220 #endif /* process.h is included */

Generated on Fri Jan 4 18:04:15 2008 for sedflux by  doxygen 1.5.2