Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
BaseVectorReader.h
1/*
2 * Copyright 2020 IFPEN-CEA
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * SPDX-License-Identifier: Apache-2.0
17 */
18
19#pragma once
20
21#include <alien/data/IVector.h>
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27namespace Alien
28{
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
33class IVector;
34
35/*---------------------------------------------------------------------------*/
36/*---------------------------------------------------------------------------*/
37
38namespace Common
39{
40
41 /*---------------------------------------------------------------------------*/
42 /*---------------------------------------------------------------------------*/
43
44 template <typename ValueT, typename Parameters>
45 class VectorReaderT
46 {
47 public:
48 using ValueType = ValueT;
49
50 private:
51 using Indexer = typename Parameters::Indexer;
52
53 public:
54 explicit VectorReaderT(const IVector& vector);
55
56 virtual ~VectorReaderT() = default;
57
58 inline const ValueType& operator[](Integer iIndex) const
59 {
60 const Integer id = Indexer::index(iIndex, m_local_offset);
61
62 return m_values[id];
63 }
64
65 [[nodiscard]] inline Arccore::Integer size() const { return m_values.size(); }
66
67 private:
68 ConstArrayView<ValueType> m_values;
69
70 Integer m_local_offset;
71 };
72
73 /*---------------------------------------------------------------------------*/
74 /*---------------------------------------------------------------------------*/
75
78
79 /*---------------------------------------------------------------------------*/
80 /*---------------------------------------------------------------------------*/
81
82} // namespace Common
83
84/*---------------------------------------------------------------------------*/
85/*---------------------------------------------------------------------------*/
86
87} // namespace Alien
88
89/*---------------------------------------------------------------------------*/
90/*---------------------------------------------------------------------------*/
91
92#include "VectorReaderT.h"
93
94/*---------------------------------------------------------------------------*/
95/*---------------------------------------------------------------------------*/
IVector.h.
Parameters.h.
Interface for all vectors.
Definition IVector.h:51
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17