AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
Array.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#ifndef AGXDATA_ARRAY_H
18#define AGXDATA_ARRAY_H
19
20#include <agxData/Data.h>
21#include <agx/GlobalResult.h>
22#include <agx/Vector.h>
23
24#ifdef _MSC_VER
25# pragma warning(push)
26# pragma warning( disable : 4251 ) // class X needs to have dll-interface to be used by clients of class Y
27#endif
28
29namespace agxData
30{
31
37 {
38 public:
39
42
45
48
51
53 size_t size() const;
54
56 bool empty() const;
57
59 agx::IndexRange32& range();
60 const agx::IndexRange32& range() const;
61
63 const agxData::Buffer* buffer() const;
64 agxData::Buffer* buffer();
65
67 void init(agxData::Buffer* buffer, agx::IndexRange32 range);
68
70 void init(agxData::Buffer* buffer);
71
73 void init();
74
76 void setRange(size_t startIndex, size_t endIndex);
77
79 void setRange(agx::IndexRange32 range);
80
83 const agxData::Format* getFormat() const;
84
86 void sync();
87
89 bool isValid() const;
90
92 void _setBuffer(agxData::Buffer *buffer);
93
94 protected:
95 friend class SerializedFrame;
98 };
99
100
101
105 template <typename T>
107 {
108 public:
109 typedef T Type;
110 typedef T value_type;
111 typedef T* pointer;
112 typedef const T* const_pointer;
113 typedef T& reference;
114 typedef const T& const_reference;
115 typedef size_t size_type;
116 typedef T* iterator;
117 typedef const T* const_iterator;
118 typedef std::random_access_iterator_tag iterator_category;
120
121 static const bool IsScalar = false;
122
133 static const agxData::Array<T> raw(const T* buffer, agx::Index size);
134
135 public:
137 Array();
138
141
144
147
153
155 T& back();
156 const T& back() const;
157
159 T& front();
160 const T& front() const;
161
163 T& operator[] (size_t index);
164 const T& operator[] (size_t index) const;
165
167 T& at(size_t index);
168 const T& at(size_t index) const;
169
172
175
177 iterator begin();
178 const_iterator begin() const;
179
181 iterator end();
182 const_iterator end() const;
183
185 T* ptr();
186 const T* ptr() const;
187
195 template <typename T2>
196 size_t find(const T2& element) const;
197
199 template <typename T2>
200 bool contains(const T2& element) const;
201
202
203 //
204 // GlobalResult functionality used by parallel kernels that create a dynamic amount of output data.
205 // These are implemented in agxData/Buffer.h
206 //
207
210
214 size_t commitResult(size_t numElements, const void* localResult, agx::Index sortIndex);
215 size_t commitResult(size_t numElements, const void* localResult);
216
218 template <typename T2>
219 size_t commitResult(const T2& vector, agx::Index sortIndex);
220 template <typename T2>
221 size_t commitResult(const T2& vector);
222
223 };
224
225
226 /* Implementation */
227 // See Buffer.h
228}
229
230#ifdef _MSC_VER
231# pragma warning(pop)
232#endif
233
235
236
237#endif /* _AGXDATA_ARRAY_H_ */
#define AGX_TEMPLATED_TYPE_BINDING(_Type, _Name)
Definition Type.h:192
#define AGXCORE_EXPORT
Arrays are fast accessors into the data, or a portion of it, held by a Buffer.
Definition Array.h:37
const agxData::Buffer * buffer() const
Definition Buffer.h:720
agx::IndexRange32 m_range
Definition Array.h:97
agx::IndexRange32 & range()
Definition Buffer.h:721
size_t size() const
Definition Buffer.h:708
agxData::Buffer * m_buffer
Definition Array.h:96
Type-specific Array used for fast access into the data held by a Buffer.
Definition Array.h:107
agx::GlobalResult::Transaction allocateResult(size_t numElements)
Definition Buffer.h:572
const T * const_iterator
Definition Array.h:117
size_t size_type
Definition Array.h:115
static const bool IsScalar
Definition Array.h:121
T & reference
Definition Array.h:113
Array()
Create a new invalid array.
Definition Buffer.h:755
size_t commitResult(size_t numElements, const void *localResult, agx::Index sortIndex)
Definition Buffer.h:578
size_t find(const T2 &element) const
The index of the first occurrence of an element that is equal to the given element.
Definition Buffer.h:908
bool contains(const T2 &element) const
Definition Buffer.h:920
static agxData::Array< T > raw(T *buffer, agx::Index size)
Array creation helper method that creates an array covering the given memory area.
Definition Buffer.h:733
const T * const_pointer
Definition Array.h:112
T & front()
Definition Buffer.h:836
agx::GlobalResult * getGlobalResult()
Definition Buffer.h:564
iterator end()
Definition Buffer.h:894
const T & const_reference
Definition Array.h:114
T & at(size_t index)
Definition Buffer.h:860
iterator begin()
Definition Buffer.h:888
T & operator[](size_t index)
Definition Buffer.h:845
std::random_access_iterator_tag iterator_category
Definition Array.h:118
agxData::Array< T > slice(agx::IndexRange32 subRange) const
Definition Buffer.h:875
ptrdiff_t difference_type
Definition Array.h:119
Abstract representation of a data buffer.
Definition Buffer.h:56
Generic data.
Definition Data.h:40
A format is an implementation of a agxData::Type.
Definition Format.h:64
Only use as member allocated variable.
Definition Value.h:285
Transactions are used to reserve exclusive memory areas in which the threads can write their data.
GlobalResult is used by kernels to generate result data from different threads.
A range of indices.
Definition IndexRange.h:33
Vector containing 'raw' data.
Definition agx/Vector.h:246
Templated vector class.
Definition agx/Vector.h:53
Contains classes for low level data storage for AGX.
Definition Container.h:23
AGXCORE_EXPORT Format * getFormat(const agx::String &typeFormatName)
UInt32 Index
Definition Integer.h:44