Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
CartesianMeshPatchListView.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* CartesianMeshPatchListView.h (C) 2000-2025 */
9/* */
10/* View of a list of patches. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CARTESIANMESH_CARTESIANMESPATCHLISTVIEW_H
13#define ARCANE_CARTESIANMESH_CARTESIANMESPATCHLISTVIEW_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/ArrayView.h"
18
20
21#include "arcane/cartesianmesh/CartesianPatch.h"
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26namespace Arcane
27{
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
33
34/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
36
42class ARCANE_CARTESIANMESH_EXPORT CartesianMeshPatchListView
43{
44 friend CartesianMeshImpl;
45 friend CartesianPatchGroup;
46
47 public:
48
51 {};
52
54 class Iterator
55 {
56 friend CartesianMeshPatchListView;
57
58 public:
59
60 typedef std::forward_iterator_tag iterator_category;
61 typedef ICartesianMeshPatch value_type;
62 typedef Int32 size_type;
63
64 public:
65
66 Iterator() = default;
67
68 public:
69
70 CartesianPatch operator*() const { return CartesianPatch(m_patches[m_index]); }
71 Iterator& operator++()
72 {
73 ++m_index;
74 return (*this);
75 }
76 friend bool operator==(const Iterator& a, const Iterator& b)
77 {
78 return (a.m_patches.data() + a.m_index) == (b.m_patches.data() + b.m_index);
79 }
80 friend bool operator!=(const Iterator& a, const Iterator& b)
81 {
82 return !(operator==(a, b));
83 }
84 friend bool operator==(const Iterator& a, const Sentinel&)
85 {
86 return a.m_patches.size() != a.m_index;
87 }
88 friend bool operator!=(const Iterator& a, const Sentinel& b)
89 {
90 return !(operator==(a, b));
91 }
92
93 private:
94
96 : m_index(index)
97 , m_patches(v)
98 {}
99
100 private:
101
102 Int32 m_index = 0;
104 };
105
106 public:
107
108 CartesianMeshPatchListView() = default;
109
110 private:
111
112 // Constructor for 'CartesiaMeshImpl'
113 explicit CartesianMeshPatchListView(ConstArrayView<ICartesianMeshPatch*> v)
114 : m_patches(v)
115 {}
116
117 public:
118
119 Iterator begin() const { return Iterator(m_patches, 0); }
120 Sentinel end() const { return {}; }
121 Iterator endIterator() const { return Iterator(m_patches, m_patches.size()); }
122 Int32 size() const { return m_patches.size(); }
123
124 private:
125
126 ConstArrayView<ICartesianMeshPatch*> m_patches;
127};
128
129/*---------------------------------------------------------------------------*/
130/*---------------------------------------------------------------------------*/
131
132} // End namespace Arcane
133
134/*---------------------------------------------------------------------------*/
135/*---------------------------------------------------------------------------*/
136
137#endif
Declarations of Arcane's general types.
Sentinel for iteration over a list of patches.
AMR Patch of a Cartesian mesh.
Constant view of an array of type T.
Interface of an AMR patch of a Cartesian mesh.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int32_t Int32
Signed integer type of 32 bits.