19 #include <momemta/Pool.h> 21 #include <momemta/Logging.h> 23 void Pool::remove(
const InputTag& tag,
bool force) {
24 auto it = m_storage.find(tag);
25 if (it == m_storage.end())
28 if (!force && it->second.valid)
34 void Pool::remove_if_invalid(
const InputTag& tag) {
39 auto it = m_storage.find(tag);
40 if (it == m_storage.end()) {
46 it = m_storage.emplace(tag, content).first;
49 return it->second.ptr;
54 throw std::invalid_argument(
"Indexed input tag cannot be passed as argument of the pool. Use the `get` function of the input tag to retrieve its content.");
57 auto from_it = m_storage.find(from);
58 if (from_it == m_storage.end())
59 throw tag_not_found_error(
"No such tag in pool: " + from.
toString());
61 auto to_it = m_storage.find(to);
62 if (to_it != m_storage.end())
63 throw duplicated_tag_error(
"A module already produced the tag '" + to.
toString() +
"'");
65 m_storage[to] = m_storage[from];
69 auto it = m_storage.find(tag);
70 return it != m_storage.end();
74 using std::runtime_error::runtime_error;
81 for (
const auto& it: m_storage) {
82 if (!it.second.valid) {
83 LOG(fatal) <<
"Memory block '" << it.first.toString() <<
"' is flagged as invalid. This should not happen. Please open a bug report at <>.";
bool exists(const InputTag &tag) const
Check if input tag exists in the pool.