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 | Protected Attributes | List of all members
vl::ResourceDatabase Class Reference

The ResourceDatabase class contains and manipulates a set of resources. More...

#include <ResourceDatabase.hpp>

+ Inheritance diagram for vl::ResourceDatabase:

Public Member Functions

 ResourceDatabase ()
 
const std::vector< ref< Object > > & resources () const
 
std::vector< ref< Object > > & resources ()
 
template<class T >
T * next (int &cur_pos) const
 Starts to look for the next object of the specified type from the given position. More...
 
template<class T >
void get (std::vector< ref< T > > &resources, bool clear_vector=true)
 Returns all the objects of the specified type in the given vector. More...
 
template<class T >
void extract (std::vector< ref< T > > &resources, bool clear_vector=true)
 Returns all the objects of the specified type in the given vector and removes them from the ResourceDatabase. More...
 
template<class T >
size_t count () const
 Don't use inside loops! Counts the number object of the specified type. More...
 
template<class T >
const T * get (int j) const
 Don't use inside loops! Returns the j-th object of the specified type (which is different from resources()[j]!). More...
 
template<class T >
T * get (int j)
 Don't use inside loops! Returns the j-th object of the specified type (which is different from resources()[j]!). More...
 
- 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...
 

Protected Attributes

std::vector< ref< Object > > mResources
 
- 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

The ResourceDatabase class contains and manipulates a set of resources.

It works with any kind of resources derived from vl::Object, even user-customized ones.

Definition at line 48 of file ResourceDatabase.hpp.

Constructor & Destructor Documentation

◆ ResourceDatabase()

vl::ResourceDatabase::ResourceDatabase ( )
inline

Definition at line 53 of file ResourceDatabase.hpp.

Member Function Documentation

◆ count()

template<class T >
size_t vl::ResourceDatabase::count ( ) const
inline

Don't use inside loops! Counts the number object of the specified type.

Definition at line 117 of file ResourceDatabase.hpp.

Referenced by vl::MorphingCallback::init(), vl::LoadWriterTIFF::writeResource(), vl::LoadWriterPNG::writeResource(), vl::LoadWriterTGA::writeResource(), and vl::LoadWriterJPG::writeResource().

◆ extract()

template<class T >
void vl::ResourceDatabase::extract ( std::vector< ref< T > > &  resources,
bool  clear_vector = true 
)
inline

Returns all the objects of the specified type in the given vector and removes them from the ResourceDatabase.

Definition at line 95 of file ResourceDatabase.hpp.

◆ get() [1/3]

template<class T >
void vl::ResourceDatabase::get ( std::vector< ref< T > > &  resources,
bool  clear_vector = true 
)
inline

◆ get() [2/3]

template<class T >
const T* vl::ResourceDatabase::get ( int  j) const
inline

Don't use inside loops! Returns the j-th object of the specified type (which is different from resources()[j]!).

Definition at line 131 of file ResourceDatabase.hpp.

References NULL.

◆ get() [3/3]

template<class T >
T* vl::ResourceDatabase::get ( int  j)
inline

Don't use inside loops! Returns the j-th object of the specified type (which is different from resources()[j]!).

Definition at line 150 of file ResourceDatabase.hpp.

References NULL.

◆ next()

template<class T >
T* vl::ResourceDatabase::next ( int &  cur_pos) const
inline

Starts to look for the next object of the specified type from the given position.

Definition at line 64 of file ResourceDatabase.hpp.

References vl::ref< T >::get(), and NULL.

◆ resources() [1/2]

const std::vector< ref<Object> >& vl::ResourceDatabase::resources ( ) const
inline

◆ resources() [2/2]

std::vector< ref<Object> >& vl::ResourceDatabase::resources ( )
inline

Definition at line 60 of file ResourceDatabase.hpp.

Member Data Documentation

◆ mResources

std::vector< ref<Object> > vl::ResourceDatabase::mResources
protected

Definition at line 168 of file ResourceDatabase.hpp.


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