Fawkes API Fawkes Development Version
naoqi_inifin.cpp
1
2/***************************************************************************
3 * naoqi_inifin.cpp - Fawkes NaoQiAspect initializer/finalizer
4 *
5 * Created: Thu May 12 15:54:02 2011
6 * Copyright 2006-2011 Tim Niemueller [www.niemueller.de]
7 *
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 <plugins/nao/aspect/naoqi_inifin.h>
26
27namespace fawkes {
28
29/** @class NaoQiAspectIniFin <plugins/nao/aspect/naoqi_inifin.h>
30 * NaoQiAspect initializer/finalizer.
31 * This initializer/finalizer will provide the NaoQi broker to threads
32 * with the NaoQiAspect.
33 * @author Tim Niemueller
34 */
35
36/** Constructor. */
38{
39}
40
41void
43{
44 NaoQiAspect *naoqi_thread;
45 naoqi_thread = dynamic_cast<NaoQiAspect *>(thread);
46 if (naoqi_thread == NULL) {
47 throw CannotInitializeThreadException("Thread '%s' claims to have the "
48 "NaoQiAspect, but RTTI says it "
49 "has not. ",
50 thread->name());
51 }
52 if (!naoqi_broker_) {
53 throw CannotInitializeThreadException("NaoQi broker has not been set.");
54 }
55
56 naoqi_thread->init_NaoQiAspect(naoqi_broker_);
57}
58
59void
61{
62}
63
64/** Set the NaoQi broker to use for aspect initialization.
65 * @param naoqi_broker NaoQi broker to pass to threads with NaoQiAspect.
66 */
67void
68NaoQiAspectIniFin::set_naoqi_broker(AL::ALPtr<AL::ALBroker> naoqi_broker)
69{
70 naoqi_broker_ = naoqi_broker;
71}
72
73} // end namespace fawkes
Aspect initializer/finalizer base class.
Definition: inifin.h:34
void set_naoqi_broker(AL::ALPtr< AL::ALBroker > naoqi_broker)
Set the NaoQi broker to use for aspect initialization.
NaoQiAspectIniFin()
Constructor.
virtual void finalize(Thread *thread)
Finalize thread.
virtual void init(Thread *thread)
Initialize thread.
Thread aspect to get access to NaoQi broker.
Definition: naoqi.h:36
Thread class encapsulation of pthreads.
Definition: thread.h:46
const char * name() const
Get name of thread.
Definition: thread.h:100
Fawkes library namespace.