Fawkes API  Fawkes Development Version
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 <aspect/blocked_timing.h>
27 #include <aspect/clock.h>
28 #include <aspect/configurable.h>
29 #include <aspect/logging.h>
30 #include <aspect/thread_producer.h>
31 #include <aspect/vision_master.h>
32 #include <core/threading/thread.h>
33 #include <core/threading/thread_notification_listener.h>
34 #include <core/utils/lock_list.h>
35 #include <core/utils/lock_map.h>
36 #include <fvutils/base/vision_master.h>
37 
38 #include <string>
39 
40 namespace fawkes {
41 class Barrier;
42 }
44 
47  public fawkes::LoggingAspect,
49  public fawkes::ClockAspect,
54 {
55 public:
56  FvBaseThread();
57  virtual ~FvBaseThread();
58 
59  virtual void init();
60  virtual void loop();
61  virtual void finalize();
62 
64 
65  virtual firevision::Camera *
66  register_for_camera(const char * camera_string,
67  fawkes::Thread * thread,
68  firevision::colorspace_t cspace = firevision::YUV422_PLANAR);
69  virtual firevision::Camera *register_for_raw_camera(const char * camera_string,
70  fawkes::Thread *thread);
71  virtual void unregister_thread(fawkes::Thread *thread);
72 
73  virtual firevision::CameraControl *acquire_camctrl(const char *cam_string);
75 
76  virtual bool thread_started(fawkes::Thread *thread) throw();
77  virtual bool thread_init_failed(fawkes::Thread *thread) throw();
78 
79  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
80 protected:
81  virtual void
82  run()
83  {
84  Thread::run();
85  }
86 
87 protected:
88  virtual firevision::CameraControl *acquire_camctrl(const char * cam_string,
89  const std::type_info &typeinf);
90 
91 private:
92  void cond_recreate_barrier(unsigned int num_cyclic_threads);
93  firevision::CameraControl *create_camctrl(const char *camera_string);
94 
95 private:
98  unsigned int aqt_timeout_;
99 
102 
103  fawkes::Barrier *aqt_barrier_;
104 };
105 
106 #endif
FireVision base application acquisition thread.
FireVision base thread.
Definition: base_thread.h:54
virtual void release_camctrl(firevision::CameraControl *cc)
Release a camera control.
virtual ~FvBaseThread()
Destructor.
Definition: base_thread.cpp:66
virtual firevision::VisionMaster * vision_master()
Get vision master.
virtual firevision::CameraControl * acquire_camctrl(const char *cam_string)
Retrieve a CameraControl for the specified camera string.
virtual bool thread_init_failed(fawkes::Thread *thread)
Thread initialization failed.
virtual void loop()
Thread loop.
FvBaseThread()
Constructor.
Definition: base_thread.cpp:55
virtual void unregister_thread(fawkes::Thread *thread)
Unregister a thread.
virtual void finalize()
Finalize the thread.
Definition: base_thread.cpp:81
virtual bool thread_started(fawkes::Thread *thread)
Thread started successfully.
virtual firevision::Camera * register_for_raw_camera(const char *camera_string, fawkes::Thread *thread)
Register thread for camera.
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: base_thread.h:82
virtual firevision::Camera * register_for_camera(const char *camera_string, fawkes::Thread *thread, firevision::colorspace_t cspace=firevision::YUV422_PLANAR)
Register thread for camera.
virtual void init()
Initialize the thread.
Definition: base_thread.cpp:72
A barrier is a synchronization tool which blocks until a given number of threads have reached the bar...
Definition: barrier.h:32
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
Thread notification listener interface.
Aspect for thread producing threads.
Thread class encapsulation of pthreads.
Definition: thread.h:46
Vision Master Aspect.
Definition: vision_master.h:36
Camera control interface base class.
Definition: control.h:31
Camera interface for image aquiring devices in FireVision.
Definition: camera.h:33
Fawkes library namespace.