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
30 size_t counter_ = 0,
34public: /* accessor */
36 size_t getCounter() const { return counter_; }
37
38
40 size_t getWatermark() const { return watermark_; }
41
42
43public: /* other */
45 void inc() {
46 if( ++counter_ > watermark_ )
48 }
49
50
53 void dec() {
54 DBC_PRE( counter_ > 0 );
55
56 counter_--;
57 }
58
59
62 void set( size_t p_size ) {
63 counter_ = p_size;
64 if( counter_ > watermark_ )
66 }
67};
Watermark class.
Definition watermark.h:28
void set(size_t p_size)
Set and check given size.
Definition watermark.h:62
size_t counter_
Counter.
Definition watermark.h:30
size_t watermark_
Watermark.
Definition watermark.h:31
size_t getWatermark() const
Getter for the watermark.
Definition watermark.h:40
void dec()
Decrement counter.
Definition watermark.h:53
size_t getCounter() const
Getter for counter.
Definition watermark.h:36
void inc()
Increment counter and watermark if neccessary.
Definition watermark.h:45
Helpers for design by contract idioms.
#define DBC_PRE(XXX)
Assert for preconditions.
Definition dbc.h:103