Fawkes API  Fawkes Development Version
openrave_inifin.cpp
1 
2 /***************************************************************************
3  * openrave_inifin.cpp - Fawkes OpenRaveAspect initializer/finalizer
4  *
5  * Created: Fri Feb 25 15:08:00 2011
6  * Copyright 2011 Bahram Maleki-Fard
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/openrave/aspect/openrave.h>
26 #include <plugins/openrave/aspect/openrave_connector.h>
27 #include <plugins/openrave/aspect/openrave_inifin.h>
28 
29 namespace fawkes {
30 
31 /** @class OpenRaveAspectIniFin <plugins/openrave/aspect/openrave_inifin.h>
32  * OpenRaveAspect initializer/finalizer.
33  * This initializer/finalizer will provide the OpenRaveConnector to threads with
34  * the OpenRaveAspect.
35  * @author Bahram Maleki-Fard
36  */
37 
38 /** Constructor.
39  * @param openrave OpenRaveConnector to pass on to threads
40  */
41 OpenRaveAspectIniFin::OpenRaveAspectIniFin(OpenRaveConnector *openrave)
42 : AspectIniFin("OpenRaveAspect")
43 {
44  openrave_ = openrave;
45 }
46 
47 void
49 {
50  OpenRaveAspect *or_thread;
51 
52  or_thread = dynamic_cast<OpenRaveAspect *>(thread);
53  if (or_thread == NULL) {
54  throw CannotInitializeThreadException("Thread '%s' claims to have the "
55  "OpenRaveAspect, but RTTI says it "
56  "has not. ",
57  thread->name());
58  }
59 
60  or_thread->init_OpenRaveAspect(openrave_);
61 }
62 
63 void
64 OpenRaveAspectIniFin::finalize(Thread *thread)
65 {
66 }
67 
68 } // end namespace fawkes
fawkes::OpenRaveAspectIniFin::OpenRaveAspectIniFin
OpenRaveAspectIniFin(OpenRaveConnector *openrave)
Constructor.
Definition: openrave_inifin.cpp:47
fawkes::CannotInitializeThreadException
Definition: thread_initializer.h:39
fawkes::Thread::name
const char * name() const
Definition: thread.h:100
fawkes
fawkes::Thread
Definition: thread.h:45
fawkes::OpenRaveAspectIniFin::finalize
virtual void finalize(Thread *thread)
Definition: openrave_inifin.cpp:70
fawkes::OpenRaveAspectIniFin::init
virtual void init(Thread *thread)
Definition: openrave_inifin.cpp:54
fawkes::OpenRaveAspect
Definition: openrave.h:40