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//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//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 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
22// detail/events.hpp
23
24
30
31
32#ifndef BERTINI_DETAIL_EVENTS_HPP
33#define BERTINI_DETAIL_EVENTS_HPP
34#include <boost/type_index.hpp>
35namespace bertini {
36
57 { BOOST_TYPE_INDEX_REGISTER_CLASS
58 public:
59 virtual ~AnyEvent() = default;
60 };
61
62 template<class ObsT, bool IsConst = true>
63 class Event;
64
76 template<class ObsT>
77 class Event<ObsT, true> : public AnyEvent
78 { BOOST_TYPE_INDEX_REGISTER_CLASS
79 public:
80
86 Event(ObsT const& obs) : current_observable_(obs)
87 {}
88
89 virtual ~Event() = default;
90
98 ObsT const& Get() const
99 {return current_observable_;}
100
101 Event() = delete;
102
103 using HeldT = const ObsT&;
104 protected:
106 };
107
108
120 template<class ObsT>
121 class Event<ObsT,false> : public AnyEvent
122 { BOOST_TYPE_INDEX_REGISTER_CLASS
123 public:
124
130 Event(ObsT & obs) : current_observable_(obs)
131 {}
132
133 virtual ~Event() = default;
134
142 ObsT & Get()
143 {return current_observable_;}
144
145 Event() = delete;
146
147 using HeldT = ObsT&;
148 protected:
150 };
151
153 template<typename ObsT>
155
157 template<typename ObsT>
159
166 #define ADD_BERTINI_EVENT_TYPE(event_name,event_parenttype) template<class ObservedT> \
167 class event_name : public event_parenttype<ObservedT> \
168 { BOOST_TYPE_INDEX_REGISTER_CLASS \
169 public: \
170 using HeldT = typename event_parenttype<ObservedT>::HeldT; \
171 event_name(HeldT obs) : event_parenttype<ObservedT>(obs){} \
172 virtual ~event_name() = default; \
173 event_name() = delete; }
174
175} //re: namespace bertini
176
177#endif
Strawman Event type, enabling polymorphism.
Definition events.hpp:57
virtual ~AnyEvent()=default
ObsT & current_observable_
The observable object this event carries.
Definition events.hpp:149
Event(ObsT &obs)
Constructor for an event.
Definition events.hpp:130
ObsT & Get()
Get the emitting object, by const reference.
Definition events.hpp:142
ObsT & HeldT
How the observable is held: by mutable reference.
Definition events.hpp:147
const ObsT & current_observable_
The observable object this event carries.
Definition events.hpp:105
ObsT const & Get() const
Get the emitting object, by const reference.
Definition events.hpp:98
virtual ~Event()=default
Event(ObsT const &obs)
Constructor for an event.
Definition events.hpp:86
const ObsT & HeldT
How the observable is held: by const reference.
Definition events.hpp:103
Definition events.hpp:63
Definition algorithm_builder.hpp:36
Event< ObsT, true > ConstEvent
An event holding a const reference to its observable.
Definition events.hpp:154
Event< ObsT, false > MutableEvent
An event holding a mutable reference to its observable.
Definition events.hpp:158