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 Types | Public Member Functions | List of all members
vlX::VLXSerializer Class Reference

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

#include <Serializer.hpp>

+ Inheritance diagram for vlX::VLXSerializer:

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::ObjectloadVLT (const vl::String &path, bool start_fresh=true)
 
vl::ref< vl::ObjectloadVLT (vl::VirtualFile *file, bool start_fresh=true)
 
vl::ref< vl::ObjectloadVLB (const vl::String &path, bool start_fresh=true)
 
vl::ref< vl::ObjectloadVLB (vl::VirtualFile *file, bool start_fresh=true)
 
vl::ObjectimportVLX (const VLXStructure *st)
 
VLXStructureexportVLX (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::ObjectgetImportedStructure (const VLXStructure *st)
 
VLXStructuregetExportedObject (const vl::Object *obj)
 
Registryregistry ()
 The Registry used by the serializer, by default set to vl::defVLXRegistry(). More...
 
const Registryregistry () 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...
 
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 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::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 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...
 
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 Serializer.hpp.

Member Enumeration Documentation

◆ EError

Enumerator
NoError 
ImportError 
ExportError 
ReadError 
WriteError 

Definition at line 50 of file Serializer.hpp.

Constructor & Destructor Documentation

◆ VLXSerializer()

vlX::VLXSerializer::VLXSerializer ( )
inline

Member Function Documentation

◆ canExport()

bool VLXSerializer::canExport ( const vl::Object obj) const

◆ canImport()

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().

◆ directive()

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

Returns the value of a serialization directive.

Definition at line 164 of file Serializer.hpp.

◆ documentURL()

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

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

Definition at line 151 of file Serializer.hpp.

◆ eraseAllDirectives()

void vlX::VLXSerializer::eraseAllDirectives ( )
inline

Erases all previously set directives.

Definition at line 178 of file Serializer.hpp.

◆ eraseDirective()

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

Removes a serialization directive.

Definition at line 161 of file Serializer.hpp.

◆ error()

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

The last signaled error.

Definition at line 141 of file Serializer.hpp.

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

◆ errorString()

const char * VLXSerializer::errorString ( ) const

Definition at line 426 of file Seriailzer.cpp.

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

◆ exportVLX()

VLXStructure * VLXSerializer::exportVLX ( const vl::Object obj)

◆ generateID()

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

◆ getExportedObject()

VLXStructure * VLXSerializer::getExportedObject ( const vl::Object obj)

Definition at line 164 of file Seriailzer.cpp.

References NULL, and VL_CHECK.

◆ getImportedStructure()

Object * VLXSerializer::getImportedStructure ( const VLXStructure st)

Definition at line 152 of file Seriailzer.cpp.

References NULL, and VL_CHECK.

◆ getMetadata() [1/2]

VLXValue* vlX::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 Serializer.hpp.

References NULL.

◆ getMetadata() [2/2]

const VLXValue* vlX::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 Serializer.hpp.

References NULL.

◆ hasDirective()

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

Returns true if the given directive has been set.

Definition at line 175 of file Serializer.hpp.

◆ importVLX()

Object * VLXSerializer::importVLX ( const VLXStructure st)

◆ loadVLB() [1/2]

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().

◆ loadVLB() [2/2]

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

◆ loadVLT() [1/2]

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().

◆ loadVLT() [2/2]

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

◆ metadata() [1/2]

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

The metadata to be imported or exported.

Definition at line 102 of file Serializer.hpp.

◆ metadata() [2/2]

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

The metadata to be imported or exported.

Definition at line 105 of file Serializer.hpp.

◆ registerExportedObject()

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

◆ registerImportedStructure()

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

◆ registry() [1/2]

Registry* vlX::VLXSerializer::registry ( )
inline

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

Definition at line 93 of file Serializer.hpp.

◆ registry() [2/2]

const Registry* vlX::VLXSerializer::registry ( ) const
inline

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

Definition at line 96 of file Serializer.hpp.

◆ reset()

void vlX::VLXSerializer::reset ( )
inline

Definition at line 127 of file Serializer.hpp.

◆ 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 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().

◆ saveVLB() [1/2]

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().

◆ saveVLB() [2/2]

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

◆ saveVLT() [1/2]

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().

◆ saveVLT() [2/2]

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

◆ setDirective()

void vlX::VLXSerializer::setDirective ( const char *  directive,
const char *  value 
)
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.

◆ setDocumentURL()

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

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

Definition at line 148 of file Serializer.hpp.

◆ setError()

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

◆ setRegistry()

void vlX::VLXSerializer::setRegistry ( const Registry registry)
inline

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

Definition at line 99 of file Serializer.hpp.

◆ signalExportError()

void VLXSerializer::signalExportError ( const vl::String str)

◆ signalImportError()

void VLXSerializer::signalImportError ( const vl::String str)

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