Visualization Library 2.1.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Member Functions | Static Public Attributes | Static Protected Member Functions | Protected Attributes | List of all members
vl::Collection< T > Class Template Reference

It's basically an std::vector for Objects that is itself an Object so it can be reference counted and passed around with ease. More...

#include <Collection.hpp>

+ Inheritance diagram for vl::Collection< T >:

Public Member Functions

 Collection (const std::vector< ref< T > > &vector)
 
 Collection ()
 
Collectionoperator= (const std::vector< ref< T > > &vector)
 
 operator std::vector< ref< T > > () const
 
void push_back (T *data)
 
void pop_back ()
 
void resize (size_t size)
 
size_t size () const
 
bool empty () const
 
void clear ()
 
const T * back () const
 
T * back ()
 
void reserve (size_t capacity)
 
size_t capacity () const
 
const ref< T > & operator[] (size_t i) const
 
ref< T > & operator[] (size_t i)
 
const T * at (size_t i) const
 
T * at (size_t i)
 
void swap (Collection &other)
 
void sort ()
 
size_t find (T *obj) const
 
void shrink ()
 
void push_back (const Collection< T > &objs)
 
void insert (size_t start, const Collection< T > &objs)
 
void set (const Collection< T > &objs)
 
void erase (size_t start, size_t count)
 
void set (size_t index, T *obj)
 
void insert (size_t index, T *obj)
 
void erase (const T *data)
 
void eraseAt (size_t index)
 
const std::vector< ref< T > > & vector () const
 
std::vector< ref< T > > & vector ()
 
- Public Member Functions inherited from vl::Object
 Object ()
 Constructor. More...
 
 Object (const Object &other)
 Copy constructor: copies the name, ref count mutex and user data. More...
 
Objectoperator= (const Object &other)
 Copy operator: copies the object's name, ref count mutex and user data. More...
 
const std::string & objectName () const
 The name of the object, by default set to the object's class name. More...
 
void setObjectName (const char *name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setObjectName (const std::string &name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setRefCountMutex (IMutex *mutex)
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
IMutexrefCountMutex ()
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
const IMutexrefCountMutex () const
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
int referenceCount () const
 Returns the number of references of an object. More...
 
void incReference () const
 Increments the reference count of an object. More...
 
void decReference ()
 Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More...
 
void setAutomaticDelete (bool autodel_on)
 If set to true the Object is deleted when its reference count reaches 0. More...
 
bool automaticDelete () const
 If set to true the Object is deleted when its reference count reaches 0. More...
 
template<class T >
T * as ()
 Casts an Object to the specified class. More...
 
template<class T >
const T * as () const
 Casts an Object to the specified class. More...
 

Static Public Attributes

static const size_t not_found = size_t( -1 )
 

Static Protected Member Functions

static bool less (const ref< T > &a, const ref< T > &b)
 

Protected Attributes

std::vector< ref< T > > mVector
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Additional Inherited Members

- Protected Member Functions inherited from vl::Object
virtual ~Object ()
 

Detailed Description

template<typename T>
class vl::Collection< T >

It's basically an std::vector for Objects that is itself an Object so it can be reference counted and passed around with ease.

It has also handy utility functions like sort(), find(), etc. Handy alternative to std::vector< ref< Object > > which becomes Collection<Object>.

Definition at line 49 of file Collection.hpp.

Constructor & Destructor Documentation

◆ Collection() [1/2]

template<typename T>
vl::Collection< T >::Collection ( const std::vector< ref< T > > &  vector)
inline

Definition at line 57 of file Collection.hpp.

◆ Collection() [2/2]

template<typename T>
vl::Collection< T >::Collection ( )
inline

Definition at line 63 of file Collection.hpp.

Member Function Documentation

◆ at() [1/2]

template<typename T>
const T* vl::Collection< T >::at ( size_t  i) const
inline

◆ at() [2/2]

template<typename T>
T* vl::Collection< T >::at ( size_t  i)
inline

Definition at line 105 of file Collection.hpp.

◆ back() [1/2]

template<typename T>
const T* vl::Collection< T >::back ( ) const
inline

Definition at line 91 of file Collection.hpp.

◆ back() [2/2]

template<typename T>
T* vl::Collection< T >::back ( )
inline

Definition at line 93 of file Collection.hpp.

◆ capacity()

template<typename T>
size_t vl::Collection< T >::capacity ( ) const
inline

Definition at line 97 of file Collection.hpp.

◆ clear()

template<typename T>
void vl::Collection< T >::clear ( )
inline

◆ empty()

template<typename T>
bool vl::Collection< T >::empty ( ) const
inline

◆ erase() [1/2]

template<typename T>
void vl::Collection< T >::erase ( size_t  start,
size_t  count 
)
inline

Definition at line 145 of file Collection.hpp.

◆ erase() [2/2]

template<typename T>
void vl::Collection< T >::erase ( const T *  data)
inline

Definition at line 154 of file Collection.hpp.

◆ eraseAt()

template<typename T>
void vl::Collection< T >::eraseAt ( size_t  index)
inline

◆ find()

template<typename T>
size_t vl::Collection< T >::find ( T *  obj) const
inline

Definition at line 116 of file Collection.hpp.

Referenced by vl::ActorTreeAbstract::eraseActor().

◆ insert() [1/2]

template<typename T>
void vl::Collection< T >::insert ( size_t  start,
const Collection< T > &  objs 
)
inline

Definition at line 135 of file Collection.hpp.

◆ insert() [2/2]

template<typename T>
void vl::Collection< T >::insert ( size_t  index,
T *  obj 
)
inline

Definition at line 152 of file Collection.hpp.

◆ less()

template<typename T>
static bool vl::Collection< T >::less ( const ref< T > &  a,
const ref< T > &  b 
)
inlinestaticprotected

Definition at line 169 of file Collection.hpp.

Referenced by vl::Collection< vl::SceneManager >::sort().

◆ operator std::vector< ref< T > >()

template<typename T>
vl::Collection< T >::operator std::vector< ref< T > > ( ) const
inline

Definition at line 74 of file Collection.hpp.

◆ operator=()

template<typename T>
Collection& vl::Collection< T >::operator= ( const std::vector< ref< T > > &  vector)
inline

Definition at line 68 of file Collection.hpp.

◆ operator[]() [1/2]

template<typename T>
const ref<T>& vl::Collection< T >::operator[] ( size_t  i) const
inline

Definition at line 99 of file Collection.hpp.

◆ operator[]() [2/2]

template<typename T>
ref<T>& vl::Collection< T >::operator[] ( size_t  i)
inline

Definition at line 101 of file Collection.hpp.

◆ pop_back()

template<typename T>
void vl::Collection< T >::pop_back ( )
inline

Definition at line 81 of file Collection.hpp.

◆ push_back() [1/2]

template<typename T>
void vl::Collection< T >::push_back ( T *  data)
inline

◆ push_back() [2/2]

template<typename T>
void vl::Collection< T >::push_back ( const Collection< T > &  objs)
inline

Definition at line 130 of file Collection.hpp.

◆ reserve()

template<typename T>
void vl::Collection< T >::reserve ( size_t  capacity)
inline

Definition at line 95 of file Collection.hpp.

Referenced by vl::ActorKdTree::rebuildKdTree().

◆ resize()

template<typename T>
void vl::Collection< T >::resize ( size_t  size)
inline

Definition at line 83 of file Collection.hpp.

Referenced by vl::Rendering::render().

◆ set() [1/2]

template<typename T>
void vl::Collection< T >::set ( const Collection< T > &  objs)
inline

Definition at line 140 of file Collection.hpp.

◆ set() [2/2]

template<typename T>
void vl::Collection< T >::set ( size_t  index,
T *  obj 
)
inline

Definition at line 150 of file Collection.hpp.

◆ shrink()

template<typename T>
void vl::Collection< T >::shrink ( )
inline

Definition at line 125 of file Collection.hpp.

◆ size()

template<typename T>
size_t vl::Collection< T >::size ( ) const
inline

◆ sort()

template<typename T>
void vl::Collection< T >::sort ( )
inline

Definition at line 111 of file Collection.hpp.

◆ swap()

template<typename T>
void vl::Collection< T >::swap ( Collection< T > &  other)
inline

Definition at line 107 of file Collection.hpp.

Referenced by vl::Collection< vl::SceneManager >::shrink().

◆ vector() [1/2]

template<typename T>
const std::vector< ref<T> >& vl::Collection< T >::vector ( ) const
inline

◆ vector() [2/2]

template<typename T>
std::vector< ref<T> >& vl::Collection< T >::vector ( )
inline

Definition at line 166 of file Collection.hpp.

Member Data Documentation

◆ mVector

template<typename T>
std::vector< ref<T> > vl::Collection< T >::mVector
protected

◆ not_found

template<typename T>
const size_t vl::Collection< T >::not_found = size_t( -1 )
static

Definition at line 54 of file Collection.hpp.


The documentation for this class was generated from the following file: