Debian Codegraph @

src/atlas/array/TableView.cc

raw
1 /*
2 * (C) Copyright 2013 ECMWF.
3 *
4 * This software is licensed under the terms of the Apache Licence Version 2.0
5 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6 * In applying this licence, ECMWF does not waive the privileges and immunities
7 * granted to it by virtue of its status as an intergovernmental organisation
8 * nor does it submit to any jurisdiction.
9 */
10
11 #include "atlas/array/TableView.h"
12
13 namespace atlas {
14 namespace array {
15
16 // ----------------------------------------------------------------------------
17
18 template <bool ReadOnly>
19 TableView<ReadOnly>::TableView(const Table& table, bool host):
20 host_(host),
21 missing_value_(table.missing_value()),
22 rows_(table.rows()),
23 maxcols_(table.maxcols()),
24 mincols_(table.mincols()),
25 values_(host_ ? make_host_view<idx_t, 1>(*(table.data_[_values_]))
26 : make_device_view<idx_t, 1>(*(table.data_[_values_]))),
27 displs_(host_ ? make_host_view<size_t, 1>(*(table.data_[_displs_]))
28 : make_device_view<size_t, 1>(*(table.data_[_displs_]))),
29 counts_(host_ ? make_host_view<size_t, 1>(*(table.data_[_counts_]))
30 : make_device_view<size_t, 1>(*(table.data_[_counts_]))),
31 const_access_(this),
32 access_(this) {}
33
34 // ----------------------------------------------------------------------------
35
36 template <bool ReadOnly>
37 TableView<ReadOnly>::TableView(const TableView& other):
38 host_(other.host_),
39 missing_value_(other.missing_value_),
40 rows_(other.rows_),
41 maxcols_(other.maxcols_),
42 mincols_(other.mincols_),
43 values_(other.values_),
44 displs_(other.displs_),
45 counts_(other.counts_),
46 const_access_(this),
47 access_(this) {}
48
49 // ----------------------------------------------------------------------------
50
51 template <bool ReadOnly>
52 TableView<ReadOnly> TableView<ReadOnly>::operator=(const TableView& other) {
53 host_ = other.host_;
54 missing_value_ = other.missing_value_;
55 rows_ = other.rows_;
56 maxcols_ = other.maxcols_;
57 mincols_ = other.mincols_;
58 values_ = other.values_;
59 displs_ = other.displs_;
60 counts_ = other.counts_;
61 return *this;
62 }
63
64 // ----------------------------------------------------------------------------
65
66 template <bool ReadOnly>
67 TableView<ReadOnly> make_table_view(const Table& table) {
68 return TableView<ReadOnly>(table);
69 }
70
71 // ----------------------------------------------------------------------------
72
73 template class TableView<true>;
74 template class TableView<false>;
75 template TableView<true> make_table_view<true>(const Table&);
76 template TableView<false> make_table_view<false>(const Table&);
77
78 // ----------------------------------------------------------------------------
79
80 } // namespace array
81 } // namespace atlas