15 #ifndef POINTERTOARRAY_H
16 #define POINTERTOARRAY_H
67 #include "pandabase.h"
69 #include "pointerToArrayBase.h"
71 #if (defined(WIN32_VC) || defined(WIN64_VC)) && !defined(__INTEL_COMPILER)
74 #pragma warning (disable : 4506)
77 template <
class Element>
98 template <
class Element>
112 EXTENSION(PointerToArray(PyObject *
self, PyObject *source));
114 INLINE size_type size()
const;
115 INLINE
void push_back(
const Element &x);
116 INLINE
void pop_back();
117 INLINE
const Element &
get_element(size_type n)
const;
118 INLINE
void set_element(size_type n,
const Element &value);
119 EXTENSION(
const Element &__getitem__(size_type n)
const);
120 EXTENSION(
void __setitem__(size_type n,
const Element &value));
122 INLINE
void set_data(
const string &data);
123 INLINE
string get_subdata(size_type n, size_type count)
const;
124 INLINE
void set_subdata(size_type n, size_type count,
const string &data);
129 #if PY_VERSION_HEX >= 0x02060000
130 EXTENSION(
int __getbuffer__(PyObject *
self, Py_buffer *view,
int flags));
131 EXTENSION(
void __releasebuffer__(PyObject *
self, Py_buffer *view)
const);
137 typedef TYPENAME PointerToArrayBase<Element>::To To;
149 INLINE PointerToArray(
TypeHandle type_handle = get_type_handle(Element));
151 INLINE PointerToArray(size_type n,
const Element &value,
TypeHandle type_handle = get_type_handle(Element));
154 #ifdef USE_MOVE_SEMANTICS
164 INLINE iterator begin()
const;
165 INLINE iterator end()
const;
166 INLINE TYPENAME PointerToArray<Element>::reverse_iterator rbegin()
const;
167 INLINE TYPENAME PointerToArray<Element>::reverse_iterator rend()
const;
171 INLINE size_type size()
const;
172 INLINE size_type max_size()
const;
173 INLINE
bool empty()
const;
176 INLINE
void reserve(size_type n);
177 INLINE
void resize(size_type n);
178 INLINE size_type capacity()
const;
179 INLINE reference front()
const;
180 INLINE reference back()
const;
181 INLINE iterator insert(iterator position,
const Element &x);
182 INLINE
void insert(iterator position, size_type n,
const Element &x);
191 INLINE
void erase(iterator position);
192 INLINE
void erase(iterator first, iterator last);
194 #if !defined(WIN32_VC) && !defined (WIN64_VC)
195 INLINE reference operator [](size_type n)
const;
196 INLINE reference operator [](
int n)
const;
199 INLINE
void push_back(
const Element &x);
200 INLINE
void pop_back();
203 INLINE
operator Element *()
const;
204 INLINE Element *
p()
const;
209 INLINE
const Element &
get_element(size_type n)
const;
210 INLINE
void set_element(size_type n,
const Element &value);
212 INLINE
void set_data(
const string &data);
213 INLINE
string get_subdata(size_type n, size_type count)
const;
214 INLINE
void set_subdata(size_type n, size_type count,
const string &data);
226 INLINE
void ref()
const;
227 INLINE
bool unref()
const;
239 #ifdef USE_MOVE_SEMANTICS
266 template <
class Element>
281 INLINE size_type size()
const;
282 INLINE
const Element &
get_element(size_type n)
const;
283 EXTENSION(
const Element &__getitem__(size_type n)
const);
285 INLINE
string get_subdata(size_type n, size_type count)
const;
290 #if PY_VERSION_HEX >= 0x02060000
291 EXTENSION(
int __getbuffer__(PyObject *
self, Py_buffer *view,
int flags)
const);
292 EXTENSION(
void __releasebuffer__(PyObject *
self, Py_buffer *view)
const);
298 typedef TYPENAME PointerToArrayBase<Element>::To To;
304 #if defined(WIN32_VC) || defined(WIN64_VC)
318 #ifdef USE_MOVE_SEMANTICS
325 INLINE iterator begin()
const;
326 INLINE iterator end()
const;
327 INLINE TYPENAME ConstPointerToArray<Element>::reverse_iterator rbegin()
const;
328 INLINE TYPENAME ConstPointerToArray<Element>::reverse_iterator rend()
const;
333 INLINE size_type size()
const;
334 INLINE size_type max_size()
const;
335 INLINE
bool empty()
const;
338 INLINE size_type capacity()
const;
339 INLINE reference front()
const;
340 INLINE reference back()
const;
342 #if !defined(WIN32_VC) && !defined(WIN64_VC)
343 INLINE reference operator [](size_type n)
const;
344 INLINE reference operator [](
int n)
const;
347 INLINE
operator const Element *()
const;
348 INLINE
const Element *
p()
const;
354 INLINE
const Element &
get_element(size_type n)
const;
356 INLINE
string get_subdata(size_type n, size_type count)
const;
359 INLINE
void ref()
const;
360 INLINE
bool unref()
const;
374 #ifdef USE_MOVE_SEMANTICS
399 #define PTA(type) PointerToArray< type >
400 #define CPTA(type) ConstPointerToArray< type >
402 #include "pointerToArray.I"
404 #endif // HAVE_POINTERTOARRAY_H
int get_node_ref_count() const
Returns the node_ref of the underlying vector.
int get_node_ref_count() const
Returns the node_ref of the underlying vector.
const pvector< Element > & v() const
To access the vector itself, for more direct fiddling with some of the vector's esoteric functionalit...
void * get_void_ptr() const
Returns the reference to memory where the vector is stored.
const Element * p() const
Function p() is similar to the function from ConstPointerTo.
void clear()
To empty the PTA, use the clear() method, since assignment to NULL is problematic (given the ambiguit...
const Element & get_element(size_type n) const
This method exists mainly to access the elements of the array easily from a high-level language such ...
int get_ref_count() const
Returns the reference count of the underlying vector.
bool node_unref() const
Decrements the node_ref of the underlying vector.
void node_ref() const
Increments the node_ref of the underlying vector.
void set_element(size_type n, const Element &value)
This method exists mainly to access the elements of the array easily from a high-level language such ...
A special kind of PointerTo that stores an array of the indicated element type, instead of a single e...
string get_subdata(size_type n, size_type count) const
This method exists mainly to access the data of the array easily from a high-level language such as P...
bool unref() const
Decrements the reference count of the underlying vector.
void ref() const
Increments the reference count of the underlying vector.
static PointerToArray< Element > empty_array(size_type n, TypeHandle type_handle=get_type_handle(Element))
Return an empty array of size n.
int get_ref_count() const
Returns the reference count of the underlying vector.
This is our own Panda specialization on the default STL vector.
void make_empty()
Empties the array pointed to.
void set_void_ptr(void *p)
Sets this PTA to point to the pointer passed in.
void set_data(const string &data)
This method exists mainly to access the data of the array easily from a high-level language such as P...
void node_ref() const
Increments the node_ref of the underlying vector.
pvector< Element > & v() const
To access the vector itself, for more direct fiddling with some of the vector's esoteric functionalit...
This is the base class for PointerToArray and ConstPointerToArray.
void set_subdata(size_type n, size_type count, const string &data)
This method exists mainly to access the data of the array easily from a high-level language such as P...
void clear()
To empty the PTA, use the clear() method, since assignment to NULL is problematic (given the ambiguit...
const ReferenceCountedVector< Element > * v0() const
To access the internal ReferenceCountedVector object, for very low-level fiddling.
PointerToArray< Element > cast_non_const() const
Casts away the constness of the CPTA(Element), and returns an equivalent PTA(Element).
string get_subdata(size_type n, size_type count) const
This method exists mainly to access the data of the array easily from a high-level language such as P...
string get_data() const
This method exists mainly to access the data of the array easily from a high-level language such as P...
void ref() const
Increments the reference count of the underlying vector.
bool node_unref() const
Decrements the node_ref of the underlying vector.
ReferenceCountedVector< Element > * v0() const
To access the internal ReferenceCountedVector object, for very low-level fiddling.
TypeHandle is the identifier used to differentiate C++ class types.
string get_data() const
This method exists mainly to access the data of the array easily from a high-level language such as P...
const Element & get_element(size_type n) const
This method exists mainly to access the elements of the array easily from a high-level language such ...
This defines the object that is actually stored and reference-counted internally by a PointerToArray...
Element * p() const
Function p() is similar to the function from PointerTo.
bool unref() const
Decrements the reference count of the underlying vector.
Similar to PointerToArray, except that its contents may not be modified.