https://mooseframework.inl.gov
Loading...
Searching...
No Matches
RestartableDataMap.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#pragma once
11
12#include "RestartableData.h"
13
14#include "UniqueStorage.h"
15
16// C++ includes
17#include <memory>
18#include <vector>
19#include <unordered_map>
20
28{
29public:
33 class Data : public UniqueStorage<RestartableDataValue>
34 {
35 public:
37 {
38 friend class RestartableDataMap;
40 WriteKey(const WriteKey &) {}
41 };
42
43 RestartableDataValue & addPointer(std::unique_ptr<RestartableDataValue> && ptr, const WriteKey)
44 {
46 }
47 };
48
50
54 RestartableDataValue & addData(std::unique_ptr<RestartableDataValue> data);
55
59 bool hasData(const std::string & name) const;
60
65 const RestartableDataValue * findData(const std::string & name) const;
66 RestartableDataValue * findData(const std::string & name);
68
72 RestartableDataValue & data(const std::string & name);
73
78 auto begin() { return _data.begin(); }
79 auto end() { return _data.end(); }
80 auto begin() const { return _data.begin(); }
81 auto end() const { return _data.end(); }
83
87 auto size() const { return _data.size(); }
91 auto empty() const { return _data.empty(); }
92
93private:
97 std::unordered_map<std::string, std::size_t> _name_to_data_index;
98};
Protected storage for restartable data.
RestartableDataValue & addPointer(std::unique_ptr< RestartableDataValue > &&ptr, const WriteKey)
Storage for restartable data that is ordered based on insertion order.
const RestartableDataValue * findData(const std::string &name) const
Tries to find data with the name name; returns nullptr if not found.
RestartableDataValue & addData(std::unique_ptr< RestartableDataValue > data)
Adds the restartable data data to the map.
std::unordered_map< std::string, std::size_t > _name_to_data_index
Mapping from data name -> index in _data for quick indexing.
auto begin()
Begin and end iterators to the data.
RestartableDataValue & data(const std::string &name)
bool hasData(const std::string &name) const
RestartableDataMap::Data _data
The registered data.
Abstract definition of a RestartableData value.
Storage container that stores a vector of unique pointers of T, but represents most of the public fac...
bool empty() const
iterator begin()
Begin and end iterators to the underlying data.
std::size_t size() const
T & addPointer(std::unique_ptr< T > &&ptr)
Adds the given object in ptr to the storage.
iterator end()