summaryrefslogtreecommitdiff
path: root/include/erebos/service.h
blob: 7e037f8c685ebfc52ddb11053cddea70971b1283 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once

#include <erebos/state.h>
#include <erebos/uuid.h>

#include <memory>

namespace erebos {

class Server;

class Service
{
public:
	Service();
	virtual ~Service();

	using Config = monostate;

	class Context
	{
	public:
		struct Priv;
		Context(Priv *);
		Priv & priv();

		const class Ref & ref() const;
		const class Peer & peer() const;

		const Stored<LocalState> & local() const;
		void local(const LocalState &);

		void afterCommit(function<void()>);
		void runAfterCommitHooks() const;

	private:
		std::unique_ptr<Priv> p;
	};

	virtual UUID uuid() const = 0;
	virtual void handle(Context &) = 0;
};

}