Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SubEnvironment.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4
5namespace storm {
6
7// The member functions below are declared but defined out-of-line afterwards.
8// This is needed because `extern template class` otherwise still implicitly inlines and instantiates member functions.
9
10template<typename EnvironmentType>
12 public:
14 SubEnvironment(SubEnvironment const& other);
16 EnvironmentType const& get() const;
17 EnvironmentType& get();
18
19 private:
20 void assertInitialized() const;
21 mutable std::unique_ptr<EnvironmentType> subEnv;
22};
23
24template<typename EnvironmentType>
26 // Intentionally left empty
27}
28
29template<typename EnvironmentType>
30SubEnvironment<EnvironmentType>::SubEnvironment(SubEnvironment const& other) : subEnv(other.subEnv ? new EnvironmentType(*other.subEnv) : nullptr) {
31 // Intentionally left empty
32}
33
34template<typename EnvironmentType>
36 if (other.subEnv) {
37 subEnv = std::make_unique<EnvironmentType>(*other.subEnv);
38 } else {
39 subEnv.reset();
40 }
41 return *this;
42}
43
44template<typename EnvironmentType>
45EnvironmentType const& SubEnvironment<EnvironmentType>::get() const {
46 assertInitialized();
47 return *subEnv;
48}
49
50template<typename EnvironmentType>
52 assertInitialized();
53 return *subEnv;
54}
55
56template<typename EnvironmentType>
57void SubEnvironment<EnvironmentType>::assertInitialized() const {
58 if (!subEnv) {
59 subEnv = std::make_unique<EnvironmentType>();
60 }
61}
62
63} // namespace storm
SubEnvironment< EnvironmentType > & operator=(SubEnvironment const &other)
EnvironmentType const & get() const