Leviathan  0.8.0.0
Leviathan game engine
Leviathan::SyncedValue Class Reference

Class that encapsulates a value that can be used for syncing. More...

#include <SyncedVariables.h>

Public Member Functions

DLLEXPORT SyncedValue (NamedVariableList *newddata, bool passtoclients=true, bool allowevents=true)
 Creates a new variable that can be synced with others. More...
 
DLLEXPORT ~SyncedValue ()
 
DLLEXPORT void NotifyUpdated ()
 Call after changing the HeldVariables. More...
 
DLLEXPORT NamedVariableListGetVariableAccess () const
 Gets a direct access to the variables. More...
 

Protected Member Functions

void _MasterYouCalled (SyncedVariables *owner)
 Sets the owner, which is very important. More...
 

Protected Attributes

bool PassToClients
 
bool AllowSendEvents
 If set to true sends generic update events. More...
 
NamedVariableListHeldVariables
 Holds the actual variables. More...
 
SyncedVariablesOwner = nullptr
 

Detailed Description

Class that encapsulates a value that can be used for syncing.

See also
SyncedVariables

Definition at line 18 of file SyncedVariables.h.

Constructor & Destructor Documentation

◆ SyncedValue()

DLLEXPORT Leviathan::SyncedValue::SyncedValue ( NamedVariableList newddata,
bool  passtoclients = true,
bool  allowevents = true 
)

Creates a new variable that can be synced with others.

Parameters
newddataNamedVariableList allocated with the new operator and filled with the initial wanted data
passtoclientsControls if this is actually sent, can be used to create hidden values
alloweventsIf true send GenericEvent when value is updated

Definition at line 475 of file SyncedVariables.cpp.

476  :
477  PassToClients(passtoclients), AllowSendEvents(allowevents), HeldVariables(newddata)
478 {
479 
480 }
NamedVariableList * HeldVariables
Holds the actual variables.
bool AllowSendEvents
If set to true sends generic update events.

◆ ~SyncedValue()

DLLEXPORT Leviathan::SyncedValue::~SyncedValue ( )

Definition at line 482 of file SyncedVariables.cpp.

482  {
483  // Release the data //
485 }
NamedVariableList * HeldVariables
Holds the actual variables.
#define SAFE_DELETE(x)
Definition: Define.h:153

Member Function Documentation

◆ _MasterYouCalled()

void Leviathan::SyncedValue::_MasterYouCalled ( SyncedVariables owner)
protected

Sets the owner, which is very important.

Returns
Returns false when the name is invalid

Definition at line 496 of file SyncedVariables.cpp.

496  {
497  Owner = owner;
498 }
SyncedVariables * Owner

◆ GetVariableAccess()

DLLEXPORT NamedVariableList * Leviathan::SyncedValue::GetVariableAccess ( ) const

Gets a direct access to the variables.

Warning
You will need to manually call NotifyUpdated to not break things

Definition at line 492 of file SyncedVariables.cpp.

492  {
493  return HeldVariables;
494 }
NamedVariableList * HeldVariables
Holds the actual variables.

◆ NotifyUpdated()

DLLEXPORT void Leviathan::SyncedValue::NotifyUpdated ( )

Call after changing the HeldVariables.

Definition at line 487 of file SyncedVariables.cpp.

487  {
488  // Send to the Owner for doing stuff //
489  Owner->_NotifyUpdatedValue(this);
490 }
void _NotifyUpdatedValue(const SyncedValue *const valtosync, int useid=-1)
Sends update notifications about a variable.
SyncedVariables * Owner

Member Data Documentation

◆ AllowSendEvents

bool Leviathan::SyncedValue::AllowSendEvents
protected

If set to true sends generic update events.

Definition at line 53 of file SyncedVariables.h.

◆ HeldVariables

NamedVariableList* Leviathan::SyncedValue::HeldVariables
protected

Holds the actual variables.

Definition at line 56 of file SyncedVariables.h.

◆ Owner

SyncedVariables* Leviathan::SyncedValue::Owner = nullptr
protected

Definition at line 58 of file SyncedVariables.h.

◆ PassToClients

bool Leviathan::SyncedValue::PassToClients
protected

Controls whether this variable is actually sent to clients

Note
This can be used to temporarily disable sending a variable to all clients

Definition at line 50 of file SyncedVariables.h.


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