Fawkes API Fawkes Development Version
openni_inifin.cpp
1
2/***************************************************************************
3 * openni_inifin.cpp - Fawkes OpenNiAspect initializer/finalizer
4 *
5 * Created: Sat Feb 26 15:42:56 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/openni/aspect/openni_inifin.h>
26
27#include <XnCppWrapper.h>
28
29namespace fawkes {
30
31/** @class OpenNiAspectIniFin <plugins/openni/aspect/openni_inifin.h>
32 * OpenNiAspect initializer/finalizer.
33 * This initializer/finalizer will provide the OpenNI context to threads
34 * with the OpenNiAspect.
35 * @author Tim Niemueller
36 */
37
38/** Constructor. */
40{
41}
42
43void
45{
46 OpenNiAspect *openni_thread;
47 openni_thread = dynamic_cast<OpenNiAspect *>(thread);
48 if (openni_thread == NULL) {
49 throw CannotInitializeThreadException("Thread '%s' claims to have the "
50 "OpenNiAspect, but RTTI says it "
51 "has not. ",
52 thread->name());
53 }
54 if (!openni_context_) {
55 throw CannotInitializeThreadException("OpenNI context has not been set.");
56 }
57
58 openni_thread->init_OpenNiAspect(openni_context_);
59}
60
61void
63{
64}
65
66/** Set the OpenNI context to use for aspect initialization.
67 * @param openni_context OpenNI context to pass to threads with OpenNiAspect.
68 */
69void
71{
72 openni_context_ = openni_context;
73}
74
75} // end namespace fawkes
Aspect initializer/finalizer base class.
Definition: inifin.h:34
void set_openni_context(LockPtr< xn::Context > openni_context)
Set the OpenNI context to use for aspect initialization.
virtual void finalize(Thread *thread)
Finalize thread.
OpenNiAspectIniFin()
Constructor.
virtual void init(Thread *thread)
Initialize thread.
Thread aspect to get access to the OpenNI context.
Definition: openni.h:39
Thread class encapsulation of pthreads.
Definition: thread.h:46
const char * name() const
Get name of thread.
Definition: thread.h:100
Fawkes library namespace.