Debian Codegraph @

dune/istl/paamg/properties.hh

raw
1 // SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2 // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4 // vi: set et ts=4 sw=2 sts=2:
5 #ifndef DUNE_ISTL_AMG_PROPERTIES_HH
6 #define DUNE_ISTL_AMG_PROPERTIES_HH
7
8 #include <dune/common/propertymap.hh>
9
10 namespace Dune
11 {
12
13 namespace Amg
14 {
15 /**
16 * @addtogroup ISTL_PAAMG
17 *
18 * @{
19 */
20 /** @file
21 * @author Markus Blatt
22 * @brief Provides classes for handling internal properties in a graph
23 */
24
25 /**
26 * @brief Tag idnetifying the visited property of a vertex.
27 */
28 struct VertexVisitedTag
29 {};
30
31
32 /**
33 * @brief A property map that extracts one property out of a bundle
34 * using operator[]()
35 *
36 * Using this access class properties can be stored in std::bitset.
37 */
38 template<typename C, typename K, std::size_t i,typename T=typename C::ValueType,
39 typename R = typename C::Reference>
40 class RandomAccessBundledPropertyMap
41 : public RAPropertyMapHelper<R,
42 RandomAccessBundledPropertyMap<C,K,i,T,R> >
43 {
44 public:
45 /** @brief The container that holds the properties */
46 typedef C Container;
47
48 /** @brief The reference type of the container. */
49 typedef R Reference;
50
51 /** @brief The key of the property map. */
52 typedef K Key;
53
54 /**
55 * @brief The category of the property map.
56 */
57 typedef LvaluePropertyMapTag Category;
58
59 enum {
60 /** @brief The index of the property in the bundle. */
61 index = i
62 };
63
64 /**
65 * @brief Get the property for a key.
66 * @param key The key.
67 * @return The corresponding property.
68 */
69 Reference operator[](const Key& key) const
70 {
71 return container_[key][index];
72 }
73
74 /**
75 * @brief Constructor.
76 * @param container The container with the property bundle.
77 */
78 RandomAccessBundledPropertyMap(Container& container)
79 : container_(&container)
80 {}
81
82 /** @brief The default constructor. */
83 RandomAccessBundledPropertyMap()
84 : container_(0)
85 {}
86
87 private:
88 /** @brief The container with property bundles. */
89 Container* container_;
90 };
91 }
92 }
93
94 #endif