Anchors
C++ library for Incremental Computing
anchorbase.h
1#ifndef ANCHORS_ANCHORBASE_H
2#define ANCHORS_ANCHORBASE_H
3
4#pragma comment(lib, "bcrypt.lib") // For Windows machines
5
6#include <boost/uuid/uuid.hpp>
7#include <memory>
8#include <unordered_set>
9#include <vector>
10
11namespace anchors {
12/***
13 `AnchorBase` represents an Anchor without its type information, which allows us
14 store Anchors of different types in a container.
15
16 The functions in this class are implemented as private functions and only
17 visible to the Engine class.
18 ***/
19class AnchorBase {
20 public:
21 using AnchorId = boost::uuids::uuid;
22
23 virtual ~AnchorBase(){};
24
25 virtual void compute(int stabilizationNumber) = 0;
26
27 virtual AnchorId getId() const = 0;
28
29 virtual int getHeight() const = 0;
30
31 virtual int getRecomputeId() const = 0;
32
33 virtual int getChangeId() const = 0;
34
35 virtual void setChangeId(int changeId) = 0;
36
37 virtual void markNecessary() = 0;
38
39 virtual void decrementNecessaryCount() = 0;
40
41 virtual bool isNecessary() const = 0;
42
43 virtual bool isStale() const = 0;
44
45 virtual std::unordered_set<std::shared_ptr<AnchorBase>> getDependants()
46 const = 0;
47
48 virtual std::vector<std::shared_ptr<AnchorBase>> getDependencies()
49 const = 0;
50
51 virtual void addDependant(const std::shared_ptr<AnchorBase>& parent) = 0;
52
53 virtual void removeDependant(const std::shared_ptr<AnchorBase>& parent) = 0;
54};
55} // namespace anchors
56
57#endif // ANCHORS_ANCHORBASE_H
Main library namespace.
Definition: anchor.h:32