Fawkes API Fawkes Development Version
action_executor_dispatcher_inifin.cpp
1/***************************************************************************
2 * action_executor_dispatcher_inifin.cpp - Inifin for the Golog++ Executor
3 *
4 * Created: Sat 12 Oct 2019 12:14:27 CEST 12:14
5 * Copyright 2019 Till Hofmann <hofmann@kbsg.rwth-aachen.de>
6 ****************************************************************************/
7
8/* This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Library General Public License for more details.
17 *
18 * Read the full text in the LICENSE.GPL file in the doc directory.
19 */
20
21#include "action_executor_dispatcher_inifin.h"
22
23namespace fawkes {
24
25/** @class GologppDispatcherAspectIniFin
26 * The initializer/finalizer for the GologppDispatcherAspect.
27 * This AspectIniFin is responsible for creating the dispatcher,
28 * which can then be used by all executors.
29 */
30
31/** Constructor. */
33: AspectIniFin("GologppDispatcherAspect")
34{
35 dispatcher_ = new gpp::ActionExecutorDispatcher();
36}
37
38/** Destructor*. */
40{
41 delete dispatcher_;
42}
43
45GologppDispatcherAspectIniFin::get_aspect(Thread *thread) const
46{
47 GologppDispatcherAspect *exec_thread = dynamic_cast<GologppDispatcherAspect *>(thread);
48 if (!exec_thread) {
50 "Thread '%s' claims to have the GologppDispatcherAspect, but RRTI says it has not.",
51 thread->name());
52 }
53 return exec_thread;
54}
55
56/** Initialize the thread with the aspect.
57 * This initializes the given thread with the dispatcher.
58 * @param thread The thread to initialize.
59 */
60void
62{
63 auto exec_thread = get_aspect(thread);
64 exec_thread->init_GologppDispatcherAspect(dispatcher_);
65}
66
67/** Finalize the aspect of the given thread.
68 * @param thread The thread to finalize.
69 */
70void
72{
73 auto exec_thread = get_aspect(thread);
75}
76
77} // namespace fawkes
Aspect initializer/finalizer base class.
Definition: inifin.h:34
virtual void init(Thread *thread)
Initialize the thread with the aspect.
virtual void finalize(Thread *thread)
Finalize the aspect of the given thread.
An aspect that provides access to the Golog++ Action Executor Dispatcher.
void init_GologppDispatcherAspect(gpp::ActionExecutorDispatcher *dispatcher)
Init GologppDispatcherAspect.
void finalize_GologppDispatcherAspect()
Finalize the GologppDispatcherAspect.
Thread class encapsulation of pthreads.
Definition: thread.h:46
const char * name() const
Get name of thread.
Definition: thread.h:100
Dispatch an activity to a number of registered executors by checking all registered executors subsequ...
Fawkes library namespace.