CoreNEURON
ivocvect.hpp
Go to the documentation of this file.
1 /*
2 # =============================================================================
3 # Copyright (c) 2016 - 2022 Blue Brain Project/EPFL
4 #
5 # See top-level LICENSE file for details.
6 # =============================================================================.
7 */
8 
9 #pragma once
10 
12 
13 #include <cstdio>
14 #include <utility>
15 
16 namespace coreneuron {
17 template <typename T>
18 class fixed_vector {
19  size_t n_;
20 
21  public:
22  T* data_; /*making public for openacc copying */
23 
24  fixed_vector() = default;
25 
26  fixed_vector(size_t n)
27  : n_(n) {
28  data_ = new T[n_];
29  }
30 
31  fixed_vector(const fixed_vector& vec) = delete;
32  fixed_vector& operator=(const fixed_vector& vec) = delete;
34  : n_{vec.n_}
35  , data_{nullptr} {
36  std::swap(data_, vec.data_);
37  }
39  data_ = nullptr;
40  std::swap(data_, vec.data_);
41  n_ = vec.n_;
42  return *this;
43  }
44 
46  delete[] data_;
47  }
48 
49  const T& operator[](int i) const {
50  return data_[i];
51  }
52  T& operator[](int i) {
53  return data_[i];
54  }
55 
56  nrn_pragma_acc(routine seq)
57  const T* data(void) const {
58  return data_;
59  }
60 
61  nrn_pragma_acc(routine seq)
62  T* data(void) {
63  return data_;
64  }
65 
66  nrn_pragma_acc(routine seq)
67  size_t size() const {
68  return n_;
69  }
70 };
71 
73 
74 extern IvocVect* vector_new(int n);
75 extern int vector_capacity(IvocVect* v);
76 extern double* vector_vec(IvocVect* v);
77 
78 // retro-compatibility API
79 extern IvocVect* vector_new1(int n);
80 nrn_pragma_acc(routine seq)
81 extern int vector_capacity(void* v);
82 nrn_pragma_acc(routine seq)
83 extern double* vector_vec(void* v);
84 
85 } // namespace coreneuron
coreneuron::fixed_vector::operator=
fixed_vector & operator=(fixed_vector &&vec)
Definition: ivocvect.hpp:38
coreneuron::fixed_vector::data_
T * data_
Definition: ivocvect.hpp:22
coreneuron::fixed_vector::nrn_pragma_acc
nrn_pragma_acc(routine seq) size_t size() const
Definition: ivocvect.hpp:66
coreneuron::vector_new
IvocVect * vector_new(int n)
Definition: ivocvect.cpp:13
coreneuron::vector_vec
double * vector_vec(IvocVect *v)
Definition: ivocvect.cpp:19
coreneuron::fixed_vector::fixed_vector
fixed_vector()=default
coreneuron::fixed_vector::n_
size_t n_
Definition: ivocvect.hpp:19
coreneuron::fixed_vector::operator=
fixed_vector & operator=(const fixed_vector &vec)=delete
coreneuron::fixed_vector::fixed_vector
fixed_vector(size_t n)
Definition: ivocvect.hpp:26
coreneuron
THIS FILE IS AUTO GENERATED DONT MODIFY IT.
Definition: corenrn_parameters.cpp:12
coreneuron::i
int i
Definition: cellorder.cpp:485
coreneuron::fixed_vector::~fixed_vector
~fixed_vector()
Definition: ivocvect.hpp:45
coreneuron::fixed_vector::operator[]
T & operator[](int i)
Definition: ivocvect.hpp:52
coreneuron::fixed_vector
Definition: ivocvect.hpp:18
coreneuron::vector_new1
IvocVect * vector_new1(int n)
Definition: ivocvect.cpp:26
coreneuron::fixed_vector::nrn_pragma_acc
nrn_pragma_acc(routine seq) const T *data(void) const
Definition: ivocvect.hpp:56
coreneuron::fixed_vector::fixed_vector
fixed_vector(fixed_vector &&vec)
Definition: ivocvect.hpp:33
coreneuron::fixed_vector::nrn_pragma_acc
nrn_pragma_acc(routine seq) T *data(void)
Definition: ivocvect.hpp:61
data
#define data
Definition: md1redef.h:36
v
#define v
Definition: md1redef.h:11
offload.hpp
coreneuron::nrn_pragma_acc
nrn_pragma_acc(routine vector) static void triang_interleaved2(NrnThread *nt
Definition: ivocvect.cpp:30
coreneuron::fixed_vector::operator[]
const T & operator[](int i) const
Definition: ivocvect.hpp:49
coreneuron::vector_capacity
int vector_capacity(IvocVect *v)
Definition: ivocvect.cpp:16