Leonardus
Loading...
Searching...
No Matches
watermark.h
Go to the documentation of this file.
1
18#pragma once
19
20// Inc HAA
21#include "dbc.h"
22
23
28class Watermark {
29 size_t counter_ = 0,
33public: /* accessor */
35 size_t getCounter() const { return counter_; }
36
37
39 size_t getWatermark() const { return watermark_; }
40
41
42public: /* other */
44 void inc() {
45 if( ++counter_ > watermark_ )
47 }
48
49
53 void dec() {
54 DBC_PRE( counter_ > 0 );
55
56 counter_--;
57 }
58
59
63 void set( size_t p_size ) {
64 counter_ = p_size;
65 if( counter_ > watermark_ )
67 }
68};
Watermark class.
Definition watermark.h:28
void set(size_t p_size)
Set and check given size.
Definition watermark.h:63
size_t counter_
Counter.
Definition watermark.h:29
size_t watermark_
Watermark.
Definition watermark.h:30
size_t getWatermark() const
Getter for the watermark.
Definition watermark.h:39
void dec()
Decrement counter.
Definition watermark.h:53
size_t getCounter() const
Getter for counter.
Definition watermark.h:35
void inc()
Increment counter and watermark if neccessary.
Definition watermark.h:44
Helpers for design by contract idioms.
#define DBC_PRE(XXX)
Assert for preconditions.
Definition dbc.h:78