libpnicore
array_holder_interface.hpp
1 //
2 // (c) Copyright 2013 DESY, Eugen Wintersberger <eugen.wintersberger@desy.de>
3 //
4 // This file is part of libpnicore.
5 //
6 // libpnicore is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // libpnicore is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with libpnicore. If not, see <http://www.gnu.org/licenses/>.
18 //
19 // ============================================================================
20 //
21 // Created on: 11 08, 2013
22 // Author: Eugen Wintersberger <eugen.wintersberger@desy.de>
23 //
24 #pragma once
25 
26 #include <iostream>
27 #include "value.hpp"
28 #include "value_ref.hpp"
29 
30 namespace pni{
31 namespace core{
32 
40  {
41  public:
43  typedef std::vector<size_t> element_index;
45  typedef std::vector<slice> view_index;
52  virtual type_id_t type_id() const = 0;
53 
54  //-----------------------------------------------------------------
64  virtual size_t rank() const = 0;
65 
66  //-----------------------------------------------------------------
76  virtual shape_t shape() const = 0;
77 
78  //-----------------------------------------------------------------
87  virtual size_t size() const = 0;
88 
89  //-----------------------------------------------------------------
98  virtual std::ostream &write(std::ostream &os) const = 0;
99 
100  //-----------------------------------------------------------------
109  virtual std::istream &read(std::istream &is) = 0;
110 
111  //-----------------------------------------------------------------
121  virtual array_holder_interface *clone() const = 0;
122 
123  //-----------------------------------------------------------------
132  virtual string type_name() const = 0;
133 
134  //-----------------------------------------------------------------
136  virtual value operator[](size_t i) const = 0;
137 
138  //-----------------------------------------------------------------
140  virtual value_ref operator[](size_t i) = 0;
141 
142  //-----------------------------------------------------------------
144  virtual value at(size_t i) const = 0;
145 
146  //-----------------------------------------------------------------
148  virtual value_ref at(size_t i) = 0;
149 
150  //-----------------------------------------------------------------
152  virtual const void *ptr() const = 0;
153 
154  //-----------------------------------------------------------------
156  virtual value operator()(const element_index &index) const = 0;
157 
158  //-----------------------------------------------------------------
160  virtual value_ref operator()(const element_index &index) = 0;
161 
162  };
163 
164 
165 //end of namespace
166 }
167 }
virtual size_t size() const =0
get size
virtual value at(size_t i) const =0
get value at linear index i
virtual string type_name() const =0
get type name
virtual array_holder_interface * clone() const =0
clone yourself
virtual size_t rank() const =0
get rank
std::vector< slice > view_index
view index type
Definition: array_holder_interface.hpp:45
virtual value operator[](size_t i) const =0
get element at linear index i
virtual shape_t shape() const =0
get shape
Definition: add_op.hpp:29
virtual type_id_t type_id() const =0
return type id
virtual value operator()(const element_index &index) const =0
get element value
virtual std::ostream & write(std::ostream &os) const =0
write data
virtual const void * ptr() const =0
get pointer to data
std::vector< size_t > element_index
single element index type
Definition: array_holder_interface.hpp:43
virtual std::istream & read(std::istream &is)=0
read data
array holder interface
Definition: array_holder_interface.hpp:39
type_id_t
type codes for PNI data types
Definition: types/types.hpp:148
type erasure for references to POD data
Definition: value_ref.hpp:43
type erasure for POD data
Definition: value.hpp:46