Visualization Library 2.0.0-b3

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

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Types | Public Member Functions | List of all members
vl::VLXSerializer Class Reference

Translates an arbitrary set of vl::Object (and subclasses) into VLB and VLT format. More...

#include <VLXSerializer.hpp>

+ Inheritance diagram for vl::VLXSerializer:

Public Types

enum  EError {
  NoError, ImportError, ExportError, ReadError,
  WriteError
}
 

Public Member Functions

 VLXSerializer ()
 
const char * errorString () const
 
bool saveVLT (const String &path, const Object *obj, bool start_fresh=true)
 
bool saveVLT (VirtualFile *file, const Object *obj, bool start_fresh=true)
 
bool saveVLB (const String &path, const Object *obj, bool start_fresh=true)
 
bool saveVLB (VirtualFile *file, const Object *obj, bool start_fresh=true)
 
ref< ObjectloadVLT (const String &path, bool start_fresh=true)
 
ref< ObjectloadVLT (VirtualFile *file, bool start_fresh=true)
 
ref< ObjectloadVLB (const String &path, bool start_fresh=true)
 
ref< ObjectloadVLB (VirtualFile *file, bool start_fresh=true)
 
ObjectimportVLX (const VLXStructure *st)
 
VLXStructureexportVLX (const Object *obj)
 
bool canExport (const Object *obj) const
 
bool canImport (const VLXStructure *st) const
 
void registerImportedStructure (const VLXStructure *st, Object *obj)
 
void registerExportedObject (const Object *obj, VLXStructure *st)
 
ObjectgetImportedStructure (const VLXStructure *st)
 
VLXStructuregetExportedObject (const Object *obj)
 
VLXRegistryregistry ()
 The VLXRegistry used by the serializer, by default set to vl::defVLXRegistry(). More...
 
const VLXRegistryregistry () const
 The VLXRegistry used by the serializer, by default set to vl::defVLXRegistry(). More...
 
void setRegistry (const VLXRegistry *registry)
 The VLXRegistry used by the serializer, by default set to vl::defVLXRegistry(). More...
 
std::map< std::string, VLXValue > & metadata ()
 The metadata to be imported or exported. More...
 
const std::map< std::string, VLXValue > & metadata () const
 The metadata to be imported or exported. More...
 
VLXValuegetMetadata (const char *key)
 Returns the value of the given metadata key or NULL if no such metadata was found. More...
 
const VLXValuegetMetadata (const char *key) const
 Returns the value of the given metadata key or NULL if no such metadata was found. More...
 
void reset ()
 
std::string generateID (const char *prefix)
 
void setError (EError err)
 Sets a serialization error. More...
 
EError error () const
 The last signaled error. More...
 
void signalImportError (const String &str)
 
void signalExportError (const String &str)
 
void setDocumentURL (const String &location)
 The URL of the document used to resolve document-relative file paths. More...
 
const StringdocumentURL () const
 The URL of the document used to resolve document-relative file paths. More...
 
void resolvePath (std::string &path)
 If the given path starts with "this:" then the "this:" prefix is replaced with the documentURL(), otherwise the path is left unchanged. More...
 
void setDirective (const char *directive, const char *value)
 Sets a serialization directive that can be used by VLXClassWrapper objects to program the serialization process. More...
 
void eraseDirective (const char *directive)
 Removes a serialization directive. More...
 
const std::string & directive (const char *directive) const
 Returns the value of a serialization directive. More...
 
bool hasDirective (const char *directive)
 Returns true if the given directive has been set. More...
 
void eraseAllDirectives ()
 Erases all previously set directives. 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...
 

Additional Inherited Members

- Protected Member Functions inherited from vl::Object
virtual ~Object ()
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Detailed Description

Translates an arbitrary set of vl::Object (and subclasses) into VLB and VLT format.

Definition at line 45 of file VLXSerializer.hpp.

Member Enumeration Documentation

◆ EError

Enumerator
NoError 
ImportError 
ExportError 
ReadError 
WriteError 

Definition at line 50 of file VLXSerializer.hpp.

Constructor & Destructor Documentation

◆ VLXSerializer()

vl::VLXSerializer::VLXSerializer ( )
inline

Member Function Documentation

◆ canExport()

bool VLXSerializer::canExport ( const Object obj) const

◆ canImport()

bool VLXSerializer::canImport ( const VLXStructure st) const

◆ directive()

const std::string& vl::VLXSerializer::directive ( const char *  directive) const
inline

Returns the value of a serialization directive.

Definition at line 164 of file VLXSerializer.hpp.

◆ documentURL()

const String& vl::VLXSerializer::documentURL ( ) const
inline

The URL of the document used to resolve document-relative file paths.

Definition at line 151 of file VLXSerializer.hpp.

Referenced by resolvePath().

◆ eraseAllDirectives()

void vl::VLXSerializer::eraseAllDirectives ( )
inline

Erases all previously set directives.

Definition at line 178 of file VLXSerializer.hpp.

◆ eraseDirective()

void vl::VLXSerializer::eraseDirective ( const char *  directive)
inline

Removes a serialization directive.

Definition at line 161 of file VLXSerializer.hpp.

◆ error()

EError vl::VLXSerializer::error ( ) const
inline

The last signaled error.

Definition at line 141 of file VLXSerializer.hpp.

Referenced by exportVLX(), importVLX(), vl::loadVLB(), vl::loadVLT(), vl::saveVLB(), vl::saveVLT(), signalExportError(), and signalImportError().

◆ errorString()

const char * VLXSerializer::errorString ( ) const

Definition at line 425 of file VLXSeriailzer.cpp.

References ExportError, ImportError, NoError, ReadError, and WriteError.

Referenced by vl::loadVLB(), vl::loadVLT(), vl::saveVLB(), and vl::saveVLT().

◆ exportVLX()

VLXStructure * VLXSerializer::exportVLX ( const Object obj)

◆ generateID()

std::string VLXSerializer::generateID ( const char *  prefix)

◆ getExportedObject()

VLXStructure * VLXSerializer::getExportedObject ( const Object obj)

Definition at line 163 of file VLXSeriailzer.cpp.

References NULL, and VL_CHECK.

Referenced by exportVLX().

◆ getImportedStructure()

Object * VLXSerializer::getImportedStructure ( const VLXStructure st)

Definition at line 151 of file VLXSeriailzer.cpp.

References NULL, and VL_CHECK.

Referenced by importVLX().

◆ getMetadata() [1/2]

VLXValue* vl::VLXSerializer::getMetadata ( const char *  key)
inline

Returns the value of the given metadata key or NULL if no such metadata was found.

Definition at line 108 of file VLXSerializer.hpp.

References NULL.

◆ getMetadata() [2/2]

const VLXValue* vl::VLXSerializer::getMetadata ( const char *  key) const
inline

Returns the value of the given metadata key or NULL if no such metadata was found.

Definition at line 118 of file VLXSerializer.hpp.

References NULL.

◆ hasDirective()

bool vl::VLXSerializer::hasDirective ( const char *  directive)
inline

Returns true if the given directive has been set.

Definition at line 175 of file VLXSerializer.hpp.

◆ importVLX()

Object * VLXSerializer::importVLX ( const VLXStructure st)

◆ loadVLB() [1/2]

ref< Object > VLXSerializer::loadVLB ( const String path,
bool  start_fresh = true 
)

Definition at line 381 of file VLXSeriailzer.cpp.

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

Referenced by vl::loadVLB().

◆ loadVLB() [2/2]

ref< Object > VLXSerializer::loadVLB ( VirtualFile file,
bool  start_fresh = true 
)

◆ loadVLT() [1/2]

ref< Object > VLXSerializer::loadVLT ( const String path,
bool  start_fresh = true 
)

Definition at line 337 of file VLXSeriailzer.cpp.

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

Referenced by vl::loadVLT().

◆ loadVLT() [2/2]

ref< Object > VLXSerializer::loadVLT ( VirtualFile file,
bool  start_fresh = true 
)

◆ metadata() [1/2]

std::map< std::string, VLXValue >& vl::VLXSerializer::metadata ( )
inline

The metadata to be imported or exported.

Definition at line 102 of file VLXSerializer.hpp.

Referenced by loadVLB(), loadVLT(), saveVLB(), and saveVLT().

◆ metadata() [2/2]

const std::map< std::string, VLXValue >& vl::VLXSerializer::metadata ( ) const
inline

The metadata to be imported or exported.

Definition at line 105 of file VLXSerializer.hpp.

◆ registerExportedObject()

void VLXSerializer::registerExportedObject ( const Object obj,
VLXStructure st 
)

◆ registerImportedStructure()

void VLXSerializer::registerImportedStructure ( const VLXStructure st,
Object obj 
)

◆ registry() [1/2]

VLXRegistry* vl::VLXSerializer::registry ( )
inline

The VLXRegistry used by the serializer, by default set to vl::defVLXRegistry().

Definition at line 93 of file VLXSerializer.hpp.

Referenced by canExport(), canImport(), exportVLX(), and importVLX().

◆ registry() [2/2]

const VLXRegistry* vl::VLXSerializer::registry ( ) const
inline

The VLXRegistry used by the serializer, by default set to vl::defVLXRegistry().

Definition at line 96 of file VLXSerializer.hpp.

◆ reset()

void vl::VLXSerializer::reset ( )
inline

Definition at line 127 of file VLXSerializer.hpp.

Referenced by loadVLB(), loadVLT(), saveVLB(), and saveVLT().

◆ resolvePath()

void VLXSerializer::resolvePath ( std::string &  path)

If the given path starts with "this:" then the "this:" prefix is replaced with the documentURL(), otherwise the path is left unchanged.

Definition at line 438 of file VLXSeriailzer.cpp.

References documentURL(), vl::String::extractPath(), vl::String::fromStdString(), vl::String::normalizeSlashes(), vl::String::right(), vl::String::startsWith(), and vl::String::toStdString().

Referenced by vl::VLXClassWrapper_GLSLShader::importGLSLShader(), and vl::VLXClassWrapper_Texture::importTexture().

◆ saveVLB() [1/2]

bool VLXSerializer::saveVLB ( const String path,
const Object obj,
bool  start_fresh = true 
)

Definition at line 273 of file VLXSeriailzer.cpp.

References vl::ref< T >::get().

Referenced by vl::saveVLB().

◆ saveVLB() [2/2]

bool VLXSerializer::saveVLB ( VirtualFile file,
const Object obj,
bool  start_fresh = true 
)

◆ saveVLT() [1/2]

bool VLXSerializer::saveVLT ( const String path,
const Object obj,
bool  start_fresh = true 
)

Definition at line 202 of file VLXSeriailzer.cpp.

References vl::ref< T >::get().

Referenced by vl::saveVLT().

◆ saveVLT() [2/2]

bool VLXSerializer::saveVLT ( VirtualFile file,
const Object obj,
bool  start_fresh = true 
)

◆ setDirective()

void vl::VLXSerializer::setDirective ( const char *  directive,
const char *  value 
)
inline

Sets a serialization directive that can be used by VLXClassWrapper objects to program the serialization process.

Directives are essentially a way to pass options to VLXClassWrapper objects, which can read them from the VLXSerializer they are using.

Definition at line 158 of file VLXSerializer.hpp.

◆ setDocumentURL()

void vl::VLXSerializer::setDocumentURL ( const String location)
inline

The URL of the document used to resolve document-relative file paths.

Definition at line 148 of file VLXSerializer.hpp.

Referenced by loadVLB(), and loadVLT().

◆ setError()

void vl::VLXSerializer::setError ( EError  err)
inline

◆ setRegistry()

void vl::VLXSerializer::setRegistry ( const VLXRegistry registry)
inline

The VLXRegistry used by the serializer, by default set to vl::defVLXRegistry().

Definition at line 99 of file VLXSerializer.hpp.

◆ signalExportError()

void VLXSerializer::signalExportError ( const String str)

◆ signalImportError()

void VLXSerializer::signalImportError ( const String str)

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