forked from snakster/cpp.react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.h
More file actions
115 lines (81 loc) · 2.46 KB
/
api.h
File metadata and controls
115 lines (81 loc) · 2.46 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Copyright Sebastian Jeckel 2017.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef REACT_API_H_INCLUDED
#define REACT_API_H_INCLUDED
#pragma once
#include <type_traits>
#include <vector>
#include "react/detail/defs.h"
#include "react/common/utility.h"
/*****************************************/ REACT_BEGIN /*****************************************/
///////////////////////////////////////////////////////////////////////////////////////////////////
/// API constants
///////////////////////////////////////////////////////////////////////////////////////////////////
enum class WeightHint
{
automatic,
light,
heavy
};
enum class TransactionFlags
{
none = 0,
allow_merging = 1 << 1,
sync_linked = 1 << 2
};
REACT_DEFINE_BITMASK_OPERATORS(TransactionFlags)
enum class Token { value };
enum class InPlaceTag
{
value = 1
};
static constexpr InPlaceTag in_place = InPlaceTag::value;
///////////////////////////////////////////////////////////////////////////////////////////////////
/// API types
///////////////////////////////////////////////////////////////////////////////////////////////////
// Group
class Group;
// Ref
template <typename T>
using Ref = std::reference_wrapper<const T>;
// State
template <typename S>
class State;
template <typename S>
class StateVar;
template <typename S>
class StateSlot;
template <typename S>
class StateLink;
template <typename S>
using StateRef = State<Ref<S>>;
// Event
enum class Token;
template <typename E = Token>
class Event;
template <typename E = Token>
class EventSource;
template <typename E = Token>
class EventSlot;
template <typename E = Token>
using EventValueList = std::vector<E>;
template <typename E = Token>
using EventValueSink = std::back_insert_iterator<std::vector<E>>;
// Observer
class Observer;
template <typename T>
bool HasChanged(const T& a, const T& b)
{ return !(a == b); }
template <typename T>
bool HasChanged(const Ref<T>& a, const Ref<T>& b)
{ return true; }
template <typename T, typename V>
void ListInsert(T& list, V&& value)
{ list.push_back(std::forward<V>(value)); }
template <typename T, typename V>
void MapInsert(T& map, V&& value)
{ map.insert(std::forward<V>(value)); }
/******************************************/ REACT_END /******************************************/
#endif // REACT_API_H_INCLUDED