BcPOC
SF-HRP ASM implementation
D:/bcatch/bcpoc_src/bcpoc/src/sfhrp/SFHRP/simple_plan.hpp
Go to the documentation of this file.
00001 #ifndef _HR_PLAN_
00002 #define _HR_PLAN_
00003 
00004 #include <list>
00005 #include <vector>
00006 #include <cstdlib>
00007 
00008 #include "types.hpp"
00009 //#include "../action_engine/ActionEngine.hpp"
00010 
00011 #include "base_rule.hpp"
00012 #include "rule_queue.hpp"
00013 #include "base_rule_order.hpp"
00014 #include "i_engine_descriptor.hpp"
00015 
00016 //class BaseRule;
00017 
00018 
00019 class SimplePlan {
00020 public:
00021 
00022         /*
00023          * Ctor
00024          */
00025         SimplePlan( ptrReactivePlanner, IEngineDescriptor* engine);
00026 
00027         /*
00028          * Dtor
00029          */
00030         ~SimplePlan();
00031 
00032         //priority, weight, action, flags, sticky_timeout, fails, successes
00033         ptrBaseRule AddActionRule(std::string &, unsigned int, unsigned int, std::vector< int> &,
00034                 unsigned int, unsigned int, unsigned int, unsigned int);
00035 
00036         //priority, weight, plan, flags, sticky_timeout, fails, successes
00037         ptrBaseRule AddPlanRule(unsigned int, unsigned int, ptrSimplePlan,
00038                 unsigned int, unsigned int, unsigned int, unsigned int);
00039 
00040         //priority, weight, flags, sticky_timeout, fails, successes
00041         ptrBaseRule AddFailRule(std::string &, unsigned int, unsigned int, unsigned int,
00042                 unsigned int, unsigned int, unsigned int);
00043 
00044         //priority, weight, flags, sticky_timeout, fails, successes
00045         ptrBaseRule AddSuccessRule(std::string &, unsigned int, unsigned int, unsigned int,
00046                 unsigned int, unsigned int, unsigned int);
00047 
00048 
00049         //ASM method    
00050         int GetAction();
00051 
00052         friend void BaseRule::Activate();
00053         friend void BaseRule::Deactivate();
00054 
00055 protected:
00056         typedef std::list<ptrBaseRule> ruleList;
00057         typedef RuleQueue<ptrBaseRule, BaseRuleOrder> RuleQueueType;
00058 
00059         ptrReactivePlanner _planner;
00060 
00061         ruleList _rule_list;
00062         RuleQueueType _active_rules;
00063 
00064         //rule scheduling & flag hnadling methods
00065         void _activate_rule( ptrBaseRule);
00066         void _deactivate_rule( ptrBaseRule); 
00067 
00068         //_active_rules queue handling
00069         void _activate( ptrBaseRule);
00070         void _deactivate( ptrBaseRule);
00071 
00072         // releaser safe scheduling
00073         ptrBaseRule _rsrule_deactiv_sched;
00074         
00075         IEngineDescriptor* _engine;
00076 
00077 };
00078 
00079 #endif
00080