FrameIT
FactRecorder Class Reference

Organizes (insertion/ deletion / etc. operations) and sepperates Fact spaces. Keeps track of insertion/ deletion actions for undo and redo. More...

Inheritance diagram for FactRecorder:
IJSONsavable< FactRecorder > SolutionRecorder

Classes

class  GlobalFactDictionary
 
struct  meta
 Each Fact entry in MyFactSpace has a corresponding meta entry in MetaInf. The meta struct is a collection of meta-variables. <seealsocref="PruneWorkflow"/> More...
 
struct  stepnote
 Keeps track of insertion/ deletion/ etc. operations for undo and redo More...
 

Public Member Functions

 FactRecorder ()
 Only used by JsonConverter to initiate empty instance. More...
 
void Dispose ()
 
 FactRecorder (bool invoke=false)
 Standard Constructor for empty, ready to use FactRecorder More...
 
bool TryGetFact (string URI, out Fact found)
 Exposes Dictionary<TKey, TValue>.TryGetValue(TKey, out TValue) of MyFactSpace More...
 
meta GetFactMeta (string id)
 Exposes contens of MetaInf

See also
ContainsKey(string)
More...
 
stepnote GetWorkflow (int index)
 Exposes contens of Workflow More...
 
bool ContainsKey (string id)
 wrappes MyFactSpace.ContainsKey(id ) More...
 
bool ContainsLabel (string label)
 Looks up if there is a label Fact.GetLabel in MyFactSpace.Values More...
 
string Add (Fact value, out bool exists, bool samestep, Gadget gadget, string scroll_label, bool isImmutable=false, bool force=false)
 Call this to Add a Fact to this instance. More...
 
bool Remove (Fact value, bool samestep, Gadget gadget, bool deleteSolutionFact=false)
 Call this to Remove a Fact from this instance. If other Facts depend on value Remove(/, true)will be called recursively/ cascadingly. More...
 
bool Remove (string key, bool samestep, Gadget gadget, bool deleteImmutables=false)
 
bool safe_dependencies (string key, out List< string > dependencies)
 searches recursively for Facts where Fact.getDependentFactIds includes key / found dependencies More...
 
void undo ()
 Undoes an entire step or last softreset . No Fact will be actually added, removed or deleted; only its visablity and meta.active changes.

See also
marker, worksteps, backlog
More...
 
void redo ()
 Redoes an entire step . No Fact will be actually added, removed or deleted; only its visablity and meta.active changes.

See also
marker, worksteps, backlog
More...
 
void Clear ()
 Resets to "factory conditions". Neither deletes Facts nor invokes CommunicationEvents.RemoveFactEvent More...
 
void hardreset (bool invoke_event=true)
 Resets to "factory conditions". deletes Facts and invokes CommunicationEvents.RemoveFactEvent iff invoke_event && invoke. More...
 
void softreset ()
 Undoes all worksteps (since marker) and sets soft_resetted to true. More...
 
void fastforward ()
 Redoes all worksteps (from marker onwards) and sets soft_resetted to false. More...
 
void Draw (bool draw_all=false)
 Call this after assigning a stored instance in an empty world, that was not drawn. Redoes/ draws everything from marker = 0 to draw_all ? worksteps : backlog More...
 
void Undraw (bool force_invoke=false)
 Undraws everything by invoking CommunicationEvents.RemoveFactEvent, that is meta.active, but does not change that satus. More...
 
bool DynamiclySolved (SolutionRecorder MinimalSolution, out List< List< string > > MissingElements, out List< List< string > > Solutions)
 Used to check wether this satisfies the constrains of an Solution. Only meta.active are accounted for. More...
 
IEnumerable< GadgetGetUsedGadgets ()
 
int GetNumberOfGadgets ()
 
IEnumerable< string > GetUsedScrolls ()
 
int GetNumberOfScrolls ()
 
int GetNumberOfFacts ()
 
- Public Member Functions inherited from IJSONsavable< FactRecorder >
virtual string _IJGetName (string name)
 
virtual List< Directories > _IJGetHierarchie (List< Directories > hierarchie_base)
 
virtual bool _IJGetRawObject (out T payload, string path)
 
virtual T _IJPreProcess (T payload)
 
virtual T _IJPostProcess (T payload)
 
bool store (List< Directories > hierarchie, string name, bool use_install_folder=false, bool overwrite=true, bool deep_store=true)
 
bool store_children (List< Directories > hierarchie, string name, bool use_install_folder=false, bool overwrite=true, bool deep_store=true)
 

Static Public Member Functions

static T ReInitializeFactOrganizer< T > (T source, bool invoke, out Dictionary< string, string > old_to_new)
 Used to parse read-in FactRecorder by JsonReader and make Fact.Id conform. Also poppulates OldToNewURI More...
 
static bool FindEquivalent (IReadOnlyDictionary< string, Fact > FactSpace, Fact search, out string found_key, out Fact found_value, out bool exact, bool allow_exact=true)
 
- Static Public Member Functions inherited from IJSONsavable< FactRecorder >
static bool store (List< Directories > hierarchie, string name, T payload, bool use_install_folder=false, bool overwrite=true, bool deep_store=true)
 
static bool store_children (List< Directories > hierarchie, string name, T payload, bool use_install_folder=false, bool overwrite=true, bool deep_store=true)
 
static bool load_children (List< Directories > hierarchie, string name, ref T raw_payload, bool use_install_folder=false, bool deep_load=true, bool post_process=true)
 
static bool load (List< Directories > hierarchie, string name, out T payload, bool use_install_folder=false, bool deep_load=true, bool post_process=true)
 
static T postprocess (T payload)
 
static T preprocess (T payload)
 
static void delete_children (List< Directories > hierarchie, string name, bool use_install_folder=false, int skip_last_children=0)
 
static bool delete (List< Directories > hierarchie, string name, bool use_install_folder=false)
 

Public Attributes

bool invoke
 If set to true, Remove(string, bool) and Add(Fact, out bool, bool) will invoke CommunicationEvents.RemoveFactEvent and CommunicationEvents.AddFactEvent respectively. More...
 

Protected Attributes

List< string > ImmutableFacts = new()
 Contains Immutable Fact.Ids; e.g: From a SolutionRecorder which are being exposed to the Player. More...
 
Dictionary< Gadget,(int first_occurrence, int last_occurrence)> GadgetWorkflowDict = new()
 
Dictionary< int, GadgetWorkflowGadgetDict = new() { { -1, null } }
 
Dictionary< string, metaMetaInf = new()
 
List< stepnoteWorkflow = new()
 Keeps track of insertion/ deletion/ etc. operations for undo and redo More...
 
int marker = 0
 Notes position in Workflow for undo and redo; the pointed to element is non-acitve More...
 
int worksteps = 0
 Backlock logic redundant - for convinience. Keeps track of number of steps in Workflow. One step can consist of multiple operations.

See also
stepnote
More...
 
int backlog = 0
 Backlock logic redundant - for convinience. Keeps track of number of steps in Workflow, which are not set active. One step can consist of multiple operations.

See also
stepnote
More...
 
bool soft_resetted = false
 Set to true if recently been resetted. More...
 

Package Attributes

int MaxLabelId = 0
 Keeps track of maximum Fact.LabelId for Fact.generateLabel. More...
 
SortedSet< int > UnusedLabelIds = new()
 Stores unused Fact.LabelId for Fact.generateLabel, wich were freed in Fact.freeAutoLabel for later reuse to keep naming space compact. More...
 

Properties

IReadOnlyDictionary< string, FactMyFactSpace [get]
 
static IReadOnlyDictionary< string, FactAllFacts [get]
 
Fact this[string id] [get]
 wrappes MyFactSpace[id ]

See also
ContainsKey(string)
More...
 
string name = null [getset]
 For store(string, List<Directories>, bool, bool) and load(ref FactRecorder, bool, string, List<Directories>, bool, out Dictionary<string, string>) More...
 
string path = null [getset]
 For store(string, List<Directories>, bool, bool) and load(ref FactRecorder, bool, string, List<Directories>, bool, out Dictionary<string, string>) More...
 
- Properties inherited from IJSONsavable< FactRecorder >
string name [getset]
 
string path [getset]
 

Private Member Functions

void WorkflowAdd (stepnote note)
 prunes & adds note to Workflow; Invokes Events More...
 
void PruneWorkflow (stepnote not_me)
 set current (displayed) state in stone, a.k.a. delete non meta.active Facts for good; resets un-redo parameters More...
 
void yeetusdeletus (List< string > deletereverse, bool samestep, Gadget gadget)
 Turns every Fact in deletereverse (in reverse order) inactive, as it would be removed, but without checking for (recursive) dependencies. More...
 
void reversestep (int pos, bool samestep=false)
 reverses any entire step; adds process to Workflow! More...
 
FactRecorder IJSONsavable< FactRecorder >. _IJPostProcess (FactRecorder raw_payload)
 
FactRecorder IJSONsavable< FactRecorder >. _IJPreProcess (FactRecorder payload)
 
void InvokeFactEvent (bool creation, string Id)
 Updates MetaInf, Fact.GetLabel and invokes CommunicationEvents (latter iff invoke is set) More...
 

Static Private Member Functions

static FactRecorder ()
 

Private Attributes

IReadOnlyDictionary< string, FactJsonFactSpace = null
 

Additional Inherited Members

- Static Public Attributes inherited from IJSONsavable< FactRecorder >
static readonly IJSONsavable< T > Instance
 
static readonly FieldInfo[] JsonSaveableFields
 
static readonly FieldInfo[] JsonAutoPreProcessFields
 
static readonly FieldInfo[] JsonAutoPostProcessFields
 
static readonly FieldInfo[] JsonSeperateFields
 
- Static Protected Attributes inherited from IJSONsavable< FactRecorder >
static List< Directories > hierarchie
 

Detailed Description

Organizes (insertion/ deletion / etc. operations) and sepperates Fact spaces. Keeps track of insertion/ deletion actions for undo and redo.

Constructor & Destructor Documentation

◆ FactRecorder() [1/3]

static FactRecorder.FactRecorder ( )
staticprivate

◆ FactRecorder() [2/3]

FactRecorder.FactRecorder ( )

Only used by JsonConverter to initiate empty instance.

◆ FactRecorder() [3/3]

FactRecorder.FactRecorder ( bool  invoke = false)

Standard Constructor for empty, ready to use FactRecorder

Parameters
invokesets invoke.

Member Function Documentation

◆ _IJPostProcess()

FactRecorder IJSONsavable< FactRecorder >. FactRecorder._IJPostProcess ( FactRecorder  raw_payload)
private

◆ _IJPreProcess()

FactRecorder IJSONsavable< FactRecorder >. FactRecorder._IJPreProcess ( FactRecorder  payload)
private

◆ Add()

string FactRecorder.Add ( Fact  value,
out bool  exists,
bool  samestep,
Gadget  gadget,
string  scroll_label,
bool  isImmutable = false,
bool  force = false 
)

Call this to Add a Fact to this instance.

Warning: If return_value != value .Id, value will be deleted for good to reduce ressource usage!

Parameters
valueto be added
existstrue iff value already exists (may be inactive before opreation)
samestepset true if Fact creation happens as a subsequent/ consequent step of multiple Fact creations and/or deletions, and you whish that these are affected by a single undo/ redo step
gadgetthe Gadgetused to create this Fact or null
scroll_labelthe Scrollused to create this Fact or null
isImmutablewill eneable delete protection, will BE recorded in ImmutableFacts, will NOT be recorded in Workflow
Returns
Fact.Id of value or found Fact iff exists ==true

◆ Clear()

void FactRecorder.Clear ( )

Resets to "factory conditions". Neither deletes Facts nor invokes CommunicationEvents.RemoveFactEvent

See also
hardreset(bool)

◆ ContainsKey()

bool FactRecorder.ContainsKey ( string  id)

wrappes MyFactSpace.ContainsKey(id )

Parameters
ida Fact.Id
Returns
MyFactSpace.ContainsKey(id )

◆ ContainsLabel()

bool FactRecorder.ContainsLabel ( string  label)

Looks up if there is a label Fact.GetLabel in MyFactSpace.Values

Parameters
labelsupposed Fact.GetLabel to be checked
Returns
true iff MyFactSpace conatains a Value Fact, where Fact.GetLabel == label .

◆ Dispose()

void FactRecorder.Dispose ( )

◆ Draw()

void FactRecorder.Draw ( bool  draw_all = false)

Call this after assigning a stored instance in an empty world, that was not drawn. Redoes/ draws everything from marker = 0 to draw_all ? worksteps : backlog

Does not invoke softreset or undo in any way and thus may trigger Exceptions or undefined behaviour if any Fact in MyFactSpace is already drawn.

◆ DynamiclySolved()

bool FactRecorder.DynamiclySolved ( SolutionRecorder  MinimalSolution,
out List< List< string > >  MissingElements,
out List< List< string > >  Solutions 
)

Used to check wether this satisfies the constrains of an Solution. Only meta.active are accounted for.

Parameters
MinimalSolutiondescribes constrains
MissingElementselements which were not found in SolutionRecorder.ValidationSet in a format reflecting that of SolutionRecorder.ValidationSet
Solutionselements which were found in SolutionRecorder.ValidationSet in a format reflecting that of SolutionRecorder.ValidationSet
Returns
true iff all constrains set by MinimalSolution are met

◆ fastforward()

void FactRecorder.fastforward ( )

Redoes all worksteps (from marker onwards) and sets soft_resetted to false.

◆ FindEquivalent()

static bool FactRecorder.FindEquivalent ( IReadOnlyDictionary< string, Fact FactSpace,
Fact  search,
out string  found_key,
out Fact  found_value,
out bool  exact,
bool  allow_exact = true 
)
static

◆ GetFactMeta()

meta FactRecorder.GetFactMeta ( string  id)

Exposes contens of MetaInf

See also
ContainsKey(string)

Parameters
idor URI of Fact
Returns
meta struct of given Fact

◆ GetNumberOfFacts()

int FactRecorder.GetNumberOfFacts ( )

◆ GetNumberOfGadgets()

int FactRecorder.GetNumberOfGadgets ( )

◆ GetNumberOfScrolls()

int FactRecorder.GetNumberOfScrolls ( )

◆ GetUsedGadgets()

IEnumerable< Gadget > FactRecorder.GetUsedGadgets ( )

◆ GetUsedScrolls()

IEnumerable< string > FactRecorder.GetUsedScrolls ( )

◆ GetWorkflow()

stepnote FactRecorder.GetWorkflow ( int  index)

Exposes contens of Workflow

Parameters
indexto get
Returns
stepnote of given index

◆ hardreset()

void FactRecorder.hardreset ( bool  invoke_event = true)

Resets to "factory conditions". deletes Facts and invokes CommunicationEvents.RemoveFactEvent iff invoke_event && invoke.

See also
Clear
Parameters
invoke_eventif set to true and invoke set to true will invoke CommunicationEvents.RemoveFactEvent

◆ InvokeFactEvent()

void FactRecorder.InvokeFactEvent ( bool  creation,
string  Id 
)
private

Updates MetaInf, Fact.GetLabel and invokes CommunicationEvents (latter iff invoke is set)

Parameters
creationwether Fact is created or removed
IdFact.Id

◆ PruneWorkflow()

void FactRecorder.PruneWorkflow ( stepnote  not_me)
private

set current (displayed) state in stone, a.k.a. delete non meta.active Facts for good; resets un-redo parameters

◆ redo()

void FactRecorder.redo ( )

Redoes an entire step . No Fact will be actually added, removed or deleted; only its visablity and meta.active changes.

See also
marker, worksteps, backlog

◆ ReInitializeFactOrganizer< T >()

static T FactRecorder.ReInitializeFactOrganizer< T > ( source,
bool  invoke,
out Dictionary< string, string >  old_to_new 
)
static

Used to parse read-in FactRecorder by JsonReader and make Fact.Id conform. Also poppulates OldToNewURI

Parameters
targetto be parsed into, will be overwritten. If invoke = true, target should be StageStatic.stage.factState, outherwise InvokeFactEvent(bool, string) will cause Exceptions when it invokes Events of CommunicationEvents
sourceinstance to be parsed
invokesee invoke
old_to_newGenerated to map Key outdated Fact.Ids to corresponding Value updatated Fact.Ids.
Type Constraints
T :FactRecorder 
T :new() 

◆ Remove() [1/2]

bool FactRecorder.Remove ( Fact  value,
bool  samestep,
Gadget  gadget,
bool  deleteSolutionFact = false 
)

Call this to Remove a Fact from this instance. If other Facts depend on value Remove(/, true)will be called recursively/ cascadingly.

this will not delete a Fact, but sets it inactive for later deletion when pruned.

Parameters
valueto be removed
samestepset true if Fact deletion happens as a subsequent/ consequent step of multiple Fact creations and/or deletions, and you whish that these are affected by a single undo/ redo step
gadgetthe Gadgetused to delete value or null
deleteSolutionFactcan overwrite protection from Facts imported from a SolutionRecorder
Returns
true iff value .Id was found.

◆ Remove() [2/2]

bool FactRecorder.Remove ( string  key,
bool  samestep,
Gadget  gadget,
bool  deleteImmutables = false 
)

this will not delete a Fact, but sets it inactive for later deletion when pruned.

Parameters
keyto be removed
samestepset true if Fact deletion happens as a subsequent/ consequent step of multiple Fact creations and/or deletions, and you whish that these are affected by a single undo/ redo step
gadgetthe Gadgetused to delete value or null
deleteImmutablescan overwrite protection from Facts in ImmutableFacts
Returns
true iff value was found.

◆ reversestep()

void FactRecorder.reversestep ( int  pos,
bool  samestep = false 
)
private

reverses any entire step; adds process to Workflow!

Warning: unused therefore untested and unmaintained.

Parameters
posposition after steptail-end of the step to be reversed
samestepsee yeetusdeletus(List<string>, bool).samestep

◆ safe_dependencies()

bool FactRecorder.safe_dependencies ( string  key,
out List< string >  dependencies 
)

searches recursively for Facts where Fact.getDependentFactIds includes key / found dependencies

Parameters
keyto be cross referenced
dependenciesall Facts where Fact.getDependentFactIds includes key / found dependencies
Returns
false if any dependencies are steproots

◆ softreset()

void FactRecorder.softreset ( )

Undoes all worksteps (since marker) and sets soft_resetted to true.

◆ TryGetFact()

bool FactRecorder.TryGetFact ( string  URI,
out Fact  found 
)

Exposes Dictionary<TKey, TValue>.TryGetValue(TKey, out TValue) of MyFactSpace

Parameters
URIFact.Id to search for
foundFact iff found, else null
Returns
wehter Fact with Fact.Id was found

◆ undo()

void FactRecorder.undo ( )

Undoes an entire step or last softreset . No Fact will be actually added, removed or deleted; only its visablity and meta.active changes.

See also
marker, worksteps, backlog

◆ Undraw()

void FactRecorder.Undraw ( bool  force_invoke = false)

Undraws everything by invoking CommunicationEvents.RemoveFactEvent, that is meta.active, but does not change that satus.

Parameters
force_invokeif set true, invokes CommunicationEvents.RemoveFactEvent for every Fact regardles of meta.active status or invoke

◆ WorkflowAdd()

void FactRecorder.WorkflowAdd ( stepnote  note)
private

prunes & adds note to Workflow; Invokes Events

Parameters
noteto be added

◆ yeetusdeletus()

void FactRecorder.yeetusdeletus ( List< string >  deletereverse,
bool  samestep,
Gadget  gadget 
)
private

Turns every Fact in deletereverse (in reverse order) inactive, as it would be removed, but without checking for (recursive) dependencies.

Parameters
deletereverseto be removed, but without checking for (recursive) dependencies
samestepsee Remove(string, bool).samestep. Only applies to last (first iteration) element of deletereverse ; for everything else samestep will be set to true.

Member Data Documentation

◆ backlog

int FactRecorder.backlog = 0
protected

Backlock logic redundant - for convinience. Keeps track of number of steps in Workflow, which are not set active. One step can consist of multiple operations.

See also
stepnote

◆ GadgetWorkflowDict

Dictionary<Gadget, (int first_occurrence, int last_occurrence)> FactRecorder.GadgetWorkflowDict = new()
protected

  • Key: Gadget Used Gadget
  • Value: (int first_occurrence, int last_occurrence) First and Last occurence of gadget in Workflow

◆ ImmutableFacts

List<string> FactRecorder.ImmutableFacts = new()
protected

Contains Immutable Fact.Ids; e.g: From a SolutionRecorder which are being exposed to the Player.

Will NOT be recorded in Workflow!

◆ invoke

bool FactRecorder.invoke

If set to true, Remove(string, bool) and Add(Fact, out bool, bool) will invoke CommunicationEvents.RemoveFactEvent and CommunicationEvents.AddFactEvent respectively.

◆ JsonFactSpace

IReadOnlyDictionary<string, Fact> FactRecorder.JsonFactSpace = null
private

◆ marker

int FactRecorder.marker = 0
protected

Notes position in Workflow for undo and redo; the pointed to element is non-acitve

◆ MaxLabelId

int FactRecorder.MaxLabelId = 0
package

Keeps track of maximum Fact.LabelId for Fact.generateLabel.

◆ MetaInf

Dictionary<string, meta> FactRecorder.MetaInf = new()
protected

◆ soft_resetted

bool FactRecorder.soft_resetted = false
protected

Set to true if recently been resetted.

◆ UnusedLabelIds

SortedSet<int> FactRecorder.UnusedLabelIds = new()
package

Stores unused Fact.LabelId for Fact.generateLabel, wich were freed in Fact.freeAutoLabel for later reuse to keep naming space compact.

◆ Workflow

List<stepnote> FactRecorder.Workflow = new()
protected

Keeps track of insertion/ deletion/ etc. operations for undo and redo

◆ WorkflowGadgetDict

Dictionary<int, Gadget> FactRecorder.WorkflowGadgetDict = new() { { -1, null } }
protected

  • Key: int First occurence of gadget in Workflow
  • Value: Gadget Used Gadget

◆ worksteps

int FactRecorder.worksteps = 0
protected

Backlock logic redundant - for convinience. Keeps track of number of steps in Workflow. One step can consist of multiple operations.

See also
stepnote

Property Documentation

◆ AllFacts

IReadOnlyDictionary<string, Fact> FactRecorder.AllFacts
staticget

◆ MyFactSpace

IReadOnlyDictionary<string, Fact> FactRecorder.MyFactSpace
get

◆ name

string FactRecorder.name = null
getset

For store(string, List<Directories>, bool, bool) and load(ref FactRecorder, bool, string, List<Directories>, bool, out Dictionary<string, string>)

◆ path

string FactRecorder.path = null
getset

For store(string, List<Directories>, bool, bool) and load(ref FactRecorder, bool, string, List<Directories>, bool, out Dictionary<string, string>)

◆ this[string id]

Fact FactRecorder.this[string id]
get

wrappes MyFactSpace[id ]

See also
ContainsKey(string)

Parameters
ida Fact.Id in MyFactSpace
Returns
MyFactSpace[id ]

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