Bertini 2 d882924 (2026-10-06 19:56 UTC)
Numerical algebraic geometry library (C++ core)
Loading...
Searching...
No Matches
events.hpp
Go to the documentation of this file.
1//This file is part of Bertini 2.
2//
3//nag_algorithms/events.hpp is free software: you can redistribute it and/or modify
4//it under the terms of the GNU General Public License as published by
5//the Free Software Foundation, either version 3 of the License, or
6//(at your option) any later version.
7//
8//nag_algorithms/events.hpp is distributed in the hope that it will be useful,
9//but WITHOUT ANY WARRANTY; without even the implied warranty of
10//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11//GNU General Public License for more details.
12//
13//You should have received a copy of the GNU General Public License
14//along with nag_algorithms/events.hpp. If not, see <http://www.gnu.org/licenses/>.
15//
16// Copyright(C) Bertini2 Development Team
17//
18// See <http://www.gnu.org/licenses/> for a copy of the license,
19// as well as COPYING. Bertini2 is provided with permitted
20// additional terms in the b2/licenses/ directory.
21
33
34#pragma once
35
37#include "bertini2/detail/observable.hpp" // Observable: the executing tracker is carried as one
38#include "bertini2/common/config.hpp" // SuccessCode: how a completed path ended
39
40#include <cstddef>
41
42namespace bertini {
43
44 namespace algorithm {
45
50
54 ADD_BERTINI_EVENT_TYPE(AlgorithmStarted, AlgorithmEvent);
55
59 ADD_BERTINI_EVENT_TYPE(AlgorithmComplete, AlgorithmEvent);
60
61
69 template<class ObservedT>
70 class PathStarted : public AlgorithmEvent<ObservedT>
71 { BOOST_TYPE_INDEX_REGISTER_CLASS
72 public:
74 using HeldT = typename AlgorithmEvent<ObservedT>::HeldT;
81 PathStarted(HeldT obs, std::size_t path_index, Observable const* tracker = nullptr)
82 : AlgorithmEvent<ObservedT>(obs), path_index_(path_index), tracker_(tracker)
83 {}
84
86 std::size_t PathIndex() const { return path_index_; }
87
98 Observable const* Tracker() const { return tracker_; }
99
100 virtual ~PathStarted() = default;
101 PathStarted() = delete;
102 private:
103 std::size_t path_index_;
104 Observable const* tracker_ = nullptr;
105 };
106
110 template<class ObservedT>
111 class PathComplete : public AlgorithmEvent<ObservedT>
112 { BOOST_TYPE_INDEX_REGISTER_CLASS
113 public:
115 using HeldT = typename AlgorithmEvent<ObservedT>::HeldT;
123 PathComplete(HeldT obs, std::size_t path_index, Observable const* tracker = nullptr,
125 : AlgorithmEvent<ObservedT>(obs), path_index_(path_index), tracker_(tracker),
126 outcome_(outcome)
127 {}
128
130 std::size_t PathIndex() const { return path_index_; }
131
134 Observable const* Tracker() const { return tracker_; }
135
147 SuccessCode Outcome() const { return outcome_; }
148
149 virtual ~PathComplete() = default;
150 PathComplete() = delete;
151 private:
152 std::size_t path_index_;
153 Observable const* tracker_ = nullptr;
155 };
156
157 } // namespace algorithm
158
159} // namespace bertini
An abstract observable type, maintaining a list of observers, who can be notified in case of Events.
Definition observable.hpp:66
SuccessCode Outcome() const
How this path ended.
Definition events.hpp:147
typename AlgorithmEvent< ObservedT >::HeldT HeldT
The held-observer type the event carries.
Definition events.hpp:115
PathComplete(HeldT obs, std::size_t path_index, Observable const *tracker=nullptr, SuccessCode outcome=SuccessCode::Success)
Construct the event for the path at the given index.
Definition events.hpp:123
Observable const * Tracker() const
The tracker that executed this path – see PathStarted::Tracker().
Definition events.hpp:134
std::size_t PathIndex() const
Definition events.hpp:130
PathStarted(HeldT obs, std::size_t path_index, Observable const *tracker=nullptr)
Construct the event for the path at the given index.
Definition events.hpp:81
std::size_t PathIndex() const
Definition events.hpp:86
typename AlgorithmEvent< ObservedT >::HeldT HeldT
The held-observer type the event carries.
Definition events.hpp:74
virtual ~PathStarted()=default
Observable const * Tracker() const
The tracker that actually executes this path.
Definition events.hpp:98
Contains the detail/events base types.
#define ADD_BERTINI_EVENT_TYPE(event_name, event_parenttype)
Defines a new event type in a hierarchy.
Definition events.hpp:166
Definition algorithm_base.hpp:34
Definition algorithm_builder.hpp:36
Event< ObsT, true > ConstEvent
An event holding a const reference to its observable.
Definition events.hpp:154
SuccessCode
Definition config.hpp:42
@ Success
Definition config.hpp:51
Contains the observable base types.