Live Cells C++
Reactive Programming for C++
Loading...
Searching...
No Matches
dependent_cell.hpp
1/*
2 * live_cells_cpp
3 * Copyright (C) 2024 Alexander Gutev <alex.gutev@gmail.com>
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you
6 * may not use this file except in compliance with the License. You
7 * may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * permissions and limitations under the License.
16 */
17
18#ifndef LIVE_CELLS_DEPENDENT_CELL_HPP
19#define LIVE_CELLS_DEPENDENT_CELL_HPP
20
21#include <memory>
22
23#include "observable.hpp"
24#include "merged_observable.hpp"
25
26namespace live_cells {
27
43 template <Cell... Ts>
45 public:
46
57 observable(args...) {}
58
59 void add_observer(observer::ref o) const {
60 observable.add_observer(o);
61 }
62
63 void remove_observer(observer::ref o) const {
64 observable.remove_observer(o);
65 }
66
67 protected:
68 merged_observable<Ts...> observable;
69 };
70
71
72} // live_cells
73
74#endif /* LIVE_CELLS_DEPENDENT_CELL_HPP */
Provides an interface for a cell with a value that is dependent on one or more argument cells.
Definition dependent_cell.hpp:44
dependent_cell(Ts... args)
Create a cell with a value dependent on the argument cells in args.
Definition dependent_cell.hpp:56
A computed cell which determines its argument cells at runtime.
Definition dynamic_compute_cell.hpp:153
void remove_observer(observer::ref o) const
Definition merged_observable.hpp:63
void add_observer(observer::ref o) const
Definition merged_observable.hpp:53
std::shared_ptr< observer > ref
Shared pointer to an observer.
Definition types.hpp:37
Definition boolean.hpp:26