Dune-Fufem 2.11-git
Loading...
Searching...
No Matches
sharedpointermap.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © DUNE-FUFEM Project contributors, see file AUTHORS.md
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
3
4#ifndef SHARED_POINTER_MAP_HH
5#define SHARED_POINTER_MAP_HH
6
7#warning This header is deprecated and will be removed after 2.11.
8
18#include <map>
19#include <memory>
20
22
35template <class K, class V, class Compare = std::less<K> >
36class
37[[deprecated("This class is deprecated and will be removed after 2.11.")]]
39 public std::map<K, std::shared_ptr<V>, Compare>
40{
41 typedef typename std::shared_ptr<V> VSP;
42
43 public:
45
46 [[deprecated("This class is deprecated and will be removed after 2.11.")]]
49
54 const VSP& getPointer(const K& key) const
55 {
56 typename Base::const_iterator it = this->find(key);
57 if (it == this->end())
58 DUNE_THROW(Dune::Exception, "Key not found");
59 return it->second;
60 }
61
66 VSP& getPointer(const K& key)
67 {
68 typename Base::iterator it = this->find(key);
69 if (it == this->end())
70 DUNE_THROW(Dune::Exception, "Key not found");
71 return it->second;
72 }
73
78 const V& get(const K& key) const
79 {
80 return *getPointer(key);
81 }
82
87 V& get(const K& key)
88 {
89 return *getPointer(key);
90 }
91
97 void set(const K& key, V* value)
98 {
99 this->operator[](key) = VSP(value);
100 }
101
102};
103
104#endif
reference operator[](size_type i)
iterator end()
#define DUNE_THROW(E,...)
const_iterator find(int proc) const
Simple map for shared pointers.
Definition sharedpointermap.hh:40
VSP & getPointer(const K &key)
Get a shared ptr for given key.
Definition sharedpointermap.hh:66
const VSP & getPointer(const K &key) const
Get a const shared ptr for given key.
Definition sharedpointermap.hh:54
const V & get(const K &key) const
Get const reference to value for given key.
Definition sharedpointermap.hh:78
SharedPointerMap()
Definition sharedpointermap.hh:47
void set(const K &key, V *value)
Set key to value.
Definition sharedpointermap.hh:97
V & get(const K &key)
Get reference to value for given key.
Definition sharedpointermap.hh:87
std::map< K, VSP, Compare > Base
Definition sharedpointermap.hh:44