1 #ifndef IVL_netarray_H
2 #define IVL_netarray_H
3 /*
4 * Copyright (c) 2012-2014 Stephen Williams (steve@icarus.com)
5 * Copyright CERN 2012 / Stephen Williams (steve@icarus.com)
6 *
7 * This source code is free software; you can redistribute it
8 * and/or modify it in source code form under the terms of the GNU
9 * General Public License as published by the Free Software
10 * Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
21 */
22
23 # include "nettypes.h"
24 # include <vector>
25
26 /*
27 * Arrays with static dimensions (packed and unpacked) share this
28 * common base type.
29 */
30 class netsarray_t : public netarray_t {
31
32 public:
33 explicit netsarray_t(const std::vector<netrange_t>&packed,
34 ivl_type_t etype);
35 ~netsarray_t();
36
37 public:
38 // Virtual methods from the ivl_type_s type...
39
40 public:
static_dimensions()41 inline const std::vector<netrange_t>& static_dimensions() const
42 { return dims_; }
43
44 private:
45 std::vector<netrange_t> dims_;
46
47 };
48
netsarray_t(const std::vector<netrange_t> & pd,ivl_type_t etype)49 inline netsarray_t::netsarray_t(const std::vector<netrange_t>&pd,
50 ivl_type_t etype)
51 : netarray_t(etype), dims_(pd)
52 {
53 }
54
55 /*
56 * Packed arrays.
57 */
58 class netparray_t : public netsarray_t {
59
60 public:
61 explicit netparray_t(const std::vector<netrange_t>&packed,
62 ivl_type_t etype);
63 ~netparray_t();
64
65 public:
66 // Virtual methods from the ivl_type_s type...
67 bool packed(void) const;
68 long packed_width(void) const;
69 std::vector<netrange_t> slice_dimensions() const;
70
71 };
72
netparray_t(const std::vector<netrange_t> & pd,ivl_type_t etype)73 inline netparray_t::netparray_t(const std::vector<netrange_t>&pd,
74 ivl_type_t etype)
75 : netsarray_t(pd, etype)
76 {
77 }
78
79 /*
80 * Unpacked arrays are very similar, but lack packed slices.
81 */
82 class netuarray_t : public netsarray_t {
83
84 public:
85 explicit netuarray_t(const std::vector<netrange_t>&packed,
86 ivl_type_t etype);
87 ~netuarray_t();
88
89 public:
90 // Virtual methods from the ivl_type_s type...
91 std::vector<netrange_t> slice_dimensions() const;
92 };
93
netuarray_t(const std::vector<netrange_t> & pd,ivl_type_t etype)94 inline netuarray_t::netuarray_t(const std::vector<netrange_t>&pd,
95 ivl_type_t etype)
96 : netsarray_t(pd, etype)
97 {
98 }
99
100 #endif /* IVL_netarray_H */
101