Drag[en]gine Script Module DragonScript 1.35
Loading...
Searching...
No Matches
Dragengine.LoadSave.PersistencyEnvironment Class Reference

Persistency environment for reading and writing for complex objects. More...

Inheritance diagram for Dragengine.LoadSave.PersistencyEnvironment:

Public Member Functions

void forEachVariable (Block ablock)
 Visit variables with block with parameters String name and Object value.
Persistency getPersistency ()
 Persistency with factories.
Object getVariable (String name)
 Variable value.
Object getVariable (String name, Object defaultValue)
 Variable value or default value if absent.
int getVersion ()
 File version number.
PersistencyEnvironment new (Persistency persistency)
 Create persistency environment.
PersistencyEnvironment new (Persistency persistency, int version)
 Create persistency environment.
PersistencyEnvironment new (PersistencyEnvironment environment)
 Create copy of persistency environment.
bool readBool (FileReader reader)
 Read boolean.
Persistable readObject (FileReader reader)
 Read object using factory and file reader.
Persistable readObjectOrNull (FileReader reader)
 Read object using factory and file reader or null if empty factory name.
String readString16OrNullIfEmpty (FileReader reader)
 Read string with 16-bit length or null if empty.
String readString8OrNullIfEmpty (FileReader reader)
 Read string with 8-bit length or null if empty.
StringID readStringIDOrNullIfEmpty (FileReader reader)
 Read StringID with 8-bit length or null if empty.
void removeAllVariables ()
 Remove all variables.
void removeVariable (String name)
 Remove variable if present.
void setVariable (String name, Object value)
 Set variable.
void setVariables (PersistencyEnvironment environment)
 Set variables from another environment.
void writeBool (FileWriter writer, bool value)
 Write boolean.
void writeObject (FileWriter writer, Persistable object)
 Write object using file writer.
void writeObjectOrNull (FileWriter writer, Persistable object)
 Write object or null using file writer.
void writeString16OrEmptyIfNull (FileWriter writer, String string)
 Write string with 16-bit length or empty string if null.
void writeString8OrEmptyIfNull (FileWriter writer, String string)
 Write string with 8-bit length or empty string if null.
void writeStringIDOrEmptyIfNull (FileWriter writer, StringID string)
 Write StringID with 8-bit length or empty string if null.

Public Attributes

Persistency pPersistency
 Persistency with factories.
Dictionary pVariables
 Variables.
int pVersion
 File version number.

Static Public Attributes

static final String varConvoPlayback = "conversationPlayback"
 Variable conversation playback.
static final String varLoadAnimator = "loadAnimator"
 Variable animation loader.
static final String varLoadBehaviorTree = "loadBehaviorTree"
 Variable behavior tree loader.
static final String varLoadConversation = "loadConversation"
 Variable conversation loader.
static final String varLoadStateMachine = "loadStateMachine"
 Variable state machine loader.

Detailed Description

Persistency environment for reading and writing for complex objects.

Carries information required to properly restore complex objects. Stores a file version number which can be used to track file format changes. The file version is static during the lifetime of the object instance. Provides also helper methods to reduce code lines for typical persistency tasks.

Variables can be set by the user to temporarily store additional information specific persistency factories required to properly restore objects. Variables are identified by a string name and can contain any type of object. Best practice is to create a copy of a persistency environment if temporary variables have to be modified and use this new environment for subsequent restoring. You can also set and restore the temporary variables but using a copy of a persistency environment is simpler.

Member Function Documentation

◆ forEachVariable()

void Dragengine.LoadSave.PersistencyEnvironment.forEachVariable ( Block ablock)

Visit variables with block with parameters String name and Object value.

References getVariable().

Referenced by readBool().

◆ getPersistency()

Persistency Dragengine.LoadSave.PersistencyEnvironment.getPersistency ( )

Persistency with factories.

References new(), and pVariables.

Referenced by getVariable().

◆ getVariable() [1/2]

Object Dragengine.LoadSave.PersistencyEnvironment.getVariable ( String name)

Variable value.

Exceptions
EInvalidParamNamed variable is absent.

References getPersistency().

Referenced by forEachVariable(), and setVariables().

◆ getVariable() [2/2]

Object Dragengine.LoadSave.PersistencyEnvironment.getVariable ( String name,
Object defaultValue )

Variable value or default value if absent.

References pPersistency.

◆ getVersion()

int Dragengine.LoadSave.PersistencyEnvironment.getVersion ( )

File version number.

References new(), pPersistency, pVariables, and pVersion.

Referenced by setVariable().

◆ new() [1/3]

PersistencyEnvironment Dragengine.LoadSave.PersistencyEnvironment.new ( Persistency persistency)

Create persistency environment.

Referenced by getPersistency(), getVersion(), new(), new(), readString16OrNullIfEmpty(), and writeObjectOrNull().

◆ new() [2/3]

PersistencyEnvironment Dragengine.LoadSave.PersistencyEnvironment.new ( Persistency persistency,
int version )

Create persistency environment.

References new().

◆ new() [3/3]

PersistencyEnvironment Dragengine.LoadSave.PersistencyEnvironment.new ( PersistencyEnvironment environment)

Create copy of persistency environment.

References new(), pPersistency, and pVersion.

◆ readBool()

bool Dragengine.LoadSave.PersistencyEnvironment.readBool ( FileReader reader)

Read boolean.

References forEachVariable().

Referenced by writeObjectOrNull().

◆ readObject()

Persistable Dragengine.LoadSave.PersistencyEnvironment.readObject ( FileReader reader)

Read object using factory and file reader.

Exceptions
EInvalidParamreader is null.
EInvalidParamRead factory name is absent in getPersistency().

Referenced by writeObjectOrNull().

◆ readObjectOrNull()

Persistable Dragengine.LoadSave.PersistencyEnvironment.readObjectOrNull ( FileReader reader)

Read object using factory and file reader or null if empty factory name.

Exceptions
EInvalidParamRead factory name is absent in getPersistency().

References pVariables, varLoadAnimator, varLoadBehaviorTree, varLoadConversation, and varLoadStateMachine.

Referenced by writeObjectOrNull().

◆ readString16OrNullIfEmpty()

String Dragengine.LoadSave.PersistencyEnvironment.readString16OrNullIfEmpty ( FileReader reader)

Read string with 16-bit length or null if empty.

References new(), and pVariables.

Referenced by writeObjectOrNull().

◆ readString8OrNullIfEmpty()

String Dragengine.LoadSave.PersistencyEnvironment.readString8OrNullIfEmpty ( FileReader reader)

Read string with 8-bit length or null if empty.

References pVariables.

Referenced by writeObject().

◆ readStringIDOrNullIfEmpty()

StringID Dragengine.LoadSave.PersistencyEnvironment.readStringIDOrNullIfEmpty ( FileReader reader)

Read StringID with 8-bit length or null if empty.

References pVariables, and removeVariable().

Referenced by writeObjectOrNull().

◆ removeAllVariables()

void Dragengine.LoadSave.PersistencyEnvironment.removeAllVariables ( )

Remove all variables.

Referenced by writeStringIDOrEmptyIfNull().

◆ removeVariable()

void Dragengine.LoadSave.PersistencyEnvironment.removeVariable ( String name)

Remove variable if present.

Referenced by readStringIDOrNullIfEmpty().

◆ setVariable()

void Dragengine.LoadSave.PersistencyEnvironment.setVariable ( String name,
Object value )

Set variable.

References getVersion(), and pVersion.

Referenced by writeString8OrEmptyIfNull().

◆ setVariables()

void Dragengine.LoadSave.PersistencyEnvironment.setVariables ( PersistencyEnvironment environment)

Set variables from another environment.

References getVariable(), and pVariables.

Referenced by writeBool().

◆ writeBool()

void Dragengine.LoadSave.PersistencyEnvironment.writeBool ( FileWriter writer,
bool value )

Write boolean.

References pVariables, and setVariables().

Referenced by writeObjectOrNull().

◆ writeObject()

void Dragengine.LoadSave.PersistencyEnvironment.writeObject ( FileWriter writer,
Persistable object )

Write object using file writer.

Writes persistency factory name as string with 8-bit length and then calls Persistable.writeToFile().

Exceptions
EInvalidParamwriter is null.
EInvalidParamobject is null.
EInvalidParamobject.persistencyFactoryName() is empty.

References readString8OrNullIfEmpty().

Referenced by writeObjectOrNull().

◆ writeObjectOrNull()

void Dragengine.LoadSave.PersistencyEnvironment.writeObjectOrNull ( FileWriter writer,
Persistable object )

Write object or null using file writer.

If object is null writes empty string with 8-bit length. Otherwise writes persistency factory name as string with 8-bit length and then calls Persistable.writeToFile().

Exceptions
EInvalidParamwriter is null.
EInvalidParamobject is not null and object.persistencyFactoryName() is empty.

References new(), pPersistency, readBool(), readObject(), readObjectOrNull(), readString16OrNullIfEmpty(), readStringIDOrNullIfEmpty(), writeBool(), writeObject(), writeObjectOrNull(), writeString16OrEmptyIfNull(), writeString8OrEmptyIfNull(), and writeStringIDOrEmptyIfNull().

Referenced by writeObjectOrNull().

◆ writeString16OrEmptyIfNull()

void Dragengine.LoadSave.PersistencyEnvironment.writeString16OrEmptyIfNull ( FileWriter writer,
String string )

Write string with 16-bit length or empty string if null.

Referenced by writeObjectOrNull().

◆ writeString8OrEmptyIfNull()

void Dragengine.LoadSave.PersistencyEnvironment.writeString8OrEmptyIfNull ( FileWriter writer,
String string )

Write string with 8-bit length or empty string if null.

References setVariable().

Referenced by writeObjectOrNull().

◆ writeStringIDOrEmptyIfNull()

void Dragengine.LoadSave.PersistencyEnvironment.writeStringIDOrEmptyIfNull ( FileWriter writer,
StringID string )

Write StringID with 8-bit length or empty string if null.

References pVariables, and removeAllVariables().

Referenced by writeObjectOrNull().

Member Data Documentation

◆ pPersistency

Persistency Dragengine.LoadSave.PersistencyEnvironment.pPersistency

Persistency with factories.

Referenced by getVariable(), getVersion(), new(), and writeObjectOrNull().

◆ pVariables

◆ pVersion

int Dragengine.LoadSave.PersistencyEnvironment.pVersion

File version number.

Referenced by getVersion(), new(), and setVariable().

◆ varConvoPlayback

final String Dragengine.LoadSave.PersistencyEnvironment.varConvoPlayback = "conversationPlayback"
static

Variable conversation playback.

Used by some factories to call one of the methods subclassed by a game class. If variable is not set factories will use null objects where possible while in other cases it might fail loading. In this case subclasses are responsible to restore the missing objects.

If set has to be an instance of ConversationPlayback.

◆ varLoadAnimator

final String Dragengine.LoadSave.PersistencyEnvironment.varLoadAnimator = "loadAnimator"
static

Variable animation loader.

Used by some factories to load animators. If variable is not set factories will consider loading the resource having failed. Some can cope with this while others throw an exception. The following factories are known to use this variable:

  • ConversationGesturePlayback

If set has to be an instance of LoadAnimator.

Referenced by readObjectOrNull().

◆ varLoadBehaviorTree

final String Dragengine.LoadSave.PersistencyEnvironment.varLoadBehaviorTree = "loadBehaviorTree"
static

Variable behavior tree loader.

Used by some factories to load behavior trees. If variable is not set factories will consider loading the resource having failed. Some can cope with this while others throw an exception. The following factories are known to use this variable:

If set has to be an instance of LoadBehaviorTree.

Referenced by readObjectOrNull().

◆ varLoadConversation

final String Dragengine.LoadSave.PersistencyEnvironment.varLoadConversation = "loadConversation"
static

Variable conversation loader.

Used by some factories to load conversations. If variable is not set factories will consider loading the resource having failed. Some can cope with this while others throw an exception. The following factories are known to use this variable:

  • ConversationPlayback

If set has to be an instance of LoadConversation.

Referenced by readObjectOrNull().

◆ varLoadStateMachine

final String Dragengine.LoadSave.PersistencyEnvironment.varLoadStateMachine = "loadStateMachine"
static

Variable state machine loader.

Used by some factories to load state machines. If variable is not set factories will consider loading the resource having failed. Some can cope with this while others throw an exception. The following factories are known to use this variable:

If set has to be an instance of LoadStateMachine.

Referenced by readObjectOrNull().


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