Fawkes API Fawkes Development Version
context_thread.h
1
2/***************************************************************************
3 * context_thread.h - OpenNI context providing thread
4 *
5 * Created: Sat Feb 26 15:23:16 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.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Library General Public License for more details.
19 *
20 * Read the full text in the LICENSE.GPL file in the doc directory.
21 */
22
23#ifndef _PLUGINS_OPENNI_CONTEXT_THREAD_H_
24#define _PLUGINS_OPENNI_CONTEXT_THREAD_H_
25
26#include <aspect/aspect_provider.h>
27#include <aspect/blocked_timing.h>
28#include <aspect/clock.h>
29#include <aspect/configurable.h>
30#include <aspect/logging.h>
31#include <core/threading/thread.h>
32#include <core/utils/lockptr.h>
33#include <plugins/openni/aspect/openni_inifin.h>
34#include <sys/types.h>
35#include <utils/time/time.h>
36
37#include <map>
38#include <string>
39
40namespace xn {
41class Context;
42class Device;
43} // namespace xn
44
51{
52public:
54 virtual ~OpenNiContextThread();
55
56 virtual void init();
57 virtual void loop();
58 virtual void finalize();
59
60private:
61 void print_nodes();
62 void verify_active();
63 void start_sensor_server();
64 void stop_sensor_server();
65
66 /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
67protected:
68 virtual void
70 {
71 Thread::run();
72 }
73
74private:
76 fawkes::OpenNiAspectIniFin openni_aspect_inifin_;
77
78 bool cfg_run_sensor_server_;
79 std::string cfg_sensor_bin_;
80 pid_t sensor_server_pid_;
81 xn::Device *device_;
82
83 int last_refcount_;
84
85 fawkes::Time check_last_;
86 fawkes::Time check_now_;
87
88 unsigned int device_no_data_loops_;
89
90 std::map<std::string, unsigned int> dead_loops_;
91};
92
93#endif
OpenNI Context Thread.
OpenNiContextThread()
Constructor.
virtual void init()
Initialize the thread.
virtual void loop()
Code to execute in the thread.
virtual ~OpenNiContextThread()
Destructor.
virtual void run()
Stub to see name in backtrace for easier debugging.
virtual void finalize()
Finalize the thread.
Thread aspect provide a new aspect.
Thread aspect to use blocked timing.
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:34
Thread aspect to access configuration data.
Definition: configurable.h:33
Thread aspect to log output.
Definition: logging.h:33
OpenNiAspect initializer/finalizer.
Definition: openni_inifin.h:33
Thread class encapsulation of pthreads.
Definition: thread.h:46
A class for handling time.
Definition: time.h:93