Visualization Library 2.0.0
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 <Serializer.hpp>
Public Types | |
enum | EError { NoError, ImportError, ExportError, ReadError, WriteError } |
Public Member Functions | |
VLXSerializer () | |
const char * | errorString () const |
bool | saveVLT (const vl::String &path, const vl::Object *obj, bool start_fresh=true) |
bool | saveVLT (vl::VirtualFile *file, const vl::Object *obj, bool start_fresh=true) |
bool | saveVLB (const vl::String &path, const vl::Object *obj, bool start_fresh=true) |
bool | saveVLB (vl::VirtualFile *file, const vl::Object *obj, bool start_fresh=true) |
vl::ref< vl::Object > | loadVLT (const vl::String &path, bool start_fresh=true) |
vl::ref< vl::Object > | loadVLT (vl::VirtualFile *file, bool start_fresh=true) |
vl::ref< vl::Object > | loadVLB (const vl::String &path, bool start_fresh=true) |
vl::ref< vl::Object > | loadVLB (vl::VirtualFile *file, bool start_fresh=true) |
vl::Object * | importVLX (const VLXStructure *st) |
VLXStructure * | exportVLX (const vl::Object *obj) |
bool | canExport (const vl::Object *obj) const |
bool | canImport (const VLXStructure *st) const |
void | registerImportedStructure (const VLXStructure *st, Object *obj) |
void | registerExportedObject (const vl::Object *obj, VLXStructure *st) |
vl::Object * | getImportedStructure (const VLXStructure *st) |
VLXStructure * | getExportedObject (const vl::Object *obj) |
Registry * | registry () |
The Registry used by the serializer, by default set to vl::defVLXRegistry(). More... | |
const Registry * | registry () const |
The Registry used by the serializer, by default set to vl::defVLXRegistry(). More... | |
void | setRegistry (const Registry *registry) |
The Registry 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 vl::String &str) |
void | signalExportError (const vl::String &str) |
void | setDocumentURL (const vl::String &location) |
The URL of the document used to resolve document-relative file paths. More... | |
const vl::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 ClassWrapper 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 Serializer.hpp.
Enumerator | |
---|---|
NoError | |
ImportError | |
ExportError | |
ReadError | |
WriteError |
Definition at line 50 of file Serializer.hpp.
|
inline |
Definition at line 53 of file Serializer.hpp.
References vlX::defVLXRegistry(), vlX::loadVLB(), vlX::loadVLT(), vlX::saveVLB(), and vlX::saveVLT().
bool VLXSerializer::canExport | ( | const vl::Object * | obj | ) | const |
Definition at line 124 of file Seriailzer.cpp.
Referenced by vlX::VLXClassWrapper_ResourceDatabase::exportResourceDatabase(), and vlX::VLXClassWrapper_Shader::exportShader().
bool VLXSerializer::canImport | ( | const VLXStructure * | st | ) | const |
Definition at line 132 of file Seriailzer.cpp.
References vlX::VLXTaggedValue::tag().
Referenced by vlX::VLXClassWrapper_Actor::importActor().
|
inline |
Returns the value of a serialization directive.
Definition at line 164 of file Serializer.hpp.
|
inline |
The URL of the document used to resolve document-relative file paths.
Definition at line 151 of file Serializer.hpp.
|
inline |
Erases all previously set directives.
Definition at line 178 of file Serializer.hpp.
|
inline |
Removes a serialization directive.
Definition at line 161 of file Serializer.hpp.
|
inline |
The last signaled error.
Definition at line 141 of file Serializer.hpp.
Referenced by vlX::loadVLB(), vlX::loadVLT(), vlX::saveVLB(), and vlX::saveVLT().
const char * VLXSerializer::errorString | ( | ) | const |
Definition at line 426 of file Seriailzer.cpp.
Referenced by vlX::loadVLB(), vlX::loadVLT(), vlX::saveVLB(), and vlX::saveVLT().
VLXStructure * VLXSerializer::exportVLX | ( | const vl::Object * | obj | ) |
Definition at line 87 of file Seriailzer.cpp.
References vl::Log::error(), vlX::ClassWrapper::exportVLX(), vl::ref< T >::get(), NULL, VL_CHECK, and VL_TRAP.
Referenced by vlX::VLXClassWrapper_Effect::export_ShaderPasses(), vlX::VLXClassWrapper_Actor::exportActor(), vlX::VLXClassWrapper_Camera::exportCamera(), vlX::VLXClassWrapper_ClipPlane::exportClipPlane(), vlX::VLXClassWrapper_DrawCall::exportDrawCall(), vlX::VLXClassWrapper_DrawCall::exportDrawCallBase(), vlX::VLXClassWrapper_Effect::exportEffect(), vlX::VLXClassWrapper_Geometry::exportGeometry(), vlX::VLXClassWrapper_GLSLProgram::exportGLSLProgram(), vlX::VLXClassWrapper_Light::exportLight(), vlX::VLXClassWrapper_ResourceDatabase::exportResourceDatabase(), vlX::VLXClassWrapper_Shader::exportShader(), vlX::VLXClassWrapper_Texture::exportTexture(), vlX::VLXClassWrapper_TextureSampler::exportTextureSampler(), and vlX::VLXClassWrapper_Transform::exportTransform().
std::string VLXSerializer::generateID | ( | const char * | prefix | ) |
Definition at line 196 of file Seriailzer.cpp.
Referenced by vlX::VLXClassWrapper_Array::export_ArrayT(), vlX::VLXClassWrapper_Geometry::exportVLX(), vlX::VLXClassWrapper_DrawCall::exportVLX(), vlX::VLXClassWrapper_PatchParameter::exportVLX(), vlX::VLXClassWrapper_ResourceDatabase::exportVLX(), vlX::VLXClassWrapper_Uniform::exportVLX(), vlX::VLXClassWrapper_Shader::exportVLX(), vlX::VLXClassWrapper_LODEvaluator::exportVLX(), vlX::VLXClassWrapper_Effect::exportVLX(), vlX::VLXClassWrapper_Actor::exportVLX(), vlX::VLXClassWrapper_Camera::exportVLX(), vlX::VLXClassWrapper_Viewport::exportVLX(), vlX::VLXClassWrapper_Transform::exportVLX(), vlX::VLXClassWrapper_Light::exportVLX(), vlX::VLXClassWrapper_ClipPlane::exportVLX(), vlX::VLXClassWrapper_GLSLProgram::exportVLX(), vlX::VLXClassWrapper_GLSLShader::exportVLX(), vlX::VLXClassWrapper_VertexAttrib::exportVLX(), vlX::VLXClassWrapper_Color::exportVLX(), vlX::VLXClassWrapper_SecondaryColor::exportVLX(), vlX::VLXClassWrapper_Normal::exportVLX(), vlX::VLXClassWrapper_Material::exportVLX(), vlX::VLXClassWrapper_ActorEventCallback::exportVLX(), vlX::VLXClassWrapper_Texture::exportVLX(), vlX::VLXClassWrapper_TexParameter::exportVLX(), and vlX::VLXClassWrapper_TextureSampler::exportVLX().
VLXStructure * VLXSerializer::getExportedObject | ( | const vl::Object * | obj | ) |
Definition at line 164 of file Seriailzer.cpp.
Object * VLXSerializer::getImportedStructure | ( | const VLXStructure * | st | ) |
Definition at line 152 of file Seriailzer.cpp.
|
inline |
Returns the value of the given metadata key or NULL if no such metadata was found.
Definition at line 108 of file Serializer.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 Serializer.hpp.
References NULL.
|
inline |
Returns true if the given directive has been set.
Definition at line 175 of file Serializer.hpp.
Object * VLXSerializer::importVLX | ( | const VLXStructure * | st | ) |
Definition at line 50 of file Seriailzer.cpp.
References vl::Log::error(), vl::ref< T >::get(), vlX::ClassWrapper::importVLX(), NULL, vlX::VLXTaggedValue::tag(), VL_CHECK, and VL_TRAP.
Referenced by vlX::VLXClassWrapper_Actor::importActor(), vlX::VLXClassWrapper_Camera::importCamera(), vlX::VLXClassWrapper_ClipPlane::importClipPlane(), vlX::VLXClassWrapper_DrawCall::importDrawCall(), vlX::VLXClassWrapper_Effect::importEffect(), vlX::VLXClassWrapper_Geometry::importGeometry(), vlX::VLXClassWrapper_GLSLProgram::importGLSLProgram(), vlX::VLXClassWrapper_Light::importLight(), vlX::VLXClassWrapper_ResourceDatabase::importResourceDatabase(), vlX::VLXClassWrapper_Shader::importShader(), vlX::VLXClassWrapper_Texture::importTexture(), vlX::VLXClassWrapper_TextureSampler::importTextureSampler(), and vlX::VLXClassWrapper_Transform::importTransform().
vl::ref< vl::Object > VLXSerializer::loadVLB | ( | const vl::String & | path, |
bool | start_fresh = true |
||
) |
Definition at line 382 of file Seriailzer.cpp.
References vl::ref< T >::get(), vlX::loadVLB(), and vl::locateFile().
Referenced by vlX::loadVLB().
ref< Object > VLXSerializer::loadVLB | ( | vl::VirtualFile * | file, |
bool | start_fresh = true |
||
) |
Definition at line 388 of file Seriailzer.cpp.
References vl::VirtualFile::close(), NULL, vl::VirtualFile::path(), and vlX::ParserVLB::setInputFile().
vl::ref< vl::Object > VLXSerializer::loadVLT | ( | const vl::String & | path, |
bool | start_fresh = true |
||
) |
Definition at line 338 of file Seriailzer.cpp.
References vl::ref< T >::get(), vlX::loadVLT(), and vl::locateFile().
Referenced by vlX::loadVLT().
vl::ref< vl::Object > VLXSerializer::loadVLT | ( | vl::VirtualFile * | file, |
bool | start_fresh = true |
||
) |
Definition at line 344 of file Seriailzer.cpp.
References vl::VirtualFile::close(), NULL, vl::VirtualFile::path(), vl::BufferedStream< Element_Type, Chunk_Size >::setInputFile(), and vlX::ParserVLT::tokenizer().
|
inline |
The metadata to be imported or exported.
Definition at line 102 of file Serializer.hpp.
|
inline |
The metadata to be imported or exported.
Definition at line 105 of file Serializer.hpp.
void VLXSerializer::registerExportedObject | ( | const vl::Object * | obj, |
VLXStructure * | st | ||
) |
Definition at line 146 of file Seriailzer.cpp.
References VL_CHECK.
Referenced by vlX::VLXClassWrapper_Array::exportVLX(), vlX::VLXClassWrapper_Geometry::exportVLX(), vlX::VLXClassWrapper_DrawCall::exportVLX(), vlX::VLXClassWrapper_PatchParameter::exportVLX(), vlX::VLXClassWrapper_ResourceDatabase::exportVLX(), vlX::VLXClassWrapper_Uniform::exportVLX(), vlX::VLXClassWrapper_Shader::exportVLX(), vlX::VLXClassWrapper_LODEvaluator::exportVLX(), vlX::VLXClassWrapper_Effect::exportVLX(), vlX::VLXClassWrapper_Actor::exportVLX(), vlX::VLXClassWrapper_Camera::exportVLX(), vlX::VLXClassWrapper_Viewport::exportVLX(), vlX::VLXClassWrapper_Transform::exportVLX(), vlX::VLXClassWrapper_Light::exportVLX(), vlX::VLXClassWrapper_ClipPlane::exportVLX(), vlX::VLXClassWrapper_GLSLProgram::exportVLX(), vlX::VLXClassWrapper_GLSLShader::exportVLX(), vlX::VLXClassWrapper_VertexAttrib::exportVLX(), vlX::VLXClassWrapper_Color::exportVLX(), vlX::VLXClassWrapper_SecondaryColor::exportVLX(), vlX::VLXClassWrapper_Normal::exportVLX(), vlX::VLXClassWrapper_Material::exportVLX(), vlX::VLXClassWrapper_ActorEventCallback::exportVLX(), vlX::VLXClassWrapper_Texture::exportVLX(), vlX::VLXClassWrapper_TexParameter::exportVLX(), and vlX::VLXClassWrapper_TextureSampler::exportVLX().
void VLXSerializer::registerImportedStructure | ( | const VLXStructure * | st, |
Object * | obj | ||
) |
Definition at line 140 of file Seriailzer.cpp.
References VL_CHECK.
Referenced by vlX::VLXClassWrapper_Array::importVLX(), vlX::VLXClassWrapper_Geometry::importVLX(), vlX::VLXClassWrapper_DrawCall::importVLX(), vlX::VLXClassWrapper_PatchParameter::importVLX(), vlX::VLXClassWrapper_ResourceDatabase::importVLX(), vlX::VLXClassWrapper_Uniform::importVLX(), vlX::VLXClassWrapper_Shader::importVLX(), vlX::VLXClassWrapper_LODEvaluator::importVLX(), vlX::VLXClassWrapper_Effect::importVLX(), vlX::VLXClassWrapper_Actor::importVLX(), vlX::VLXClassWrapper_Camera::importVLX(), vlX::VLXClassWrapper_Viewport::importVLX(), vlX::VLXClassWrapper_Transform::importVLX(), vlX::VLXClassWrapper_Light::importVLX(), vlX::VLXClassWrapper_ClipPlane::importVLX(), vlX::VLXClassWrapper_GLSLProgram::importVLX(), vlX::VLXClassWrapper_GLSLShader::importVLX(), vlX::VLXClassWrapper_VertexAttrib::importVLX(), vlX::VLXClassWrapper_Color::importVLX(), vlX::VLXClassWrapper_SecondaryColor::importVLX(), vlX::VLXClassWrapper_Normal::importVLX(), vlX::VLXClassWrapper_Material::importVLX(), vlX::VLXClassWrapper_ActorEventCallback::importVLX(), vlX::VLXClassWrapper_Texture::importVLX(), vlX::VLXClassWrapper_TexParameter::importVLX(), and vlX::VLXClassWrapper_TextureSampler::importVLX().
|
inline |
The Registry used by the serializer, by default set to vl::defVLXRegistry().
Definition at line 93 of file Serializer.hpp.
|
inline |
The Registry used by the serializer, by default set to vl::defVLXRegistry().
Definition at line 96 of file Serializer.hpp.
|
inline |
Definition at line 127 of file Serializer.hpp.
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 439 of file Seriailzer.cpp.
References vl::String::extractPath(), vl::String::fromStdString(), vl::String::normalizeSlashes(), vl::String::right(), vl::String::startsWith(), and vl::String::toStdString().
Referenced by vlX::VLXClassWrapper_GLSLShader::importGLSLShader(), and vlX::VLXClassWrapper_Texture::importTexture().
bool VLXSerializer::saveVLB | ( | const vl::String & | path, |
const vl::Object * | obj, | ||
bool | start_fresh = true |
||
) |
Definition at line 274 of file Seriailzer.cpp.
References vl::ref< T >::get(), and vlX::saveVLB().
Referenced by vlX::saveVLB().
bool VLXSerializer::saveVLB | ( | vl::VirtualFile * | file, |
const vl::Object * | obj, | ||
bool | start_fresh = true |
||
) |
Definition at line 280 of file Seriailzer.cpp.
References vlX::VLXStructure::acceptVisitor(), vl::VirtualFile::close(), vlX::VisitorIDCounter::setIDSet(), vlX::VisitorExportToVLB::setIDSet(), vl::String::toStdString(), vlX::VLXStructure::value(), VL_SERIALIZER_VERSION, and vlX::VisitorExportToVLB::writeHeader().
bool VLXSerializer::saveVLT | ( | const vl::String & | path, |
const vl::Object * | obj, | ||
bool | start_fresh = true |
||
) |
Definition at line 203 of file Seriailzer.cpp.
References vl::ref< T >::get(), and vlX::saveVLT().
Referenced by vlX::saveVLT().
bool VLXSerializer::saveVLT | ( | vl::VirtualFile * | file, |
const vl::Object * | obj, | ||
bool | start_fresh = true |
||
) |
Definition at line 209 of file Seriailzer.cpp.
References vlX::VLXStructure::acceptVisitor(), vl::VirtualFile::close(), vl::Log::error(), vl::OM_WriteOnly, vl::VirtualFile::open(), vl::VirtualFile::path(), vlX::VisitorIDCounter::setIDSet(), vlX::VisitorExportToVLT::setIDSet(), vlX::VisitorExportToVLT::text(), vl::String::toStdString(), vlX::VLXStructure::value(), VL_SERIALIZER_VERSION, vl::VirtualFile::write(), and vlX::VisitorExportToVLT::writeHeader().
|
inline |
Sets a serialization directive that can be used by ClassWrapper objects to program the serialization process.
Directives are essentially a way to pass options to ClassWrapper objects, which can read them from the VLXSerializer they are using.
Definition at line 158 of file Serializer.hpp.
|
inline |
The URL of the document used to resolve document-relative file paths.
Definition at line 148 of file Serializer.hpp.
|
inline |
Sets a serialization error.
Definition at line 138 of file Serializer.hpp.
Referenced by vlX::vlx_EClearColorMode(), vlX::vlx_EClearFlags(), vlX::vlx_EColorMaterial(), vlX::vlx_EDepthTextureMode(), vlX::vlx_EEnable(), vlX::vlx_EPolygonFace(), vlX::vlx_EPrimitiveType(), vlX::vlx_EProjectionMatrixType(), vlX::vlx_ETexCompareFunc(), vlX::vlx_ETexCompareMode(), vlX::vlx_ETexParamFilter(), vlX::vlx_ETexParamWrap(), vlX::vlx_ETextureDimension(), vlX::vlx_ETextureFormat(), vlX::vlx_EUniformType(), and vlX::vlx_EVertexAttribInterpretation().
|
inline |
The Registry used by the serializer, by default set to vl::defVLXRegistry().
Definition at line 99 of file Serializer.hpp.
void VLXSerializer::signalExportError | ( | const vl::String & | str | ) |
Definition at line 186 of file Seriailzer.cpp.
References vl::Log::error().
Referenced by vlX::VLXClassWrapper_ActorEventCallback::exportActorEventCallback(), vlX::VLXClassWrapper_LODEvaluator::exportLODEvaluator(), and vlX::VLXClassWrapper_Array::exportVLX().
void VLXSerializer::signalImportError | ( | const vl::String & | str | ) |
Definition at line 176 of file Seriailzer.cpp.
References vl::Log::error().
Referenced by vlX::VLXClassWrapper_ActorEventCallback::importActorEventCallback(), vlX::VLXClassWrapper_DrawCall::importDrawCall(), vlX::VLXClassWrapper_Geometry::importGeometry(), vlX::VLXClassWrapper_ResourceDatabase::importResourceDatabase(), vlX::VLXClassWrapper_Uniform::importUniform(), vlX::VLXClassWrapper_Array::importVLX(), vlX::VLXClassWrapper_DrawCall::importVLX(), vlX::VLXClassWrapper_GLSLShader::importVLX(), and vlX::VLXClassWrapper_ActorEventCallback::importVLX().
Visualization Library 2.0.0 Reference Documentation
Updated on Wed Dec 23 2020 12:44:14.
© Copyright Michele Bosi. All rights reserved.