Classes | Namespaces | Defines
TAO.h File Reference
#include "EventSystem.h"
#include "TaskResult.h"
#include <boost/function.hpp>
#include <boost/bind.hpp>
Include dependency graph for TAO.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  decision_making::___ABS__ScoppedThreadsOnExit
class  decision_making::_AllocPEMPTY
class  decision_making::_NextPEMPTY
struct  decision_making::ScoppedThreads::Cleaner
struct  decision_making::ProtocolAllocation::Cleanner
struct  decision_making::ProtocolNext::Cleanner
struct  decision_making::ProtocolAllocation::Option
struct  decision_making::ProtocolNext::Option
class  decision_making::ProtocolAllocation
class  decision_making::ProtocolNext
struct  decision_making::ScoppedThreads
class  decision_making::ScoppedThreadsOnExit
class  decision_making::TaoConditionCallback

Namespaces

namespace  decision_making

Defines

#define __CLEAN_THREAD_AND_EVENTS   decision_making::ScoppedThreads::Cleaner SUBMACHINESTHREADSCLEANER(SUBMACHINESTHREADS);
#define __DEFCALLCONTEXT   decision_making::CallContext call_ctx(parent_call_ctx?decision_making::CallContext(*parent_call_ctx, tao_name):decision_making::CallContext(tao_name));
#define __DEFEVENTQUEUE   decision_making::EventQueue* events_queue(parent_event_queue);
#define __DEFSUBCTEXT(TASK)   decision_making::ScoppedThreads::CallContextPtr call_ctx##TASK( new decision_making::CallContext(plan_call_ctx, #TASK) );
#define __DEFSUBEVENTQUEUE(TASK)   decision_making::ScoppedThreads::EventQueuePtr events_queu##TASK( new decision_making::EventQueue(events_queue) );
#define __ENDOFSTATE
#define __SHR_TO_REF(X)   (*(X.get()))
#define __STARTOFSTATE(X)
#define __TAO_FINISHER
#define _TAO_FUN_SIG   boost::function<decision_making::TaskResult(int)>
#define DMDEBUG(...)
#define TAO(NAME)
#define TAO_ALLOCATE(ProtocolName)
#define TAO_ALLOCATE_EMPTY   TAO_ALLOCATE(_AllocPEMPTY)
#define TAO_BGN
#define TAO_CALL_BT(NAME)
#define TAO_CALL_FSM(NAME)
#define TAO_CALL_TAO(NAME)
#define TAO_CALL_TASK(TASK)
#define TAO_CLEANUP_BGN
#define TAO_CLEANUP_END
#define TAO_CONTEXT   plan_call_ctx
#define TAO_DROP_EVENTS   events_queue->drop_all();
#define TAO_END
#define TAO_EVENT(EVENT)   decision_making::Event(#EVENT,plan_call_ctx)
#define TAO_EVENTS_DROP   events_queue->drop_all();
#define TAO_GO_NEXT(STATE)
#define TAO_HEADER(NAME)
#define TAO_NEXT(ProtocolName)
#define TAO_NEXT_EMPTY   TAO_NEXT(_NextPEMPTY)
#define TAO_NEXT_PLAN(BEHNAME)   protocol.add((int)BEHNAME, #BEHNAME, this_function->cond(BEHNAME).isSuccess());
#define TAO_ON_CONDITION(COND, DO)
#define TAO_ON_EVENT(EVENT, DO)
#define TAO_PLAN(X)
#define TAO_PLANS   enum TAOPLANS
#define TAO_PRINT_EVENT   if(not event.equals(decision_making::Event::SPIN_EVENT())){ cout<<" READ("<<tao_name<<":"<<event<<") "; }
#define TAO_RAISE(EVENT)
#define TAO_RESULT(EVENT, RESULT)
#define TAO_RISE(EVENT)   TAO_RAISE(EVENT)
#define TAO_START_CONDITION(CONDITION)
#define TAO_START_PLAN(STATE)
#define TAO_STOP_CONDITION(COND)
#define TAO_STOP_CONDITION_AND_PRINT_EVENTS(COND)
#define TAO_SUBPLAN(TAONAME)
#define TAO_TRANSITIONS   __CLEAN_THREAD_AND_EVENTS {Event event; while((event=events_queue->waitEvent())==true){

Define Documentation

#define __CLEAN_THREAD_AND_EVENTS   decision_making::ScoppedThreads::Cleaner SUBMACHINESTHREADSCLEANER(SUBMACHINESTHREADS);

Definition at line 342 of file TAO.h.

#define __DEFCALLCONTEXT   decision_making::CallContext call_ctx(parent_call_ctx?decision_making::CallContext(*parent_call_ctx, tao_name):decision_making::CallContext(tao_name));

Definition at line 195 of file TAO.h.

#define __DEFEVENTQUEUE   decision_making::EventQueue* events_queue(parent_event_queue);

Definition at line 196 of file TAO.h.

#define __DEFSUBCTEXT (   TASK)    decision_making::ScoppedThreads::CallContextPtr call_ctx##TASK( new decision_making::CallContext(plan_call_ctx, #TASK) );

Definition at line 285 of file TAO.h.

#define __DEFSUBEVENTQUEUE (   TASK)    decision_making::ScoppedThreads::EventQueuePtr events_queu##TASK( new decision_making::EventQueue(events_queue) );

Definition at line 284 of file TAO.h.

#define __ENDOFSTATE
Value:
DMDEBUG( struct _STATE_FINISHER_PRINT{std::string n; bool jc; _STATE_FINISHER_PRINT( std::string n, bool jc): n(n),jc(jc){}~_STATE_FINISHER_PRINT(){if(jc)return;DMDEBUG( cout<<"}"<<n<<" "; )} void r(){}}_ep(outname,justCondition);_ep.r(); )\
                struct _STATE_FINISHER{\
                        std::string plan_name; decision_making::CallContext& ctx; decision_making::EventQueue& queue; bool jc;\
                        _STATE_FINISHER(std::string plan_name, decision_making::CallContext& ctx, decision_making::EventQueue& queue, bool jc): plan_name(plan_name),ctx(ctx),queue(queue),jc(jc){}\
                        ~_STATE_FINISHER(){\
                                if(!jc){ ON_TAO_STATE_END(plan_name, ctx, queue); }\
                        } void r(){}\
                }_e(plan_name, call_ctx, *events_queue, justCondition);_e.r();

Definition at line 241 of file TAO.h.

#define __SHR_TO_REF (   X)    (*(X.get()))

Definition at line 286 of file TAO.h.

#define __STARTOFSTATE (   X)
Value:
std::string plan_name(#X);\
                decision_making::CallContext plan_call_ctx(call_ctx, plan_name);\
                if(!justCondition){\
                        DMDEBUG( string outname("STT("+tao_name+":"+call_ctx.str()+"/"+#X+")");cout<<outname<<"{ "; )\
                        ON_TAO_STATE_START(plan_name, call_ctx, *events_queue);\
                }

Definition at line 233 of file TAO.h.

#define __TAO_FINISHER
Value:
struct _tao_finisher_type{\
                        bool run;\
                        const decision_making::CallContext* parent_call_ctx;\
                        decision_making::EventQueue* parent_event_queue;\
                        _tao_finisher_type(bool run, const decision_making::CallContext* parent_call_ctx, decision_making::EventQueue* parent_event_queue):\
                                run(run),parent_call_ctx(parent_call_ctx), parent_event_queue(parent_event_queue){}\
                        ~_tao_finisher_type(){\
                                        if(!run or !parent_event_queue or !parent_call_ctx)return; \
                                        parent_event_queue->raiseEvent(decision_making::Event("SUBPLAN_FINISHED",*parent_call_ctx));\
                        }\
                } _tao_finisher(!justCondition, parent_call_ctx, parent_event_queue);\

Definition at line 197 of file TAO.h.

#define _TAO_FUN_SIG   boost::function<decision_making::TaskResult(int)>

Definition at line 79 of file TAO.h.

#define DMDEBUG (   ...)

Definition at line 16 of file TAO.h.

#define TAO (   NAME)
Value:
TAO_HEADER(NAME)\
        decision_making::TaskResult Tao##NAME##_cond(const decision_making::CallContext* p, decision_making::EventQueue* q, int tss){\
                                class Cond: public TaoConditionCallback{ } f;\
                                return Tao##NAME(p,q,#NAME, true, tss, &f);\
                        }\
        decision_making::TaskResult Tao##NAME(const decision_making::CallContext* p, decision_making::EventQueue* q){\
                                class Cond: public TaoConditionCallback{ } f;\
                                f.cond = boost::bind(&Tao##NAME##_cond, p, q, _1);\
                                return Tao##NAME(p,q,#NAME, false, -1, &f);\
                        }\
        decision_making::TaskResult Tao##NAME(\
                        const decision_making::CallContext* parent_call_ctx,\
                        decision_making::EventQueue* parent_event_queue,\
                        std::string tao_name,\
                        bool justCondition, int try_start_state, TaoConditionCallback* this_function)

Definition at line 176 of file TAO.h.

#define TAO_ALLOCATE (   ProtocolName)
Value:
{\
                        ProtocolName protocol(state,&plan_call_ctx, events_queue); \
                        __DEFSUBEVENTQUEUE(ALLOC)\
                        decision_making::ProtocolAllocation::Cleanner cleanner(protocol, SUBMACHINESTHREADS ,events_queu##ALLOC);

Definition at line 354 of file TAO.h.

#define TAO_ALLOCATE_EMPTY   TAO_ALLOCATE(_AllocPEMPTY)

Definition at line 359 of file TAO.h.

#define TAO_BGN
Value:
bool tao_stop = false; \
                while(not tao_stop and not events_queue->isTerminated() DM_SYSTEM_STOP){ \
                        switch((TAOPLANS)state){ { {

Definition at line 219 of file TAO.h.

#define TAO_CALL_BT (   NAME)
Value:
__DEFSUBEVENTQUEUE(NAME) __DEFSUBCTEXT(NAME) \
                        SUBMACHINESTHREADS.add(events_queu##NAME); \
                        SUBMACHINESTHREADS.add(call_ctx##NAME); \
                        decision_making::EventQueue& __t_events_queu##NAME = __SHR_TO_REF(events_queu##NAME);\
                        decision_making::CallContext& __t_call_ctx##NAME = __SHR_TO_REF(call_ctx##NAME);\
                        __BT_CREATE_BT_CALL_FUNCTION(NAME, __t_call_ctx##NAME, __t_events_queu##NAME)\
                        SUBMACHINESTHREADS.add(\
                                __CALL_BT_FUNCTION(NAME, boost::ref(__t_call_ctx##NAME), boost::ref(__t_events_queu##NAME))  \
                        );

Definition at line 306 of file TAO.h.

#define TAO_CALL_FSM (   NAME)
Value:
__DEFSUBEVENTQUEUE(NAME) \
                        SUBMACHINESTHREADS.add(events_queu##NAME); \
                        SUBMACHINESTHREADS.add(\
                                        new boost::thread(boost::bind(&Fsm##NAME, &call_ctx, events_queu##NAME.get())  ));

Definition at line 294 of file TAO.h.

#define TAO_CALL_TAO (   NAME)
Value:
__DEFSUBEVENTQUEUE(NAME) \
                        SUBMACHINESTHREADS.add(events_queu##NAME); \
                        SUBMACHINESTHREADS.add(\
                                        new boost::thread(boost::bind(&Tao##NAME, &call_ctx, events_queu##NAME.get())  ));

Definition at line 299 of file TAO.h.

#define TAO_CALL_TASK (   TASK)
Value:
__DEFSUBEVENTQUEUE(TASK) __DEFSUBCTEXT(TASK) \
                        SUBMACHINESTHREADS.add(events_queu##TASK); \
                        SUBMACHINESTHREADS.add(call_ctx##TASK); \
                        SUBMACHINESTHREADS.add(\
                                new boost::thread(  CALL_REMOTE(TASK, boost::ref(__SHR_TO_REF(call_ctx##TASK)), boost::ref(__SHR_TO_REF(events_queu##TASK)))  ));

Definition at line 287 of file TAO.h.

#define TAO_CLEANUP_BGN
Value:
class __ON_STATE_EXIT_STRUCT:public decision_making::ScoppedThreadsOnExit{public:\
                                __ON_STATE_EXIT_STRUCT(CallContext& call_ctx, EventQueue* events_queue):decision_making::ScoppedThreadsOnExit(call_ctx, events_queue){}\
                                virtual void exit(){

Definition at line 317 of file TAO.h.

#define TAO_CLEANUP_END
Value:
}\
                        };\
                        decision_making::ScoppedThreadsOnExit* __tmp___ON_STATE_EXIT_STRUCT = new __ON_STATE_EXIT_STRUCT(call_ctx, events_queue);\
                        SUBMACHINESTHREADS.add(decision_making::ScoppedThreads::ScoppedThreadsOnExitPtr(__tmp___ON_STATE_EXIT_STRUCT));

Definition at line 322 of file TAO.h.

#define TAO_CONTEXT   plan_call_ctx

Definition at line 251 of file TAO.h.

#define TAO_DROP_EVENTS   events_queue->drop_all();

Definition at line 383 of file TAO.h.

#define TAO_END
Value:
}}break;\
                        default: tao_stop=true; tao_result = decision_making::TaskResult::FAIL("SELECTED BEH DOES NOT EXIST") ;  break;}} \
                        if(!justCondition){\
                                DMDEBUG( cout<<" TAO("<<tao_name<<":FINISH) "; ) \
                                ON_TAO_END(tao_name, call_ctx, *events_queue, tao_result);\
                        }\
                        return tao_result;

Definition at line 224 of file TAO.h.

#define TAO_EVENT (   EVENT)    decision_making::Event(#EVENT,plan_call_ctx)

Definition at line 267 of file TAO.h.

#define TAO_EVENTS_DROP   events_queue->drop_all();

Definition at line 282 of file TAO.h.

#define TAO_GO_NEXT (   STATE)
Value:
state = STATE; \
                                break;

Definition at line 259 of file TAO.h.

#define TAO_HEADER (   NAME)
Value:
decision_making::TaskResult Tao##NAME(const decision_making::CallContext*, decision_making::EventQueue*, std::string, bool jc, int tss, TaoConditionCallback*);\
        decision_making::TaskResult Tao##NAME##_cond(const decision_making::CallContext* p, decision_making::EventQueue* q, int tss);\
        decision_making::TaskResult Tao##NAME(const decision_making::CallContext* p, decision_making::EventQueue* q);

Definition at line 171 of file TAO.h.

#define TAO_NEXT (   ProtocolName)
Value:
}} {{\
                        ProtocolName protocol(state,&plan_call_ctx, events_queue); \
                        decision_making::ProtocolNext::Cleanner cleanner(protocol);

Definition at line 345 of file TAO.h.

#define TAO_NEXT_EMPTY   TAO_NEXT(_NextPEMPTY)

Definition at line 349 of file TAO.h.

#define TAO_NEXT_PLAN (   BEHNAME)    protocol.add((int)BEHNAME, #BEHNAME, this_function->cond(BEHNAME).isSuccess());

Definition at line 351 of file TAO.h.

#define TAO_ON_CONDITION (   COND,
  DO 
)
Value:
if(COND){ \
                                DMDEBUG( cout<<" GOTO("<<tao_name<<":"<<decision_making::Event(#COND,plan_call_ctx)<< "->" #DO ") "; ) \
                                DO;\
                        }

Definition at line 269 of file TAO.h.

#define TAO_ON_EVENT (   EVENT,
  DO 
)
Value:
if(event==decision_making::Event(EVENT,plan_call_ctx)){ \
                                DMDEBUG( cout<<" GOTO("<<tao_name<<":"<<decision_making::Event(EVENT,plan_call_ctx)<< "->" #DO ") "; ) \
                                DO;\
                        }

Definition at line 262 of file TAO.h.

#define TAO_PLAN (   X)
Value:
}}}break; \
                        case X: { \
                                decision_making::ScoppedThreads SUBMACHINESTHREADS; \
                                __STARTOFSTATE(X)  __ENDOFSTATE

Definition at line 253 of file TAO.h.

#define TAO_PLANS   enum TAOPLANS

Definition at line 193 of file TAO.h.

#define TAO_PRINT_EVENT   if(not event.equals(decision_making::Event::SPIN_EVENT())){ cout<<" READ("<<tao_name<<":"<<event<<") "; }

Definition at line 385 of file TAO.h.

#define TAO_RAISE (   EVENT)
Value:
DMDEBUG( cout<<" RAISE("<<tao_name<<":"<<decision_making::Event(EVENT, plan_call_ctx)<<") "; ) \
                        events_queue->raiseEvent(decision_making::Event(EVENT, plan_call_ctx));

Definition at line 275 of file TAO.h.

#define TAO_RESULT (   EVENT,
  RESULT 
)
Value:
tao_stop=true; \
                        TAO_RAISE(EVENT); \
                        tao_result = RESULT; \
                        break;

Definition at line 328 of file TAO.h.

#define TAO_RISE (   EVENT)    TAO_RAISE(EVENT)

Definition at line 280 of file TAO.h.

#define TAO_START_CONDITION (   CONDITION)
Value:
if(justCondition){\
                        tao_stop=true; \
                        bool _l_cond_satis = (CONDITION);\
                        tao_result = _l_cond_satis ? decision_making::TaskResult::SUCCESS() : decision_making::TaskResult::FAIL(#CONDITION" is False") ; \
                        return tao_result;\
                }

Definition at line 334 of file TAO.h.

#define TAO_START_PLAN (   STATE)
Value:
; int state ( try_start_state<0? (int)STATE : try_start_state ); \
                decision_making::TaskResult tao_result = decision_making::TaskResult::TERMINATED();\
                __DEFCALLCONTEXT __DEFEVENTQUEUE __TAO_FINISHER\
                if(!justCondition){\
                        DMDEBUG( cout<<" TAO("<<tao_name<<":START) "; )\
                        ON_TAO_START(tao_name, call_ctx, *events_queue);\
                }

Definition at line 210 of file TAO.h.

#define TAO_STOP_CONDITION (   COND)
Value:
}\
                        TAO_TRANSITIONS\
                        {\
                                if(event==TAO_EVENT(SUBPLAN_FINISHED)){ break; }\
                                if(COND){ break ;}\
                        }

Definition at line 366 of file TAO.h.

Value:
}\
                        TAO_TRANSITIONS\
                        {\
                                TAO_PRINT_EVENT\
                                if(event==TAO_EVENT(SUBPLAN_FINISHED)){ break; }\
                                if(COND){ break ;}\
                        }

Definition at line 374 of file TAO.h.

#define TAO_SUBPLAN (   TAONAME)
Value:
DMDEBUG( cout<<"[ADD ROLE: "<<#TAONAME<<"]"; )\
                protocol.add(#TAONAME, Tao##TAONAME##_cond(&plan_call_ctx, events_queue, -1).isSuccess(), boost::bind(&Tao##TAONAME, &plan_call_ctx, events_queu##ALLOC.get()));

Definition at line 362 of file TAO.h.

#define TAO_TRANSITIONS   __CLEAN_THREAD_AND_EVENTS {Event event; while((event=events_queue->waitEvent())==true){

Definition at line 343 of file TAO.h.



decision_making
Author(s):
autogenerated on Wed Aug 26 2015 11:16:53