roviz  0.7
Code Documentation of roviz
roviz_item.h
1 #ifndef PORTABLEITEM_H
2 #define PORTABLEITEM_H
3 
10 // TODO If one thread alone can't handle all data, spawn more threads
11 // to already start processing the next images as soon as they arrive.
12 
13 #include <string>
14 #include <memory>
15 #include <functional>
16 #include <mutex>
17 #include "core/export_handling.h"
18 #include "core/input.h"
19 #include "core/output.h"
20 #include "core/trim.h"
21 #include "core/roviz_item_p.h"
22 #include "config/config.h"
23 #include "core/template_decl.h"
24 #include "streams/stream_object.h"
25 
26 // Include the appropriate base class
27 #include ROVIZ_BASE_INCLUDE
28 
43 class ROVIZ_EXPORT RovizItem : public RovizItemBase
44 {
45 #if ROVIZ_BACKEND == ROVIZ_BACKEND_Dev
46  // The moc won't allow a portable name
47  Q_OBJECT
48 #endif
49 
50 public:
54  explicit RovizItem(std::string type_name);
55  virtual ~RovizItem();
56 
70  virtual void starting(void);
71 
81  virtual void thread(void) = 0;
82 
93  void stop(void) override;
94 
103  virtual void stopped(void);
104 
112  template<class T>
113  Input<T> addInput(std::string name);
114 
123  template<class T>
124  Output<T> addOutput(std::string name);
125 
152  bool waitForCond(std::function<bool (void)> cond);
153 
178  bool waitFor(std::function<bool (void)> cond);
179 
196  bool wait(void);
197 
214  bool running(void) const override;
215 
225  void wake(void) const;
226 
237  std::mutex &mutex(void) const;
238 
251  Trim addTrim(std::string name, double default_value, double min, double max, std::function<void (double)> notifier_func);
252 
265  Trim addTrim(std::string name, double default_value, double min, double max, bool logarithmic);
266 
280  Trim addTrim(std::string name, double default_value, double min, double max, int steps, std::function<void (double)> notifier_func);
281 
297  Trim addTrim(std::string name, double default_value, double min, double max, int steps = 0, bool logarithmic = false, std::function<void (double)> notifier_func = [](double){});
298 
313  Trim addTrim(std::string name, double default_value, double min, double max, double step_size, std::function<void (double)> notifier_func = [](double){});
314 
325  template<class T>
326  Config<T> addConfig(const std::string &name, const typename ConfigStorageType<T>::type &default_value, int min, int max, bool restart_when_changed = false);
327 
338  template<class T>
339  Config<T> addConfig(const std::string &name, const typename ConfigStorageType<T>::type &default_value, double min, double max, bool restart_when_changed = false);
340 
351  template<class T>
352  Config<T> addConfig(const std::string &name, const typename ConfigStorageType<T>::type &default_value, std::function<bool (std::string&)> checker = [](std::string &){return true;}, bool restart_when_changed = false);
353 
363  template<class T>
364  Config<T> addConfig(const std::string &name, const typename ConfigStorageType<T>::type &default_index, const std::list<std::string> &possibilities, bool restart_when_changed = false);
365 
374  template<class T>
375  Config<T> addConfig(const std::string &name, const typename ConfigStorageType<T>::type &default_value, bool restart_when_changed = false);
376 
387  template<class T>
388  Config<T> addConfig(const std::string &name, const typename ConfigStorageType<T>::type &default_value, enum FilePath::Mode file_mode, const std::string &filter, bool restart_when_changed = false);
389 
390 private:
391  std::unique_ptr<RovizItemPrivate> _this;
392 
402 
412  void start(void) override;
413 
421  void pause(void) override;
422 
426  void join(void) override;
427 
435  void unpause(void) override;
437 };
438 
439 #endif // PORTABLEITEM_H
Storage for the configuration of an item.
Definition: config.h:20
Represents the output of an item.
Definition: output.h:18
A value that can be trimmed at runtime.
Definition: trim.h:21
Represents the input of an item.
Definition: input.h:19
Base class for all items that use the roviz framework.
Definition: roviz_item.h:43