Visualization Library 2.0.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 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 (int size)
 
int size () const
 
bool empty () const
 
void clear ()
 
const T * back () const
 
T * back ()
 
void reserve (int capacity)
 
int capacity () const
 
const ref< T > & operator[] (int i) const
 
ref< T > & operator[] (int i)
 
const T * at (int i) const
 
T * at (int i)
 
void swap (Collection &other)
 
void sort ()
 
int find (T *obj) const
 
void shrink ()
 
void push_back (const Collection< T > &objs)
 
void insert (int start, const Collection< T > &objs)
 
void set (const Collection< T > &objs)
 
void erase (int start, int count)
 
void set (int index, T *obj)
 
void insert (int index, T *obj)
 
void erase (const T *data)
 
void eraseAt (int 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 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 54 of file Collection.hpp.

◆ Collection() [2/2]

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

Definition at line 60 of file Collection.hpp.

Member Function Documentation

◆ at() [1/2]

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

◆ at() [2/2]

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

Definition at line 102 of file Collection.hpp.

◆ back() [1/2]

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

Definition at line 88 of file Collection.hpp.

◆ back() [2/2]

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

Definition at line 90 of file Collection.hpp.

◆ capacity()

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

Definition at line 94 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 ( int  start,
int  count 
)
inline

Definition at line 142 of file Collection.hpp.

◆ erase() [2/2]

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

Definition at line 151 of file Collection.hpp.

◆ eraseAt()

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

◆ find()

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

Definition at line 113 of file Collection.hpp.

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

◆ insert() [1/2]

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

Definition at line 132 of file Collection.hpp.

◆ insert() [2/2]

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

Definition at line 149 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 166 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 71 of file Collection.hpp.

◆ operator=()

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

Definition at line 65 of file Collection.hpp.

◆ operator[]() [1/2]

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

Definition at line 96 of file Collection.hpp.

◆ operator[]() [2/2]

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

Definition at line 98 of file Collection.hpp.

◆ pop_back()

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

Definition at line 78 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 127 of file Collection.hpp.

◆ reserve()

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

Definition at line 92 of file Collection.hpp.

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

◆ resize()

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

Definition at line 80 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 137 of file Collection.hpp.

◆ set() [2/2]

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

Definition at line 147 of file Collection.hpp.

◆ shrink()

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

Definition at line 122 of file Collection.hpp.

◆ size()

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

◆ sort()

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

Definition at line 108 of file Collection.hpp.

◆ swap()

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

Definition at line 104 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 163 of file Collection.hpp.

Member Data Documentation

◆ mVector

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

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