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 
28 namespace fawkes {
29  class ReadWriteLock;
30 }
31 
32 namespace firevision {
33  class Camera;
34 }
35 
37 {
38  public:
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 * buffer(std::string name)
53  { return __buffers[name]; }
54 
55  private:
56  std::map<std::string, firevision::Camera *> __cams;
57  std::map<std::string, unsigned char *> __buffers;
58  std::map<std::string, size_t> __buffer_sizes;
59  fawkes::ReadWriteLock *__rwlock;
60 };
Camera interface for image aquiring devices in FireVision.
Definition: camera.h:35
Fawkes library namespace.
Thread class encapsulation of pthreads.
Definition: thread.h:42
Read/write lock to allow multiple readers but only a single writer on the resource at a time...
const unsigned char * buffer(std::string name)
Get buffer for specified camera.
PCL viewer transfer thread.