Fawkes API Fawkes Development Version
navgraph_inifin.cpp
1
2/***************************************************************************
3 * navgraph_inifin.cpp - Fawkes NavGraphAspect initializer/finalizer
4 *
5 * Created: Mon Dec 06 22:33:03 2010
6 * Copyright 2006-2010 Tim Niemueller [www.niemueller.de]
7 * 2014 Sebastian Reuter
8 ****************************************************************************/
9
10/* This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. A runtime exception applies to
14 * this software (see LICENSE.GPL_WRE file mentioned below for details).
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Library General Public License for more details.
20 *
21 * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22 */
23
24#include <core/threading/thread_finalizer.h>
25#include <navgraph/aspect/navgraph.h>
26#include <navgraph/aspect/navgraph_inifin.h>
27#include <navgraph/navgraph.h>
28
29#include <cstddef>
30
31namespace fawkes {
32
33/** @class NavGraphAspectIniFin <navgraph/aspect/navgraph_inifin.h>
34 * NavGraphAspect initializer/finalizer.
35 * @author Tim Niemueller
36 */
37
38/** Constructor. */
40{
41}
42
43/** Set navgraph.
44 * @param navgraph navgraph to pass to thread with the NavGraphAspect
45 */
46void
48{
49 navgraph_ = navgraph;
50}
51
52void
54{
55 NavGraphAspect *navgraph_thread;
56 navgraph_thread = dynamic_cast<NavGraphAspect *>(thread);
57 if (navgraph_thread == NULL) {
58 throw CannotInitializeThreadException("Thread '%s' claims to have the "
59 "NavGraphAspect, but RTTI says it "
60 "has not. ",
61 thread->name());
62 }
63
64 navgraph_thread->navgraph = navgraph_;
65}
66
67void
69{
70 NavGraphAspect *navgraph_thread;
71 navgraph_thread = dynamic_cast<NavGraphAspect *>(thread);
72 if (navgraph_thread == NULL) {
73 throw CannotFinalizeThreadException("Thread '%s' claims to have the "
74 "NavGraphAspect, but RTTI says it "
75 "has not. ",
76 thread->name());
77 }
78
79 navgraph_thread->navgraph.clear();
80}
81
82} // end namespace fawkes
Aspect initializer/finalizer base class.
Definition: inifin.h:34
Thread cannot be finalized.
LockPtr<> is a reference-counting shared lockable smartpointer.
Definition: lockptr.h:55
virtual void finalize(Thread *thread)
Finalize thread.
void set_navgraph(LockPtr< NavGraph > &navgraph)
Set navgraph.
virtual void init(Thread *thread)
Initialize thread.
Thread aspect to access NavGraph.
Definition: navgraph.h:36
fawkes::LockPtr< NavGraph > navgraph
NavGraph instance shared in framework.
Definition: navgraph.h:44
Thread class encapsulation of pthreads.
Definition: thread.h:46
const char * name() const
Get name of thread.
Definition: thread.h:100
Fawkes library namespace.