Warning, file /include/orange/orangeinp/detail/ProtoBuilder.hh was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <functional>
0010
0011 #include "orange/OrangeInput.hh"
0012 #include "orange/OrangeTypes.hh"
0013
0014 #include "ProtoMap.hh"
0015
0016 namespace celeritas
0017 {
0018 struct JsonPimpl;
0019 namespace orangeinp
0020 {
0021 class ProtoInterface;
0022
0023 namespace detail
0024 {
0025
0026
0027
0028
0029
0030
0031
0032
0033 class ProtoBuilder
0034 {
0035 public:
0036
0037
0038 using Tol = Tolerance<>;
0039 using SaveUnivJson = std::function<void(UnivId, JsonPimpl&&)>;
0040
0041
0042
0043 struct Options
0044 {
0045
0046 SaveUnivJson save_json;
0047
0048
0049 bool implicit_parent_boundary{};
0050 };
0051
0052 public:
0053
0054 ProtoBuilder(OrangeInput* inp, ProtoMap const& protos, Options const& opts);
0055
0056
0057 Tol const& tol() const { return inp_->tol; }
0058
0059
0060 bool save_json() const { return static_cast<bool>(save_json_); }
0061
0062
0063 inline UnivId find_universe_id(ProtoInterface const*) const;
0064
0065
0066 inline UnivId current_uid() const;
0067
0068
0069 UnivId::size_type num_universes() const { return inp_->universes.size(); }
0070
0071
0072 bool is_global_universe() const
0073 {
0074 return this->current_uid() == orange_global_univ;
0075 }
0076
0077
0078 bool assume_inside() const
0079 {
0080 return implicit_parent_boundary_ && !this->is_global_universe();
0081 }
0082
0083
0084 LogicNotation logic() const { return inp_->logic; }
0085
0086
0087 void save_json(JsonPimpl&&) const;
0088
0089
0090 void insert(VariantUniverseInput&& unit);
0091
0092 private:
0093 OrangeInput* inp_{};
0094 ProtoMap const& protos_;
0095 SaveUnivJson save_json_;
0096 bool implicit_parent_boundary_{};
0097
0098
0099 size_type num_univs_inserted_{0};
0100 };
0101
0102
0103
0104
0105
0106
0107
0108 UnivId ProtoBuilder::find_universe_id(ProtoInterface const* p) const
0109 {
0110 return protos_.find(p);
0111 }
0112
0113
0114
0115
0116
0117 UnivId ProtoBuilder::current_uid() const
0118 {
0119 CELER_EXPECT(num_univs_inserted_ < this->num_universes());
0120 return UnivId{this->num_universes() - num_univs_inserted_ - 1};
0121 }
0122
0123
0124 }
0125 }
0126 }