Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
SafeConstArrayView.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/utils/Precomp.h>
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26namespace Alien
27{
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32template <typename T>
33class SafeConstArrayView : private ConstArrayView<T>
34{
35 public:
37 typedef ConstArrayView<T> BaseArrayView;
38
39 public:
42
44 SafeConstArrayView(ConstArrayView<T> view)
46 {}
47
48 // Constructeur de copie
49 SafeConstArrayView(const SafeConstArrayView<T>& src) = default;
50
52 SafeConstArrayView(const SharedArray<T>& array)
53 : m_array(array)
54 {
55 this->setArray(m_array.view());
56 }
57
60
62 SafeConstArrayView& operator=(ConstArrayView<T> view)
63 {
64 m_array = SharedArray<T>();
65 BaseArrayView::operator=(view);
66 return *this;
67 }
68
70 SafeConstArrayView& operator=(const SharedArray<T>& array)
71 {
72 m_array = array;
73 setArray(m_array.view());
74 return *this;
75 }
76
77 public:
79 typedef typename BaseArrayView::value_type value_type;
81 typedef typename BaseArrayView::const_iterator const_iterator;
83 typedef typename BaseArrayView::const_pointer const_pointer;
85 typedef typename BaseArrayView::const_reference const_reference;
87 typedef typename BaseArrayView::size_type size_type;
89 typedef typename BaseArrayView::difference_type difference_type;
90
91 public:
94 using BaseArrayView::subView;
96 using BaseArrayView::subConstView;
98 using BaseArrayView::subViewInterval;
100 using BaseArrayView::operator[];
102 using BaseArrayView::item;
104 using BaseArrayView::size;
106 using BaseArrayView::length;
108 using BaseArrayView::begin;
110 using BaseArrayView::end;
112 using BaseArrayView::empty;
114 using BaseArrayView::contains;
115
116 public:
118 BaseArrayView view() const { return *this; }
119
120 private:
121 SharedArray<T> m_array;
122};
123
124/*---------------------------------------------------------------------------*/
125/*---------------------------------------------------------------------------*/
126
127} // namespace Alien
128
129/*---------------------------------------------------------------------------*/
130/*---------------------------------------------------------------------------*/
virtual ~SafeConstArrayView()
Destructeur de la classe.
SafeConstArrayView & operator=(ConstArrayView< T > view)
Egalit� avec une vue (on lib�re le array).
BaseArrayView::const_pointer const_pointer
Type pointeur constant d'un �l�ment du tableau.
SafeConstArrayView & operator=(const SharedArray< T > &array)
Egalit� avec un array (on r�f�rence le array).
BaseArrayView::size_type size_type
Type indexant le tableau.
BaseArrayView::const_reference const_reference
Type r�f�rence constante d'un �l�ment du tableau.
ConstArrayView< T > BaseArrayView
Classe de base.
SafeConstArrayView(const SharedArray< T > &array)
Constructeur � partir d'un array.
BaseArrayView::value_type value_type
Type des �l�ments du tableau.
SafeConstArrayView()
Constructeur par d�faut.
BaseArrayView view() const
Retourne une vue du SafeConstArrayView.
BaseArrayView::difference_type difference_type
Type d'une distance entre it�rateur �l�ments du tableau.
BaseArrayView::const_iterator const_iterator
Type de l'it�rateur constant sur un �l�ment du tableau.
SafeConstArrayView(ConstArrayView< T > view)
Constructeur � partir d'une vue.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17