/usr/include/dune/grid/utility/persistentcontainerinterface.hh is in libdune-grid-dev 2.4.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_PERSISTENTCONTAINERINTERFACE_HH
#define DUNE_PERSISTENTCONTAINERINTERFACE_HH
#ifndef HEADERCHECK
#error "This header exists for documentation purposes only and should never be included directly."
#endif
namespace Dune
{
/** \brief Persistent storage of data on all entities of a grid.
*
* This container allows to store data which is to remain persistent
* even during adaptation cycles.
* It provides storage for all entities in the hierarchy of a given
* codimension (provided dynamically during construction) and behaves much
* like an STL container.
*
* The container stores one entry for each entity in the hierarchical grid.
* However, it may also store some additional entries, which are not (or no
* longer) attached to an entity.
*
* After grid modification the method resize must be called to ensure entries
* for each entity in the modified grid.
* Accessing newly created entities before calling resize results in
* undefined behavior (e.g., a segmentation fault).
* To reduce the amount of overallocated entries, the method shrinkToFit
* may be called.
* It is explicitly possible that the grid adapts any persistent containers
* directly during the adaptation process.
*
* The containers are also be persistent over backup / restore of the grid.
* After 'shrinkToFit', the entries in the container (and their order) must
* match those of a newly created container, even after a backup and restore
* of the grid.
*
* There is a default implementation based on std::map but a grid
* implementation may provide a specialized implementation.
* Grids with a hashable id type can use std::unordered_map to store
* the data by simply deriving their PersistentContainer from
* Dune::PersistentContainerMap.
* For grids providing an id set suitable addressing vector-like storages,
* i.e., the id is an integral type and a method size() is provided,
* Dune::PersistentContainerVector can be used.
*
* \tparam G Grid type
* \tparam T Container's value type
*/
template< class G, class T >
class PersistentContainerInterface
{
typedef PersistentContainerInterface< G, T > This;
struct ImplementationDefined;
public:
typedef G Grid;
typedef T Value;
typedef ImplementationDefined Size;
typedef ImplementationDefined ConstIterator;
typedef ImplementationDefined Iterator;
// construction
/** \brief constuctor
*
* \param[in] grid reference to the grid to attach data to
* \param[in] codim codimension to attach data to
* \param[in] value value for initial entries
*
* \note All implementations must provide at least this constructor.
*/
PersistentContainerInterface ( Grid &grid, int codim, const Value &value = Value() );
/** \brief copy constructor */
PersistentContainerInterface ( const This &other );
/** \brief assignment operator */
const This &operator= ( const This &other );
// element access
/** \brief access the data associated with an entity
*
* \note The entity must be of the same codimension as the container
*/
template< class Entity >
const Value &operator[] ( const Entity &entity ) const;
/** \brief access the data associated with an entity
*
* \note The entity must be of the same codimension as the container
*/
template< class Entity >
Value &operator[] ( const Entity &entity );
/** \brief access the data associated with a subentity
*
* \note The codimension of the entity must be less or equal to the
* codimension of the container.
*/
template< class Entity >
const Value &operator() ( const Entity &entity, int subEntity ) const;
/** \brief access the data associated with a subentity
*
* \note The codimension of the entity must be less or equal to the
* codimension of the container.
*/
template< class Entity >
Value &operator() ( const Entity &entity, int subEntity );
// capacity
/** \brief number of entries in the container
*
* \note The number of entries in the container may be large than the
* number of entities in the grid.
*/
Size size () const;
/** \brief reserve memory for all entities in the grid
*
* This method will enlarge the container such that there is an
* entry for each entity.
*
* After a grid modification, this method must be called before accessing
* any data associated to newly created entities.
*
* \note The container might still hold entries for entities that no
* longer exist in the grid.
* While those entries ca no longer be accessed through an entity,
* iterators will still stop at such entries.
*/
void resize ( const Value &value = Value() );
/** \brief remove unnecessary entries from container
*
* This method will remove entries from the container that can no longer
* be accessed from the grid.
*
* The entries in the container (and their order) must match those of a
* newly created container.
* This property must be persistent over backup / restore of the grid.
*
* \note This method is merely a hint to the container.
* According to the container's internal addressing rules, some
* inaccessible entries might remain in the container.
*/
void shrinkToFit ();
// modifiers
/** \brief set all accessible entries to a given value
*
* \note It is undefined, whether the inaccessible values are also
* motified.
*/
void fill ( const Value &value );
/** \brief exchange the content of the container with another one
*
* \note std::swap is overloaded to refor to this method
*/
void swap ( This &other );
// iterators
/** \brief returns an iterator pointing to the first element of the container
*
* \note Iterators stop at all entries of the container, even if they are
* no longer accessible from the grid.
*/
ConstIterator begin () const;
/** \brief returns an iterator pointing to the first element of the container
*
* \note Iterators stop at all entries of the container, even if they are
* no longer accessible from the grid.
*/
Iterator begin ();
/** \brief returns an iterator pointing to the last element of the container
*
* \note Iterators stop at all entries of the container, even if they are
* no longer accessible from the grid.
*/
ConstIterator end () const;
/** \brief returns an iterator pointing to the last element of the container
*
* \note Iterators stop at all entries of the container, even if they are
* no longer accessible from the grid.
*/
Iterator end ();
// information
/** \brief return the codimension, the container attaches data to */
int codimension () const;
};
} // namespace Dune
#endif // #ifndef DUNE_PERSISTENTCONTAINERINTERFACE_HH
|