Visualization Library 2.0.0-b3
A lightweight C++ OpenGL middleware for 2D/3D graphics
|
[Download] [Tutorials] [All Classes] [Grouped Classes] |
Translates an arbitrary set of vl::Object (and subclasses) into VLB and VLT format. More...
#include <VLXSerializer.hpp>
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< Object > | loadVLT (const String &path, bool start_fresh=true) |
ref< Object > | loadVLT (VirtualFile *file, bool start_fresh=true) |
ref< Object > | loadVLB (const String &path, bool start_fresh=true) |
ref< Object > | loadVLB (VirtualFile *file, bool start_fresh=true) |
Object * | importVLX (const VLXStructure *st) |
VLXStructure * | exportVLX (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) |
Object * | getImportedStructure (const VLXStructure *st) |
VLXStructure * | getExportedObject (const Object *obj) |
VLXRegistry * | registry () |
The VLXRegistry used by the serializer, by default set to vl::defVLXRegistry(). More... | |
const VLXRegistry * | registry () 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... | |
VLXValue * | getMetadata (const char *key) |
Returns the value of the given metadata key or NULL if no such metadata was found. More... | |
const VLXValue * | getMetadata (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 String & | documentURL () 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... | |
Object & | operator= (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... | |
IMutex * | refCountMutex () |
The mutex used to protect the reference counting of an Object across multiple threads. More... | |
const IMutex * | refCountMutex () 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 |
IMutex * | mRefCountMutex |
int | mReferenceCount |
bool | mAutomaticDelete |
Translates an arbitrary set of vl::Object (and subclasses) into VLB and VLT format.
Definition at line 45 of file VLXSerializer.hpp.
Enumerator | |
---|---|
NoError | |
ImportError | |
ExportError | |
ReadError | |
WriteError |
Definition at line 50 of file VLXSerializer.hpp.
|
inline |
Definition at line 53 of file VLXSerializer.hpp.
References vl::defVLXRegistry(), vl::loadVLB(), vl::loadVLT(), vl::saveVLB(), and vl::saveVLT().
bool VLXSerializer::canExport | ( | const Object * | obj | ) | const |
Definition at line 123 of file VLXSeriailzer.cpp.
References vl::VLXRegistry::exportRegistry(), and registry().
Referenced by vl::VLXClassWrapper_ResourceDatabase::exportResourceDatabase(), and vl::VLXClassWrapper_Shader::exportShader().
bool VLXSerializer::canImport | ( | const VLXStructure * | st | ) | const |
Definition at line 131 of file VLXSeriailzer.cpp.
References vl::VLXRegistry::importRegistry(), registry(), and vl::VLXTaggedValue::tag().
Referenced by vl::VLXClassWrapper_Actor::importActor().
|
inline |
Returns the value of a serialization directive.
Definition at line 164 of file VLXSerializer.hpp.
|
inline |
The URL of the document used to resolve document-relative file paths.
Definition at line 151 of file VLXSerializer.hpp.
Referenced by resolvePath().
|
inline |
Erases all previously set directives.
Definition at line 178 of file VLXSerializer.hpp.
|
inline |
Removes a serialization directive.
Definition at line 161 of file VLXSerializer.hpp.
|
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().
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().
VLXStructure * VLXSerializer::exportVLX | ( | const Object * | obj | ) |
Definition at line 86 of file VLXSeriailzer.cpp.
References error(), vl::Log::error(), ExportError, vl::VLXRegistry::exportRegistry(), vl::VLXClassWrapper::exportVLX(), vl::ref< T >::get(), getExportedObject(), NULL, registry(), setError(), VL_CHECK, and VL_TRAP.
Referenced by vl::VLXClassWrapper_Effect::export_ShaderPasses(), vl::VLXClassWrapper_Actor::exportActor(), vl::VLXClassWrapper_Camera::exportCamera(), vl::VLXClassWrapper_ClipPlane::exportClipPlane(), vl::VLXClassWrapper_DrawCall::exportDrawCall(), vl::VLXClassWrapper_DrawCall::exportDrawCallBase(), vl::VLXClassWrapper_Effect::exportEffect(), vl::VLXClassWrapper_Geometry::exportGeometry(), vl::VLXClassWrapper_GLSLProgram::exportGLSLProgram(), vl::VLXClassWrapper_Light::exportLight(), vl::VLXClassWrapper_ResourceDatabase::exportResourceDatabase(), vl::VLXClassWrapper_Shader::exportShader(), vl::VLXClassWrapper_Texture::exportTexture(), vl::VLXClassWrapper_TextureSampler::exportTextureSampler(), vl::VLXClassWrapper_Transform::exportTransform(), saveVLB(), and saveVLT().
std::string VLXSerializer::generateID | ( | const char * | prefix | ) |
Definition at line 195 of file VLXSeriailzer.cpp.
Referenced by vl::VLXClassWrapper_Array::export_ArrayT(), vl::VLXClassWrapper_Geometry::exportVLX(), vl::VLXClassWrapper_DrawCall::exportVLX(), vl::VLXClassWrapper_PatchParameter::exportVLX(), vl::VLXClassWrapper_ResourceDatabase::exportVLX(), vl::VLXClassWrapper_Uniform::exportVLX(), vl::VLXClassWrapper_Shader::exportVLX(), vl::VLXClassWrapper_LODEvaluator::exportVLX(), vl::VLXClassWrapper_Effect::exportVLX(), vl::VLXClassWrapper_Actor::exportVLX(), vl::VLXClassWrapper_Camera::exportVLX(), vl::VLXClassWrapper_Viewport::exportVLX(), vl::VLXClassWrapper_Transform::exportVLX(), vl::VLXClassWrapper_Light::exportVLX(), vl::VLXClassWrapper_ClipPlane::exportVLX(), vl::VLXClassWrapper_GLSLProgram::exportVLX(), vl::VLXClassWrapper_GLSLShader::exportVLX(), vl::VLXClassWrapper_VertexAttrib::exportVLX(), vl::VLXClassWrapper_Color::exportVLX(), vl::VLXClassWrapper_SecondaryColor::exportVLX(), vl::VLXClassWrapper_Normal::exportVLX(), vl::VLXClassWrapper_Material::exportVLX(), vl::VLXClassWrapper_ActorEventCallback::exportVLX(), vl::VLXClassWrapper_Texture::exportVLX(), vl::VLXClassWrapper_TexParameter::exportVLX(), and vl::VLXClassWrapper_TextureSampler::exportVLX().
VLXStructure * VLXSerializer::getExportedObject | ( | const Object * | obj | ) |
Definition at line 163 of file VLXSeriailzer.cpp.
References NULL, and VL_CHECK.
Referenced by exportVLX().
Object * VLXSerializer::getImportedStructure | ( | const VLXStructure * | st | ) |
Definition at line 151 of file VLXSeriailzer.cpp.
References NULL, and VL_CHECK.
Referenced by importVLX().
|
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.
|
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.
|
inline |
Returns true if the given directive has been set.
Definition at line 175 of file VLXSerializer.hpp.
Object * VLXSerializer::importVLX | ( | const VLXStructure * | st | ) |
Definition at line 49 of file VLXSeriailzer.cpp.
References error(), vl::Log::error(), vl::ref< T >::get(), getImportedStructure(), ImportError, vl::VLXRegistry::importRegistry(), vl::VLXClassWrapper::importVLX(), NULL, registry(), setError(), vl::VLXTaggedValue::tag(), VL_CHECK, and VL_TRAP.
Referenced by vl::VLXClassWrapper_Actor::importActor(), vl::VLXClassWrapper_Camera::importCamera(), vl::VLXClassWrapper_ClipPlane::importClipPlane(), vl::VLXClassWrapper_DrawCall::importDrawCall(), vl::VLXClassWrapper_Effect::importEffect(), vl::VLXClassWrapper_Geometry::importGeometry(), vl::VLXClassWrapper_GLSLProgram::importGLSLProgram(), vl::VLXClassWrapper_Light::importLight(), vl::VLXClassWrapper_ResourceDatabase::importResourceDatabase(), vl::VLXClassWrapper_Shader::importShader(), vl::VLXClassWrapper_Texture::importTexture(), vl::VLXClassWrapper_TextureSampler::importTextureSampler(), vl::VLXClassWrapper_Transform::importTransform(), loadVLB(), and loadVLT().
Definition at line 381 of file VLXSeriailzer.cpp.
References vl::ref< T >::get(), and vl::locateFile().
Referenced by vl::loadVLB().
ref< Object > VLXSerializer::loadVLB | ( | VirtualFile * | file, |
bool | start_fresh = true |
||
) |
Definition at line 387 of file VLXSeriailzer.cpp.
References vl::VirtualFile::close(), ImportError, importVLX(), metadata(), NULL, vl::VirtualFile::path(), reset(), setDocumentURL(), setError(), and vl::VLXParserVLB::setInputFile().
Definition at line 337 of file VLXSeriailzer.cpp.
References vl::ref< T >::get(), and vl::locateFile().
Referenced by vl::loadVLT().
ref< Object > VLXSerializer::loadVLT | ( | VirtualFile * | file, |
bool | start_fresh = true |
||
) |
Definition at line 343 of file VLXSeriailzer.cpp.
References vl::VirtualFile::close(), ImportError, importVLX(), metadata(), NULL, vl::VirtualFile::path(), reset(), setDocumentURL(), setError(), vl::BufferedStream< Element_Type, Chunk_Size >::setInputFile(), and vl::VLXParserVLT::tokenizer().
|
inline |
|
inline |
The metadata to be imported or exported.
Definition at line 105 of file VLXSerializer.hpp.
void VLXSerializer::registerExportedObject | ( | const Object * | obj, |
VLXStructure * | st | ||
) |
Definition at line 145 of file VLXSeriailzer.cpp.
References VL_CHECK.
Referenced by vl::VLXClassWrapper_Array::exportVLX(), vl::VLXClassWrapper_Geometry::exportVLX(), vl::VLXClassWrapper_DrawCall::exportVLX(), vl::VLXClassWrapper_PatchParameter::exportVLX(), vl::VLXClassWrapper_ResourceDatabase::exportVLX(), vl::VLXClassWrapper_Uniform::exportVLX(), vl::VLXClassWrapper_Shader::exportVLX(), vl::VLXClassWrapper_LODEvaluator::exportVLX(), vl::VLXClassWrapper_Effect::exportVLX(), vl::VLXClassWrapper_Actor::exportVLX(), vl::VLXClassWrapper_Camera::exportVLX(), vl::VLXClassWrapper_Viewport::exportVLX(), vl::VLXClassWrapper_Transform::exportVLX(), vl::VLXClassWrapper_Light::exportVLX(), vl::VLXClassWrapper_ClipPlane::exportVLX(), vl::VLXClassWrapper_GLSLProgram::exportVLX(), vl::VLXClassWrapper_GLSLShader::exportVLX(), vl::VLXClassWrapper_VertexAttrib::exportVLX(), vl::VLXClassWrapper_Color::exportVLX(), vl::VLXClassWrapper_SecondaryColor::exportVLX(), vl::VLXClassWrapper_Normal::exportVLX(), vl::VLXClassWrapper_Material::exportVLX(), vl::VLXClassWrapper_ActorEventCallback::exportVLX(), vl::VLXClassWrapper_Texture::exportVLX(), vl::VLXClassWrapper_TexParameter::exportVLX(), and vl::VLXClassWrapper_TextureSampler::exportVLX().
void VLXSerializer::registerImportedStructure | ( | const VLXStructure * | st, |
Object * | obj | ||
) |
Definition at line 139 of file VLXSeriailzer.cpp.
References VL_CHECK.
Referenced by vl::VLXClassWrapper_Array::importVLX(), vl::VLXClassWrapper_Geometry::importVLX(), vl::VLXClassWrapper_DrawCall::importVLX(), vl::VLXClassWrapper_PatchParameter::importVLX(), vl::VLXClassWrapper_ResourceDatabase::importVLX(), vl::VLXClassWrapper_Uniform::importVLX(), vl::VLXClassWrapper_Shader::importVLX(), vl::VLXClassWrapper_LODEvaluator::importVLX(), vl::VLXClassWrapper_Effect::importVLX(), vl::VLXClassWrapper_Actor::importVLX(), vl::VLXClassWrapper_Camera::importVLX(), vl::VLXClassWrapper_Viewport::importVLX(), vl::VLXClassWrapper_Transform::importVLX(), vl::VLXClassWrapper_Light::importVLX(), vl::VLXClassWrapper_ClipPlane::importVLX(), vl::VLXClassWrapper_GLSLProgram::importVLX(), vl::VLXClassWrapper_GLSLShader::importVLX(), vl::VLXClassWrapper_VertexAttrib::importVLX(), vl::VLXClassWrapper_Color::importVLX(), vl::VLXClassWrapper_SecondaryColor::importVLX(), vl::VLXClassWrapper_Normal::importVLX(), vl::VLXClassWrapper_Material::importVLX(), vl::VLXClassWrapper_ActorEventCallback::importVLX(), vl::VLXClassWrapper_Texture::importVLX(), vl::VLXClassWrapper_TexParameter::importVLX(), and vl::VLXClassWrapper_TextureSampler::importVLX().
|
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().
|
inline |
The VLXRegistry used by the serializer, by default set to vl::defVLXRegistry().
Definition at line 96 of file VLXSerializer.hpp.
|
inline |
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().
Definition at line 273 of file VLXSeriailzer.cpp.
References vl::ref< T >::get().
Referenced by vl::saveVLB().
bool VLXSerializer::saveVLB | ( | VirtualFile * | file, |
const Object * | obj, | ||
bool | start_fresh = true |
||
) |
Definition at line 279 of file VLXSeriailzer.cpp.
References vl::VLXStructure::acceptVisitor(), vl::VirtualFile::close(), exportVLX(), metadata(), NoError, reset(), vl::VLXVisitorCountIDs::setIDSet(), vl::VLXVisitorExportToVLB::setIDSet(), vl::VLXValue::String, vl::String::toStdString(), vl::VLXStructure::value(), and vl::VLXVisitorExportToVLB::writeHeader().
Definition at line 202 of file VLXSeriailzer.cpp.
References vl::ref< T >::get().
Referenced by vl::saveVLT().
bool VLXSerializer::saveVLT | ( | VirtualFile * | file, |
const Object * | obj, | ||
bool | start_fresh = true |
||
) |
Definition at line 208 of file VLXSeriailzer.cpp.
References vl::VLXStructure::acceptVisitor(), vl::VirtualFile::close(), vl::Log::error(), exportVLX(), metadata(), NoError, vl::OM_WriteOnly, vl::VirtualFile::open(), vl::VirtualFile::path(), reset(), vl::VLXVisitorCountIDs::setIDSet(), vl::VLXVisitorExportToVLT::setIDSet(), vl::VLXValue::String, vl::VLXVisitorExportToVLT::text(), vl::String::toStdString(), vl::VLXStructure::value(), vl::VirtualFile::write(), WriteError, and vl::VLXVisitorExportToVLT::writeHeader().
|
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.
|
inline |
The URL of the document used to resolve document-relative file paths.
Definition at line 148 of file VLXSerializer.hpp.
|
inline |
Sets a serialization error.
Definition at line 138 of file VLXSerializer.hpp.
Referenced by exportVLX(), importVLX(), loadVLB(), loadVLT(), signalExportError(), signalImportError(), vl::vlx_EClearColorMode(), vl::vlx_EClearFlags(), vl::vlx_EColorMaterial(), vl::vlx_EDepthTextureMode(), vl::vlx_EEnable(), vl::vlx_EPolygonFace(), vl::vlx_EPrimitiveType(), vl::vlx_EProjectionMatrixType(), vl::vlx_ETexCompareFunc(), vl::vlx_ETexCompareMode(), vl::vlx_ETexParamFilter(), vl::vlx_ETexParamWrap(), vl::vlx_ETextureDimension(), vl::vlx_ETextureFormat(), vl::vlx_EUniformType(), and vl::vlx_EVertexAttribInterpretation().
|
inline |
The VLXRegistry used by the serializer, by default set to vl::defVLXRegistry().
Definition at line 99 of file VLXSerializer.hpp.
void VLXSerializer::signalExportError | ( | const String & | str | ) |
Definition at line 185 of file VLXSeriailzer.cpp.
References error(), vl::Log::error(), ExportError, and setError().
Referenced by vl::VLXClassWrapper_ActorEventCallback::exportActorEventCallback(), vl::VLXClassWrapper_LODEvaluator::exportLODEvaluator(), and vl::VLXClassWrapper_Array::exportVLX().
void VLXSerializer::signalImportError | ( | const String & | str | ) |
Definition at line 175 of file VLXSeriailzer.cpp.
References error(), vl::Log::error(), ImportError, and setError().
Referenced by vl::VLXClassWrapper_ActorEventCallback::importActorEventCallback(), vl::VLXClassWrapper_DrawCall::importDrawCall(), vl::VLXClassWrapper_Geometry::importGeometry(), vl::VLXClassWrapper_ResourceDatabase::importResourceDatabase(), vl::VLXClassWrapper_Uniform::importUniform(), vl::VLXClassWrapper_Array::importVLX(), vl::VLXClassWrapper_DrawCall::importVLX(), vl::VLXClassWrapper_GLSLShader::importVLX(), and vl::VLXClassWrapper_ActorEventCallback::importVLX().
Visualization Library 2.0.0-b3 Reference Documentation
Updated on Tue Feb 7 2017 00:26:11.
© Copyright Michele Bosi. All rights reserved.