-
Notifications
You must be signed in to change notification settings - Fork 6
/
DVVector.h
63 lines (47 loc) · 1.52 KB
/
DVVector.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef _DVVector_h
#define _DVVector_h
#include "TRTC_api.h"
#include "DeviceViewable.h"
#include "TRTCContext.h"
class THRUST_RTC_API DVVectorLike : public DeviceViewable
{
public:
const std::string& name_elem_cls() const { return m_elem_cls; }
const std::string& name_ref_type() const { return m_ref_type; }
size_t elem_size() const { return m_elem_size; }
size_t size() const { return m_size; }
DVVectorLike(const char* elem_cls, const char* ref_type, size_t size);
virtual ~DVVectorLike() {}
virtual bool is_readable() const { return true; }
virtual bool is_writable() const { return false; }
protected:
std::string m_elem_cls;
std::string m_ref_type;
size_t m_elem_size;
size_t m_size;
};
class THRUST_RTC_API DVVector : public DVVectorLike
{
public:
void* data() const { return m_data; }
DVVector(const char* elem_cls, size_t size, void* hdata=nullptr);
~DVVector();
virtual bool is_writable() const { return true; }
void to_host(void* hdata, size_t begin=0, size_t end = (size_t)(-1)) const;
virtual ViewBuf view() const;
private:
void* m_data;
};
class THRUST_RTC_API DVVectorAdaptor : public DVVectorLike
{
public:
void* data() const { return m_data; }
DVVectorAdaptor(const char* elem_cls, size_t size, void* ddata);
DVVectorAdaptor(const DVVector& vec, size_t begin = 0, size_t end = (size_t)(-1));
DVVectorAdaptor(const DVVectorAdaptor& vec, size_t begin = 0, size_t end = (size_t)(-1));
virtual bool is_writable() const { return true; }
virtual ViewBuf view() const;
private:
void* m_data;
};
#endif