#ifndef NINAC_H #define NINAC_H #define PROTO_VERSION "VER1" #include #include #include using namespace std; typedef vector strings; class NINAC_STATE{ std::string name; /*~PROTOBEG~ NINAC_STATE */ public: NINAC_STATE (const NINAC_STATE&t); NINAC_STATE (const char *_name); const char *getname (void)const; /*~PROTOEND~ NINAC_STATE */ }; typedef std::vector NINAC_STATES; class NINAC_COND{ NINAC_STATE state; bool nottrue; /*~PROTOBEG~ NINAC_COND */ public: NINAC_COND (const NINAC_COND&c); NINAC_COND (const char *_name); NINAC_COND (const char *_name, bool _nottrue); const char *getname (void)const; bool negative (void)const; /*~PROTOEND~ NINAC_COND */ }; // Condition �alu�par une fonction class NINAC_FCOND{ std::string name; bool (*f) (const char *task, const char *target, const strings &); strings args; bool nottrue; /*~PROTOBEG~ NINAC_FCOND */ public: NINAC_FCOND (const char *_name, bool (*_f)(const char *task, const char *target, const strings&args), const strings&_args, bool _nottrue); string getargs (void)const; const char *getname (void)const; bool test (const char *task, const char *target); /*~PROTOEND~ NINAC_FCOND */ }; class NINAC_FEXEC{ std::string name; void (*f) (const char *task, const char *target, bool pre_exec, const strings &); strings args; /*~PROTOBEG~ NINAC_FEXEC */ public: NINAC_FEXEC (const char *_name, void (*_f)(const char *task, const char *target, bool pre_exec, const strings&args), const strings&_args); void run (const char *task, const char *target, bool pre_exec); /*~PROTOEND~ NINAC_FEXEC */ }; typedef std::vector NINAC_CONDS; typedef std::vector NINAC_FCONDS; typedef std::vector NINAC_FEXECS; class NINAC_TASKBASE{ protected: std::string name; std::string command; NINAC_CONDS conds; NINAC_FCONDS fconds; NINAC_FEXECS fexecs; /*~PROTOBEG~ NINAC_TASKBASE */ public: NINAC_TASKBASE (const NINAC_TASKBASE&t); NINAC_TASKBASE (const char *_name); void addcond (const char *_name); void addcond (const char *_name, bool _nottrue); void addcond (const char *name, bool (*f)(const char *, const char *, const strings&), const strings&args, bool nottrue); void addexec (const char *name, void (*f)(const char *, const char *, bool pre_exec, const strings&), const strings&args); const char *getcommand (void)const; const char *getname (void)const; void setcommand (const char *_command); /*~PROTOEND~ NINAC_TASKBASE */ }; class NINAC_TASK: public NINAC_TASKBASE{ std::string target; int priority; /*~PROTOBEG~ NINAC_TASK */ public: NINAC_TASK (const NINAC_TASK&t); NINAC_TASK (const NINAC_TASKBASE&t, const char *_target); void exec (bool force); void exec (void); const char *gettarget (void)const; void listcond (set&allcond); void listfcond (set&allcond); bool may_exec (void)const; bool maydo (void); bool operator < (const NINAC_TASK&t)const; void runexecs (bool pre_exec); void set_exec (bool may); void set_priority (int _priority); void set_running (bool is_running); /*~PROTOEND~ NINAC_TASK */ }; class NINAC_VAL{ std::string s; time_t date; /*~PROTOBEG~ NINAC_VAL */ public: NINAC_VAL (const NINAC_VAL&v); NINAC_VAL (const char *_s); NINAC_VAL (const char *_s, time_t _date); NINAC_VAL (void); const char *c_str (void)const; time_t getmtime (void)const; /*~PROTOEND~ NINAC_VAL */ }; class NINAC_VAR: public NINAC_VAL{ std::string name; /*~PROTOBEG~ NINAC_VAR */ public: NINAC_VAR (const std::string&_name, const NINAC_VAL&_val); /*~PROTOEND~ NINAC_VAR */ }; enum NINAC_FUNC_TYPE{ NINAC_EVALFUNC,NINAC_EXECFUNC }; class NINAC_FUNCTION{ NINAC_FUNCTION *next; std::string name; unsigned nbarg; // How many extra arguments NINAC_FUNC_TYPE ftype; public: bool (*feval) (const char *, const char *, const strings &); void (*fexec) (const char *, const char *, bool pre_exec, const strings &); /*~PROTOBEG~ NINAC_FUNCTION */ public: NINAC_FUNCTION (const char *_name, bool (*_f)(const char *, const char *, const strings&), unsigned _nbarg); NINAC_FUNCTION (const char *_name, void (*_f)(const char *, const char *, bool pre_exec, const strings&) , unsigned _nbarg); const char *getname (void)const; unsigned getnbarg (void)const; NINAC_FUNCTION *getnext (void)const; NINAC_FUNC_TYPE gettype (void)const; /*~PROTOEND~ NINAC_FUNCTION */ }; class SSTRINGS; class SSTRING; class DEBUG_KEY; class SSTREAM; extern DEBUG_KEY debug_ninac; #include #include "ninac.p" #endif