Rumba C++ SDK
IndexedBuffer.h
Go to the documentation of this file.
1 /*
2 
3  *
4  ***
5  *****
6  ********************* Mercenaries Engineering SARL
7  ***************** Copyright (C) 2018
8  *************
9  ********* http://www.mercenaries-engineering.com
10  ***********
11  **** ****
12  ** **
13 
14 */
15 #pragma once
16 
17 #include "Value.h"
18 #include "Buffer.h"
19 
20  namespace maquina
21  {
23  template<typename T>
24  class IndexedBufferConst : public Value
25  {
26  public:
27  typedef T value_type;
28 
30 
31  IndexedBufferConst(const Value &v);
32 
34  IndexedBufferConst(const gsl::span<const uint32_t>& indices, const gsl::span<const T>& values);
35 
36  static bool can_cast(const Value &v);
37 
39  bool empty() const;
40 
42  size_t size() const;
43 
45  gsl::span<const uint32_t> read_indices() const;
46 
48  gsl::span<const value_type> read_values() const;
49 
51  IndexedBufferConst(const std::shared_ptr<Impl> &impl) : Value(impl) {}
52  };
53 
55  template<typename T>
57  {
58  public:
59  typedef T value_type;
60 
63  size_t indices,
64  size_t values
65  );
66 
68  gsl::span<uint32_t> write_indices();
69 
71  gsl::span<value_type> write_values();
72 
74  IndexedBuffer(const std::shared_ptr<Impl> &impl) : IndexedBufferConst<T>(impl) {}
75  };
76 
90 
91 #ifndef kernel_EXPORTS
105 #endif // kernel_EXPORTS
106 
112  typedef IndexedBuffer<Imath::V2f> IndexedBufferV2f;
113  typedef IndexedBuffer<Imath::V3f> IndexedBufferV3f;
114  typedef IndexedBuffer<Imath::V4f> IndexedBufferV4f;
115  typedef IndexedBuffer<Imath::V2i> IndexedBufferV2i;
116  typedef IndexedBuffer<Imath::V3i> IndexedBufferV3i;
117  typedef IndexedBuffer<Imath::V4i> IndexedBufferV4i;
118  typedef IndexedBuffer<Imath::M44f> IndexedBufferM44f;
119  typedef IndexedBuffer<Imath::Box3f> IndexedBufferBox3f;
120 
121 #ifndef kernel_EXPORTS
135 #endif // kernel_EXPORTS
136  }
IndexedBufferConst< Imath::V2i > IndexedBufferConstV2i
Definition: IndexedBuffer.h:85
size_t size() const
Return the indexed buffer size.
IndexedBufferConst< int32_t > IndexedBufferConstInt32
Definition: IndexedBuffer.h:77
IndexedBufferConst< Imath::Box3f > IndexedBufferConstBox3f
Definition: IndexedBuffer.h:89
static bool can_cast(const Value &v)
IndexedBufferConst< uint8_t > IndexedBufferConstUInt8
Definition: IndexedBuffer.h:78
gsl::span< const value_type > read_values() const
Return a readable accessor on the indices buffer.
A read only buffer of indexed values. It is composed of a buffer of indexes of the size of the compon...
Definition: IndexedBuffer.h:24
T value_type
Definition: IndexedBuffer.h:27
gsl::span< value_type > write_values()
Return a writable accessor on the indices buffer.
IndexedBufferConst< Imath::V3f > IndexedBufferConstV3f
Definition: IndexedBuffer.h:83
This version of the SDK is unstable, i-e, it may change with no warning.
Definition: AddCurveAction.h:20
IndexedBufferConst(const Value &v)
Cast a Value object in IndexedBufferConst.
T value_type
Definition: IndexedBuffer.h:59
bool empty() const
Resize true if this indexed buffer is empty.
IndexedBufferConst< double > IndexedBufferConstDouble
Definition: IndexedBuffer.h:81
IndexedBuffer(size_t indices, size_t values)
Allocate a buffer.
IndexedBufferConst< Imath::V4i > IndexedBufferConstV4i
Definition: IndexedBuffer.h:87
#define MAQUINA_EXPORT
Definition: Export.h:31
gsl::span< const uint32_t > read_indices() const
Return a readable accessor on the indices buffer.
IndexedBufferConst< float > IndexedBufferConstFloat
Definition: IndexedBuffer.h:80
IndexedBufferConst< uint32_t > IndexedBufferConstUInt32
Definition: IndexedBuffer.h:79
IndexedBufferConst< Imath::V4f > IndexedBufferConstV4f
Definition: IndexedBuffer.h:84
IndexedBufferConst< Imath::M44f > IndexedBufferConstM44f
Definition: IndexedBuffer.h:88
#define MAQUINA_EXTERN_TEMPLATE
Definition: Export.h:25
gsl::span< uint32_t > write_indices()
Return a writable accessor on the indices buffer.
Definition: ImathBox.h:67
IndexedBufferConst< Imath::V3i > IndexedBufferConstV3i
Definition: IndexedBuffer.h:86
Vec2< float > V2f
Definition: ImathVec.h:688
A writable IndexedBuffer.
Definition: IndexedBuffer.h:56
IndexedBufferConst< Imath::V2f > IndexedBufferConstV2f
Definition: IndexedBuffer.h:82
Base class of all Rumba values.
Definition: Value.h:34