Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
base_thread.h
1 
2 /***************************************************************************
3  * base_thread.h - FireVision Base Thread
4  *
5  * Created: Tue May 29 16:40:10 2007
6  * Copyright 2006-2009 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 __FIREVISION_APPS_BASE_BASE_THREAD_H_
24 #define __FIREVISION_APPS_BASE_BASE_THREAD_H_
25 
26 #include <core/threading/thread.h>
27 #include <core/threading/thread_notification_listener.h>
28 #include <core/utils/lock_map.h>
29 #include <core/utils/lock_list.h>
30 
31 #include <aspect/blocked_timing.h>
32 #include <aspect/logging.h>
33 #include <aspect/vision_master.h>
34 #include <aspect/clock.h>
35 #include <aspect/thread_producer.h>
36 #include <aspect/configurable.h>
37 
38 #include <fvutils/base/vision_master.h>
39 #include <string>
40 
41 namespace fawkes {
42  class Barrier;
43 }
45 
47 : public fawkes::Thread,
49  public fawkes::LoggingAspect,
51  public fawkes::ClockAspect,
56 {
57  public:
58  FvBaseThread();
59  virtual ~FvBaseThread();
60 
61  virtual void init();
62  virtual void loop();
63  virtual void finalize();
64 
66 
67  virtual firevision::Camera * register_for_camera(const char *camera_string,
68  fawkes::Thread *thread,
69  firevision::colorspace_t cspace = firevision::YUV422_PLANAR);
70  virtual firevision::Camera * register_for_raw_camera(const char *camera_string,
71  fawkes::Thread *thread);
72  virtual void unregister_thread(fawkes::Thread *thread);
73 
74 
75  virtual firevision::CameraControl *acquire_camctrl(const char *cam_string);
77 
78  virtual bool thread_started(fawkes::Thread *thread) throw();
79  virtual bool thread_init_failed(fawkes::Thread *thread) throw();
80 
81  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
82  protected: virtual void run() { Thread::run(); }
83 
84  protected:
85  virtual firevision::CameraControl *acquire_camctrl(const char *cam_string,
86  const std::type_info &typeinf);
87 
88  private:
89  void cond_recreate_barrier(unsigned int num_cyclic_threads);
90  firevision::CameraControl * create_camctrl(const char *camera_string);
91 
92  private:
95  unsigned int __aqt_timeout;
96 
99 
100  fawkes::Barrier *__aqt_barrier;
101 };
102 
103 
104 #endif