AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
Container.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 AGX_CONTAINER_H
18#define AGX_CONTAINER_H
19
20#include <agx/macros.h>
21#include <agx/agxCore_export.h>
22
23namespace agxData { class Buffer; }
24
25namespace agx
26{
27 class ThreadScopeAllocator;
28
29
35 {
36 public:
37
48
49 public:
50
52 size_t size() const;
53
63 size_t capacity() const;
64
66 bool empty() const;
67
69 void* ptr();
70 const void* ptr() const;
71
72
73 public:
74
76
77
80 void _setBuffer(void* buffer) { m_buffer = buffer; }
81 void _setCapacity(size_t capacity) { m_capacity = capacity; }
82 void _setSize(size_t size) { m_size = size; }
84
85 protected:
86 Container();
87 Container(Container&& other);
88 Container(const Container& other);
89 ~Container();
90
91 protected:
92 friend class agxData::Buffer;
93 friend class Thread;
94 size_t m_size;
95 size_t m_capacity;
96 void* m_buffer;
97 };
98
99
100
101 /* Implementation */
102 AGX_FORCE_INLINE Container::Container() : m_size(0), m_capacity(0), m_buffer(nullptr) {}
103 AGX_FORCE_INLINE Container::Container(const Container& other)
104 : m_size(0), m_capacity(0), m_buffer(nullptr)
105 {
106 m_size = other.m_size;
107 m_buffer = other.m_buffer;
108 m_capacity = other.m_capacity;
109 }
110
112 m_size(0),
113 m_capacity(0),
114 m_buffer(nullptr)
115 {
116 // Move values
117 m_buffer = other.m_buffer;
118 m_capacity = other.m_capacity;
119 m_size = other.m_size;
120
121 // Set default values to the rvalue reference.
122 other.m_buffer = nullptr;
123 other.m_capacity = 0;
124 other.m_size = 0;
125 }
126
128 {
129 m_buffer = nullptr;
130 m_size = 0;
131 m_capacity = 0;
132 }
133
134 AGX_FORCE_INLINE size_t Container::size() const { return m_size; }
136 AGX_FORCE_INLINE bool Container::empty() const { return m_size == 0; }
138 AGX_FORCE_INLINE const void *Container::ptr() const { return m_buffer; }
139}
140
141
142#endif /* _AGX_CONTAINER_H_ */
#define AGXCORE_EXPORT
#define m_size
Definition agx/Vector.h:429
#define m_capacity
Definition agx/Vector.h:430
Abstract representation of a data buffer.
Definition Buffer.h:56
The Container is the base class for several of the container classes proided by AGX,...
Definition Container.h:35
size_t m_size
Definition Container.h:94
size_t m_capacity
Definition Container.h:95
bool empty() const
Definition Container.h:136
ClearPolicy
agxData::Values from this enumeration is passed to the subclasses' 'clear' method in order to control...
Definition Container.h:43
@ SHRINK_BUFFER
Buffer is deallocated and replaced by an newly allocated empty buffer.
Definition Container.h:44
@ SHRINK_BUFFER_AVERAGED
Buffer is shrunk if a smoothing average (which is updated each clear call) goes below a threshold.
Definition Container.h:45
void * ptr()
Definition Container.h:137
size_t capacity() const
Returns the size of the memory are used by the container to store its elements.
Definition Container.h:135
void * m_buffer
Definition Container.h:96
size_t size() const
Definition Container.h:134
agx::Thread is a representation of an OS specific implementation of a computational thread.
Definition Thread.h:199
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition macros.h:97
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition macros.h:96
#define AGX_FORCE_INLINE
Definition macros.h:58
Contains classes for low level data storage for AGX.
Definition Container.h:23
The agx namespace contains the dynamics/math part of the AGX Dynamics API.