-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScriptRepo.hpp
96 lines (65 loc) · 1.96 KB
/
ScriptRepo.hpp
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#ifndef ___INANITY_OIL_SCRIPT_REPO_HPP___
#define ___INANITY_OIL_SCRIPT_REPO_HPP___
#include "oil.hpp"
#include "../inanity/script/np/np.hpp"
#include "../inanity/meta/decl.hpp"
#include <vector>
BEGIN_INANITY
class File;
END_INANITY
BEGIN_INANITY_SCRIPT
class Any;
END_INANITY_SCRIPT
BEGIN_INANITY_NP
class Any;
END_INANITY_NP
BEGIN_INANITY_OIL
class ClientRepo;
class RemoteRepo;
class EntityManager;
class Action;
/// Class which combines client and remote repos.
/** Mainly intended to interact with script. */
class ScriptRepo : public Object
{
private:
ptr<ClientRepo> clientRepo;
ptr<RemoteRepo> remoteRepo;
ptr<EntityManager> entityManager;
std::vector<ptr<Action> > undoActions;
std::vector<ptr<Action> > redoActions;
ptr<Script::Np::Any> undoRedoChangedCallback;
class InitHandler;
class PullHandler;
class WatchHandler;
void ApplyAction(ptr<Action> action);
ptr<Action> ReverseAction(ptr<Action> action);
void FireUndoRedoChangedCallback();
void OnChange(ptr<File> key, ptr<File> value);
public:
ScriptRepo(ptr<ClientRepo> clientRepo, ptr<RemoteRepo> remoteRepo, ptr<EntityManager> entityManager);
ptr<EntityManager> GetEntityManager() const;
void Init(ptr<Script::Any> callback);
void Sync(ptr<Script::Any> callback);
void Watch(ptr<Script::Any> callback);
void ProcessEvents();
void Change(ptr<File> key, ptr<File> value);
/// Subscribe for changes in keys with specified prefix.
/** \param callback function(key, flags) */
void Subscribe(ptr<File> prefix, ptr<Script::Any> callback);
/// Make undoable action.
void MakeAction(ptr<Action> action);
/// Undo action from stack.
bool Undo();
/// Redo action from stack.
bool Redo();
void SetUndoRedoChangedCallback(ptr<Script::Any> callback);
long long GetPushLag() const;
long long GetPushedKeysCount() const;
long long GetPullLag() const;
long long GetPulledKeysCount() const;
ptr<ClientRepo> GetClientRepo() const;
META_DECLARE_CLASS(ScriptRepo);
};
END_INANITY_OIL
#endif