opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
app_main_loop_status.h
Go to the documentation of this file.
1#pragma once
2
3namespace osc
4{
5 // returned by `App::do_main_loop_step`
6 //
7 // callers should interpret an implicit conversion of this class to `true` as "the
8 // tick was ok". An implicit conversion to `false` should be interpreted as "something
9 // happened, you should stop stepping and maybe teardown the application loop"
11 public:
12 // returns a status that means "the step was ok, feel free to keep stepping"
13 static AppMainLoopStatus ok() { return Status::Ok; }
14
15 // returns a status that means "something _requested_ that you stop stepping"
16 //
17 // (whether you stop or not is up to you - but you should probably stop)
18 static AppMainLoopStatus quit_requested() { return Status::QuitRequested; }
19
20 explicit operator bool () const { return status_ == Status::Ok; }
21
22 private:
23 enum class Status { Ok, QuitRequested };
24
25 AppMainLoopStatus(Status status) : status_{status} {}
26
27 Status status_;
28 };
29}
Definition app_main_loop_status.h:10
static AppMainLoopStatus ok()
Definition app_main_loop_status.h:13
static AppMainLoopStatus quit_requested()
Definition app_main_loop_status.h:18
Definition custom_decoration_generator.h:5
constexpr U to(T &&value)
Definition conversion.h:56