#ifndef BASE_RULE #define BASE_RULE #include //#include "../action_engine/ActionEngine.hpp" //#include "../cond_engine/ConditionEngine.hpp" #include "types.hpp" #include "i_releaseable.hpp" #define SF_FAIL -1 #define SF_SUCCESS -2 //abstract class class BaseRule : public IReleaseable { public: //typedef BaseRule* ptrBaseRule; //parent_plan, priority, weight, flags, sticky timeout, fails, successes BaseRule(ptrSimplePlan, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int); //activate rule virtual void Activate(); //schedule for deactivation virtual void Deactivate(); //when choosen #ifndef CONDITION_ENGINE_DEBUG virtual int GetAction() = 0; #else BaseRule() { }; virtual int GetAction() { //std::cout << "Executing rule " << "\n";} #endif //force fail //virtual void Fail() = 0; //force success //virtual void Success() = 0; //rule flags enum RuleFlags { NO_FLAGS = 0, INTERRUPT_SAFE = 1, RELEASER_SAFE = 2, STICKY = 4 }; bool CheckFlags(RuleFlags); //check if rule has certain flags unsigned int GetPriority() const; unsigned int GetWeight() const; //DEBUG void out() { //if(TEST_DEBUG == true) /*std::cout << "prio: " << _priority << std::endl << "weight: " << _weight << std::endl << "flags: " << _flags << std::endl << "sttout: " << _sticky_timeout << std::endl << "fails: " << _fails << std::endl << "successes: " << _successes << std::endl;/**/ }; protected: ptrSimplePlan _parent_plan; unsigned int _priority; unsigned int _weight; unsigned int _flags; unsigned int _sticky_timeout; //in engine cycles unsigned int _fails; //default count of fails unsigned int _successes; //default count of successes unsigned int _fails_act; //actual count unsigned int _successes_act; // actual count }; #endif