Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
sf::EventCounter Class Reference

#include <EventCounter.h>

Inheritance diagram for sf::EventCounter:
Collaboration diagram for sf::EventCounter:

Public Types

typedef int handle_type
 Handle type.
 

Public Member Functions

 EventCounter ()
 Default constructor.
 
 ~EventCounter ()
 Destructor.
 
void create (unsigned int initval, bool countdown=false, bool blocking=false)
 Creates the object annex file descriptor. Setting the initial value with 'initval'. When countdown is true the get() function will countdown the counter one by one and the return value is each time 0.
 
void destroy ()
 Destroys the object/file descriptor.
 
handle_type getHandle () const
 
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. Returns true when it would block when blocking is disabled. When counting down was enabled the returned value is always 1 until the internal counter is zero. When not counting down the returned argument value is the counter value and the internal counter is reset to zero.
 
unsigned get () const
 Same as above but when the would block it return 0 otherwise the value is returned as described in the get() method.
 

Detailed Description

TEventSemaphore class is build around the system call eventfd(). This class has a file descriptor which could be used in an epoll object.

Member Typedef Documentation

◆ handle_type

Handle type.

Constructor & Destructor Documentation

◆ EventCounter()

sf::EventCounter::EventCounter ( )

Default constructor.

◆ ~EventCounter()

sf::EventCounter::~EventCounter ( )

Destructor.

Member Function Documentation

◆ create()

void sf::EventCounter::create ( unsigned int  initval,
bool  countdown = false,
bool  blocking = false 
)

Creates the object annex file descriptor. Setting the initial value with 'initval'. When countdown is true the get() function will countdown the counter one by one and the return value is each time 0.

◆ destroy()

void sf::EventCounter::destroy ( )

Destroys the object/file descriptor.

◆ get() [1/2]

unsigned int sf::EventCounter::get ( ) const
inline

Same as above but when the would block it return 0 otherwise the value is returned as described in the get() method.

◆ get() [2/2]

bool sf::EventCounter::get ( unsigned int &  value) const

Gets the counter value and decrements it. Returns true when it would block when blocking is disabled. When counting down was enabled the returned value is always 1 until the internal counter is zero. When not counting down the returned argument value is the counter value and the internal counter is reset to zero.

◆ getHandle()

EventCounter::handle_type sf::EventCounter::getHandle ( ) const
inline

Returns the file descriptor to the object.

◆ set()

void sf::EventCounter::set ( unsigned int  increment = 1)

Sets a new value by incrementing the existing one.

Returns
On failure to do so it returns false.

The documentation for this class was generated from the following file: