Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
EventCounter.h
Go to the documentation of this file.
1#pragma once
2#include <misc/gen/Sync.h>
3#include <misc/global.h>
4
5namespace sf
6{
7
12class EventCounter : private Sync
13{
14 public:
18 typedef int handle_type;
19
24
29
35 void create(unsigned int init_val, bool countdown = false, bool blocking = false);
36
40 void destroy();
41
45 [[nodiscard]] inline handle_type getHandle() const;
46
50 void set(unsigned int increment = 1);
51
59 bool get(unsigned int& value) const;
60
65 [[nodiscard]] unsigned get() const;
66
67 private:
71 handle_type _descriptor;
72};
73
75{
76 return _descriptor;
77}
78
79inline unsigned int EventCounter::get() const
80{
81 unsigned int value;
82 get(value);
83 return value;
84}
85
86}// namespace sf
Definition EventCounter.h:13
handle_type getHandle() const
Gets the file descriptor to the object.
Definition EventCounter.h:74
EventCounter()
Default constructor.
~EventCounter()
Destructor.
unsigned get() const
Same as above but when it would block it return 0 otherwise the value is returned as described in the...
Definition EventCounter.h:79
void set(unsigned int increment=1)
Sets a new value by incrementing the existing one.
bool get(unsigned int &value) const
Gets the counter value and decrements it.
int handle_type
Handle type.
Definition EventCounter.h:18
void destroy()
Destroys the object/file descriptor.
void create(unsigned int init_val, bool countdown=false, bool blocking=false)
Creates the object annex file descriptor. Setting the initial value with 'initval'....
Sync provides a system-independent interface to build classes that act like monitors,...
Definition Sync.h:56
Definition Application.h:10