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 <plugins/openrave/aspect/openrave_inifin.h>
25 #include <plugins/openrave/aspect/openrave.h>
26 #include <plugins/openrave/aspect/openrave_connector.h>
27 
28 #include <core/threading/thread_finalizer.h>
29 
30 namespace fawkes {
31 #if 0 /* just to make Emacs auto-indent happy */
32 }
33 #endif
34 
35 /** @class OpenRaveAspectIniFin <plugins/openrave/aspect/openrave_inifin.h>
36  * OpenRaveAspect initializer/finalizer.
37  * This initializer/finalizer will provide the OpenRaveConnector to threads with
38  * the OpenRaveAspect.
39  * @author Bahram Maleki-Fard
40  */
41 
42 /** Constructor.
43  * @param openrave OpenRaveConnector to pass on to threads
44  */
46  : AspectIniFin("OpenRaveAspect")
47 {
48  __openrave = openrave;
49 }
50 
51 void
53 {
54  OpenRaveAspect *or_thread;
55 
56  or_thread = dynamic_cast<OpenRaveAspect *>(thread);
57  if (or_thread == NULL) {
58  throw CannotInitializeThreadException("Thread '%s' claims to have the "
59  "OpenRaveAspect, but RTTI says it "
60  "has not. ", thread->name());
61  }
62 
63  or_thread->init_OpenRaveAspect(__openrave);
64 }
65 
66 void
68 {
69 }
70 
71 
72 
73 } // end namespace fawkes
Fawkes library namespace.
Thread class encapsulation of pthreads.
Definition: thread.h:42
Thread aspect create, update, and graph round-robin databases (RRD).
Definition: openrave.h:35
Thread cannot be initialized.
const char * name() const
Get name of thread.
Definition: thread.h:95
Interface for a OpenRave connection creator.
OpenRaveAspectIniFin(OpenRaveConnector *openrave)
Constructor.
virtual void finalize(Thread *thread)
Finalize thread.
virtual void init(Thread *thread)
Initialize thread.
Aspect initializer/finalizer base class.
Definition: inifin.h:36