Bertini 2 - C++ Core
Software for Numerical Algebraic Geometry
Loading...
Searching...
No Matches
detail/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) 2015 - 2021 by 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// individual authors of this file include:
23// silviana amethyst, university of wisconsin-eau claire
24//
25
26// detail/events.hpp
27
28
34
35
36#ifndef BERTINI_DETAIL_EVENTS_HPP
37#define BERTINI_DETAIL_EVENTS_HPP
38#include <boost/type_index.hpp>
39namespace bertini {
40
47 { BOOST_TYPE_INDEX_REGISTER_CLASS
48 public:
49 virtual ~AnyEvent() = default;
50 };
51
52 template<class ObsT, bool IsConst = true>
53 class Event;
54
66 template<class ObsT>
67 class Event<ObsT, true> : public AnyEvent
68 { BOOST_TYPE_INDEX_REGISTER_CLASS
69 public:
70
76 Event(ObsT const& obs) : current_observable_(obs)
77 {}
78
79 virtual ~Event() = default;
80
88 ObsT const& Get() const
89 {return current_observable_;}
90
91 Event() = delete;
92
93 using HeldT = const ObsT&;
94 protected:
95 const ObsT& current_observable_;
96 };
97
98
110 template<class ObsT>
111 class Event<ObsT,false> : public AnyEvent
112 { BOOST_TYPE_INDEX_REGISTER_CLASS
113 public:
114
120 Event(ObsT & obs) : current_observable_(obs)
121 {}
122
123 virtual ~Event() = default;
124
132 ObsT & Get()
133 {return current_observable_;}
134
135 Event() = delete;
136
137 using HeldT = ObsT&;
138 protected:
139 ObsT& current_observable_;
140 };
141
142 template<typename ObsT>
143 using ConstEvent = Event<ObsT,true>;
144
145 template<typename ObsT>
146 using MutableEvent = Event<ObsT,false>;
147
154 #define ADD_BERTINI_EVENT_TYPE(event_name,event_parenttype) template<class ObservedT> \
155 class event_name : public event_parenttype<ObservedT> \
156 { BOOST_TYPE_INDEX_REGISTER_CLASS \
157 public: \
158 using HeldT = typename event_parenttype<ObservedT>::HeldT; \
159 event_name(HeldT obs) : event_parenttype<ObservedT>(obs){} \
160 virtual ~event_name() = default; \
161 event_name() = delete; }
162
163} //re: namespace bertini
164
165#endif
Strawman Event type, enabling polymorphism.
Definition detail/events.hpp:47