00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _C_TASK_CONTROL
00021 #define _C_TASK_CONTROL
00022
00023 #include "iostream_t.hpp"
00024 #include <pthread.h>
00025
00026 #include "GeneratorError.h"
00027
00028 class C_TaskControl {
00029
00030 public:
00031
00032 typedef enum _enum_state {
00033 E_STATE_UNKNOWN = 0 ,
00034 E_STATE_INIT,
00035 E_STATE_RUNNING,
00036 E_STATE_STOPPING,
00037 E_STATE_STOPPED
00038 } T_State ;
00039
00040 C_TaskControl() ;
00041 virtual ~C_TaskControl() ;
00042
00043 T_GeneratorError init () ;
00044 T_GeneratorError run () ;
00045 T_GeneratorError run_task_once () ;
00046 T_GeneratorError run_all_once () ;
00047
00048 void stop () ;
00049 T_State get_state() ;
00050
00051 protected:
00052
00053 virtual T_GeneratorError TaskProcedure () = 0 ;
00054 virtual T_GeneratorError InitProcedure () = 0 ;
00055 virtual T_GeneratorError EndProcedure () = 0 ;
00056 virtual T_GeneratorError StoppingProcedure () = 0 ;
00057 virtual T_GeneratorError ForcedStoppingProcedure () = 0 ;
00058
00059 virtual T_GeneratorError InitTaskProcedure () { return (E_GEN_NO_ERROR); } ;
00060
00061 T_State M_state ;
00062 bool m_end_executed ;
00063
00064 } ;
00065
00066 iostream_output& operator<<(iostream_output&, C_TaskControl::T_State&);
00067
00068
00069 pthread_t* start_thread_control (C_TaskControl *P_taskControl) ;
00070 void wait_thread_control_end (pthread_t *P_thread);
00071
00072 #endif // _C_TASK_CONTROL