Fawkes API Fawkes Development Version
transfer_thread.h
1
2/***************************************************************************
3 * transfer_thread.h - OpenNI Visualization: network transfer thread
4 *
5 * Created: Sat Apr 02 20:00:50 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#include <core/threading/thread.h>
24
25#include <map>
26#include <string>
27
28namespace fawkes {
29class ReadWriteLock;
30}
31
32namespace firevision {
33class Camera;
34}
35
37{
38public:
41
42 void loop();
43
44 void lock_for_read();
45 void unlock();
46 void add_camera(std::string name, firevision::Camera *cam);
47
48 /** Get buffer for specified camera.
49 * @param name the name passed to add_camera.
50 * @return buffer that contains a copy of the image
51 */
52 const unsigned char *
53 buffer(std::string name)
54 {
55 return buffers_[name];
56 }
57
58private:
59 std::map<std::string, firevision::Camera *> cams_;
60 std::map<std::string, unsigned char *> buffers_;
61 std::map<std::string, size_t> buffer_sizes_;
62 fawkes::ReadWriteLock * rwlock_;
63};
PCL viewer transfer thread.
const unsigned char * buffer(std::string name)
Get buffer for specified camera.
void add_camera(std::string name, firevision::Camera *cam)
Add a camera from which to pull images.
~PclViewerTransferThread()
Destructor.
PclViewerTransferThread()
Constructor.
void loop()
Code to execute in the thread.
void lock_for_read()
Lock for reading.
Read/write lock to allow multiple readers but only a single writer on the resource at a time.
Thread class encapsulation of pthreads.
Definition: thread.h:46
const char * name() const
Get name of thread.
Definition: thread.h:100
Camera interface for image aquiring devices in FireVision.
Definition: camera.h:33
Fawkes library namespace.