17 #ifndef CYBER_CROUTINE_ROUTINE_FACTORY_H_ 18 #define CYBER_CROUTINE_ROUTINE_FACTORY_H_ 42 inline void SetDataVisitor(
const std::shared_ptr<data::DataVisitorBase>& dv) {
47 std::shared_ptr<data::DataVisitorBase> data_visitor_ =
nullptr;
50 template <
typename M0,
typename F>
57 std::shared_ptr<M0> msg;
60 if (dv->TryFetch(msg)) {
72 template <
typename M0,
typename M1,
typename F>
79 std::shared_ptr<M0> msg0;
80 std::shared_ptr<M1> msg1;
83 if (dv->TryFetch(msg0, msg1)) {
95 template <
typename M0,
typename M1,
typename M2,
typename F>
102 std::shared_ptr<M0> msg0;
103 std::shared_ptr<M1> msg1;
104 std::shared_ptr<M2> msg2;
107 if (dv->TryFetch(msg0, msg1, msg2)) {
119 template <
typename M0,
typename M1,
typename M2,
typename M3,
typename F>
126 std::shared_ptr<M0> msg0;
127 std::shared_ptr<M1> msg1;
128 std::shared_ptr<M2> msg2;
129 std::shared_ptr<M3> msg3;
132 if (dv->TryFetch(msg0, msg1, msg2, msg3)) {
133 f(msg0, msg1, msg2, msg3);
144 template <
typename Function>
147 factory.
create_routine = [f = std::forward<Function&&>(f)]() {
return f; };
155 #endif // CYBER_CROUTINE_ROUTINE_FACTORY_H_ CreateRoutineFunc create_routine
Definition: routine_factory.h:38
void SetDataVisitor(const std::shared_ptr< data::DataVisitorBase > &dv)
Definition: routine_factory.h:42
RoutineFactory CreateRoutineFactory(F &&f, const std::shared_ptr< data::DataVisitor< M0 >> &dv)
Definition: routine_factory.h:51
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
static CRoutine * GetCurrentRoutine()
Definition: croutine.h:135
Definition: routine_factory.h:33
std::function< void()> VoidFunc
Definition: routine_factory.h:35
static void Yield()
Definition: croutine.h:131
void set_state(const RoutineState &state)
Definition: croutine.h:145
std::function< VoidFunc()> CreateRoutineFunc
Definition: routine_factory.h:36
std::shared_ptr< data::DataVisitorBase > GetDataVisitor() const
Definition: routine_factory.h:39
Definition: data_visitor.h:48