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::LoadWriterManager Class Reference

The LoadWriterManager class loads and writes resources using the registered ResourceLoadWriter objects. More...

#include <LoadWriterManager.hpp>

+ Inheritance diagram for vl::LoadWriterManager:

Public Member Functions

 LoadWriterManager ()
 
void registerLoadWriter (ResourceLoadWriter *)
 
std::vector< ref< ResourceLoadWriter > > & loadWriters ()
 Returns the set of registered ResourceLoadWriter objects. More...
 
const std::vector< ref< ResourceLoadWriter > > & loadWriters () const
 Returns the set of registered ResourceLoadWriter objects. More...
 
template<class T >
T * loadWriter ()
 Returns the first ResourceLoadWriter of the specified type found. More...
 
bool canLoad (const String &path) const
 Returns true if there is a ResourceLoadWriter registered to load the specified path or extension. More...
 
bool canLoad (VirtualFile *file) const
 Returns true if there is a ResourceLoadWriter registered to load the specified file. More...
 
bool canWrite (const String &path) const
 Returns true if there is a ResourceLoadWriter registered to write the specified path or extension. More...
 
bool canWrite (VirtualFile *file) const
 Returns true if there is a ResourceLoadWriter registered to write the specified file. More...
 
const ResourceLoadWriterfindLoader (const String &path) const
 Returns the ResourceLoadWriter that has been registered to load the resource type specified by the given path or extension. More...
 
const ResourceLoadWriterfindWriter (const String &path) const
 Returns the ResourceLoadWriter that has been registered to write the resource type specified by the given path or extension. More...
 
const ResourceLoadWriterfindLoader (VirtualFile *file) const
 Returns the ResourceLoadWriter that has been registered to load the resource type specified by the given file. More...
 
const ResourceLoadWriterfindWriter (VirtualFile *file) const
 Returns the ResourceLoadWriter that has been registered to write the resource type specified by the given file. More...
 
ref< ResourceDatabaseloadResource (const String &path, bool quick=true) const
 Loads the resource specified by the given path using the appropriate ResourceLoadWriter. More...
 
ref< ResourceDatabaseloadResource (VirtualFile *file, bool quick=true) const
 Loads the resource specified by the given file using the appropriate ResourceLoadWriter. More...
 
bool writeResource (const String &path, ResourceDatabase *resource) const
 Writes the resource specified by the given file using the appropriate ResourceLoadWriter. More...
 
bool writeResource (VirtualFile *file, ResourceDatabase *resource) const
 Writes the resource specified by the given file using the appropriate ResourceLoadWriter. More...
 
const std::vector< ref< LoadCallback > > & loadCallbacks () const
 
const std::vector< ref< WriteCallback > > & writeCallbacks () const
 
std::vector< ref< LoadCallback > > & loadCallbacks ()
 
std::vector< ref< WriteCallback > > & writeCallbacks ()
 
- 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< ResourceLoadWriter > > mLoadWriters
 
std::vector< ref< LoadCallback > > mLoadCallbacks
 
std::vector< ref< WriteCallback > > mWriteCallbacks
 
- 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 LoadWriterManager class loads and writes resources using the registered ResourceLoadWriter objects.

You can install a LoadCallback to operate on loaded data or you can install a WriteCallback to operate on the data to be written, using the methods loadCallbacks() and writeCallbacks().

Definition at line 60 of file LoadWriterManager.hpp.

Constructor & Destructor Documentation

◆ LoadWriterManager()

vl::LoadWriterManager::LoadWriterManager ( )
inline

Definition at line 65 of file LoadWriterManager.hpp.

References vl::registerLoadWriter().

Member Function Documentation

◆ canLoad() [1/2]

bool vl::LoadWriterManager::canLoad ( const String path) const
inline

Returns true if there is a ResourceLoadWriter registered to load the specified path or extension.

Definition at line 92 of file LoadWriterManager.hpp.

References NULL.

Referenced by vl::canLoad().

◆ canLoad() [2/2]

bool vl::LoadWriterManager::canLoad ( VirtualFile file) const
inline

Returns true if there is a ResourceLoadWriter registered to load the specified file.

Definition at line 95 of file LoadWriterManager.hpp.

References NULL, and vl::VirtualFile::path().

◆ canWrite() [1/2]

bool vl::LoadWriterManager::canWrite ( const String path) const
inline

Returns true if there is a ResourceLoadWriter registered to write the specified path or extension.

Definition at line 98 of file LoadWriterManager.hpp.

References NULL.

Referenced by vl::canWrite().

◆ canWrite() [2/2]

bool vl::LoadWriterManager::canWrite ( VirtualFile file) const
inline

Returns true if there is a ResourceLoadWriter registered to write the specified file.

Definition at line 101 of file LoadWriterManager.hpp.

References vl::loadResource(), NULL, vl::VirtualFile::path(), and vl::writeResource().

◆ findLoader() [1/2]

const ResourceLoadWriter * LoadWriterManager::findLoader ( const String path) const

Returns the ResourceLoadWriter that has been registered to load the resource type specified by the given path or extension.

Definition at line 156 of file LoadWriterManager.cpp.

References vl::ResourceLoadWriter::canLoad(), vl::String::extractFileExtension(), loadWriters(), NULL, and vl::String::toLowerCase().

Referenced by findLoader(), and loadResource().

◆ findLoader() [2/2]

const ResourceLoadWriter * LoadWriterManager::findLoader ( VirtualFile file) const

Returns the ResourceLoadWriter that has been registered to load the resource type specified by the given file.

Definition at line 41 of file LoadWriterManager.cpp.

References vl::String::empty(), findLoader(), vl::VirtualFile::path(), and vl::Log::warning().

◆ findWriter() [1/2]

const ResourceLoadWriter * LoadWriterManager::findWriter ( const String path) const

Returns the ResourceLoadWriter that has been registered to write the resource type specified by the given path or extension.

Definition at line 168 of file LoadWriterManager.cpp.

References vl::String::extractFileExtension(), loadWriters(), NULL, and vl::String::toLowerCase().

Referenced by findWriter(), and writeResource().

◆ findWriter() [2/2]

const ResourceLoadWriter * LoadWriterManager::findWriter ( VirtualFile file) const

Returns the ResourceLoadWriter that has been registered to write the resource type specified by the given file.

Definition at line 48 of file LoadWriterManager.cpp.

References vl::String::empty(), findWriter(), vl::VirtualFile::path(), and vl::Log::warning().

◆ loadCallbacks() [1/2]

const std::vector< ref<LoadCallback> >& vl::LoadWriterManager::loadCallbacks ( ) const
inline

Definition at line 127 of file LoadWriterManager.hpp.

Referenced by loadResource().

◆ loadCallbacks() [2/2]

std::vector< ref<LoadCallback> >& vl::LoadWriterManager::loadCallbacks ( )
inline

Definition at line 131 of file LoadWriterManager.hpp.

◆ loadResource() [1/2]

ref< ResourceDatabase > LoadWriterManager::loadResource ( const String path,
bool  quick = true 
) const

◆ loadResource() [2/2]

ref< ResourceDatabase > LoadWriterManager::loadResource ( VirtualFile file,
bool  quick = true 
) const

◆ loadWriter()

template<class T >
T* vl::LoadWriterManager::loadWriter ( )
inline

Returns the first ResourceLoadWriter of the specified type found.

Definition at line 80 of file LoadWriterManager.hpp.

References NULL.

◆ loadWriters() [1/2]

std::vector< ref<ResourceLoadWriter> >& vl::LoadWriterManager::loadWriters ( )
inline

Returns the set of registered ResourceLoadWriter objects.

Definition at line 73 of file LoadWriterManager.hpp.

Referenced by findLoader(), findWriter(), and registerLoadWriter().

◆ loadWriters() [2/2]

const std::vector< ref<ResourceLoadWriter> >& vl::LoadWriterManager::loadWriters ( ) const
inline

Returns the set of registered ResourceLoadWriter objects.

Definition at line 76 of file LoadWriterManager.hpp.

◆ registerLoadWriter()

void LoadWriterManager::registerLoadWriter ( ResourceLoadWriter load_writer)

Definition at line 178 of file LoadWriterManager.cpp.

References loadWriters().

Referenced by vl::registerLoadWriter().

◆ writeCallbacks() [1/2]

const std::vector< ref<WriteCallback> >& vl::LoadWriterManager::writeCallbacks ( ) const
inline

Definition at line 129 of file LoadWriterManager.hpp.

Referenced by writeResource().

◆ writeCallbacks() [2/2]

std::vector< ref<WriteCallback> >& vl::LoadWriterManager::writeCallbacks ( )
inline

Definition at line 133 of file LoadWriterManager.hpp.

◆ writeResource() [1/2]

bool LoadWriterManager::writeResource ( const String path,
ResourceDatabase resource 
) const

Writes the resource specified by the given file using the appropriate ResourceLoadWriter.

Definition at line 120 of file LoadWriterManager.cpp.

References vl::Log::error(), findWriter(), writeCallbacks(), and vl::ResourceLoadWriter::writeResource().

Referenced by vl::saveImage(), and vl::writeResource().

◆ writeResource() [2/2]

bool LoadWriterManager::writeResource ( VirtualFile file,
ResourceDatabase resource 
) const

Writes the resource specified by the given file using the appropriate ResourceLoadWriter.

Definition at line 138 of file LoadWriterManager.cpp.

References vl::Log::error(), findWriter(), vl::VirtualFile::path(), writeCallbacks(), and vl::ResourceLoadWriter::writeResource().

Member Data Documentation

◆ mLoadCallbacks

std::vector< ref<LoadCallback> > vl::LoadWriterManager::mLoadCallbacks
protected

Definition at line 137 of file LoadWriterManager.hpp.

◆ mLoadWriters

std::vector< ref<ResourceLoadWriter> > vl::LoadWriterManager::mLoadWriters
protected

Definition at line 136 of file LoadWriterManager.hpp.

◆ mWriteCallbacks

std::vector< ref<WriteCallback> > vl::LoadWriterManager::mWriteCallbacks
protected

Definition at line 138 of file LoadWriterManager.hpp.


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