FrameIT
FactOrganizer 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 FactOrganizer:
PublicFactOrganizer SolutionOrganizer

Classes

struct  meta
 Each Fact entry in FactDict 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

 FactOrganizer (bool invoke=false)
 Standard Constructor for empty, ready to use FactOrganizer More...
 
bool ContainsKey (string id)
 wrappes FactDict.ContainsKey(id ) More...
 
bool ContainsLabel (string label)
 Looks up if there is a label Fact.Label in FactDict.Values More...
 
string Add (Fact value, out bool exists, bool samestep=false)
 Call this to Add a Fact to this instance. More...
 
bool Remove (Fact value, bool samestep=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=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 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 (SolutionOrganizer 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...
 

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

Package Attributes

Dictionary< string, FactFactDict
 
Dictionary< string, metaMetaInf = new Dictionary<string, meta>()
 
List< stepnoteWorkflow = new List<stepnote>()
 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...
 
int MaxLabelId = 0
 Keeps track of maximum Fact.LabelId for Fact.generateLabel. More...
 
SortedSet< int > UnusedLabelIds = new SortedSet<int>()
 Stores unused Fact.LabelId for Fact.generateLabel, wich were freed in Fact.freeAutoLabel for later reuse to keep naming space compact. More...
 

Properties

Fact this[string id] [get]
 wrappes FactDict[id ]

See also
ContainsKey(string)
More...
 

Private Member Functions

bool FindEquivalent (Fact search, out string found, out bool exact)
 Looks for existent Fact (found ) which is very similar or identical (exact ) to prposed Fact (search ) More...
 
void WorkflowAdd (stepnote note)
 prunes & adds note to Workflow; Invokes Events More...
 
void PruneWorkflow ()
 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=false)
 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...
 
void InvokeFactEvent (bool creation, string Id)
 Updates MetaInf, Fact.Label and invokes CommunicationEvents (latter iff invoke is set) More...
 

Static Private Member Functions

static void FactOrganizerFromPublic (ref FactOrganizer set, PublicFactOrganizer exposed, bool invoke, out Dictionary< string, string > old_to_new)
 Used to parse JsonReader/ JsonWriter readable and creatable format of this class to an actual instance of this class. More...
 
string path = null
 For store(string, List<Directories>, bool, bool) and load(ref FactOrganizer, bool, string, List<Directories>, bool, out Dictionary<string, string>) More...
 
static List< Directories > hierState = new List<Directories> { Directories.FactStateMachines }
 For store(string, List<Directories>, bool, bool) and load(ref FactOrganizer, bool, string, List<Directories>, bool, out Dictionary<string, string>) More...
 
void store (string name, List< Directories > hierarchie=null, bool use_install_folder=false, bool overwrite=true)
 
void delete ()
 
static bool load (ref FactOrganizer set, bool draw, string name, List< Directories > hierarchie, bool use_install_folder, out Dictionary< string, string > old_to_new)
 
static void delete (string name, List< Directories > hierarchie, bool use_install_folder)
 
static void delete (string path)
 

Detailed Description

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

Constructor & Destructor Documentation

◆ FactOrganizer()

FactOrganizer.FactOrganizer ( bool  invoke = false)

Standard Constructor for empty, ready to use FactOrganizer

Parameters
invokesets invoke.

Member Function Documentation

◆ Add()

string FactOrganizer.Add ( Fact  value,
out bool  exists,
bool  samestep = 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
Returns
Fact.Id of value or found Fact iff exists ==true

◆ Clear()

void FactOrganizer.Clear ( )

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

See also
hardreset(bool)

◆ ContainsKey()

bool FactOrganizer.ContainsKey ( string  id)

wrappes FactDict.ContainsKey(id )

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

◆ ContainsLabel()

bool FactOrganizer.ContainsLabel ( string  label)

Looks up if there is a label Fact.Label in FactDict.Values

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

◆ delete() [1/3]

void FactOrganizer.delete ( )

TODO? move to interface? TODO: document

◆ delete() [2/3]

static void FactOrganizer.delete ( string  name,
List< Directories >  hierarchie,
bool  use_install_folder 
)
static

TODO? move to interface? TODO: document

◆ delete() [3/3]

static void FactOrganizer.delete ( string  path)
static

TODO? move to interface? TODO: document

◆ Draw()

void FactOrganizer.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 FactDict is already drawn.

◆ DynamiclySolved()

bool FactOrganizer.DynamiclySolved ( SolutionOrganizer  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 SolutionOrganizer.ValidationSet in a format reflecting that of SolutionOrganizer.ValidationSet
Solutionselements which were found in SolutionOrganizer.ValidationSet in a format reflecting that of SolutionOrganizer.ValidationSet
Returns
true iff all constrains set by MinimalSolution are met

◆ FactOrganizerFromPublic()

static void FactOrganizer.FactOrganizerFromPublic ( ref FactOrganizer  set,
PublicFactOrganizer  exposed,
bool  invoke,
out Dictionary< string, string >  old_to_new 
)
staticprivate

Used to parse JsonReader/ JsonWriter readable and creatable format of this class to an actual instance of this class.

TODO: repair and use JSONManager.JsonInheritenceConverter<T> o.s. to bypass all of this hardwired implementation, including the entirety of PublicFactOrganizer

Parameters
setto be parsed into, will be overwritten. If invoke = true, set should be StageStatic.stage.factState, outherwise InvokeFactEvent(bool, string) will cause Exceptions when it invokes Events of CommunicationEvents
exposedinstance to be parsed
invokesee invoke
old_to_newgenerated to map Key Fact.Id of exposed to corresponding Value Fact.Id of set

.

◆ fastforward()

void FactOrganizer.fastforward ( )

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

◆ FindEquivalent()

bool FactOrganizer.FindEquivalent ( Fact  search,
out string  found,
out bool  exact 
)
private

Looks for existent Fact (found ) which is very similar or identical (exact ) to prposed Fact (search )

does not check active state

Parameters
searchto be searched for
foundFact.Id if return value is true
exacttrue iff found == search .Id
Returns
true iff the exact same or an equivalent Fact to search was found in FactDict

◆ hardreset()

void FactOrganizer.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 FactOrganizer.InvokeFactEvent ( bool  creation,
string  Id 
)
private

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

Parameters
creationwether Fact is created or removed
IdFact.Id

◆ load()

static bool FactOrganizer.load ( ref FactOrganizer  set,
bool  draw,
string  name,
List< Directories >  hierarchie,
bool  use_install_folder,
out Dictionary< string, string >  old_to_new 
)
static

TODO? move to interface? TODO: document

◆ PruneWorkflow()

void FactOrganizer.PruneWorkflow ( )
private

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

◆ redo()

void FactOrganizer.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

◆ Remove() [1/2]

bool FactOrganizer.Remove ( Fact  value,
bool  samestep = 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
Returns
true iff value .Id was found.

◆ Remove() [2/2]

bool FactOrganizer.Remove ( string  key,
bool  samestep = 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
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
Returns
true iff value was found.

◆ reversestep()

void FactOrganizer.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 FactOrganizer.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 FactOrganizer.softreset ( )

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

◆ store()

void FactOrganizer.store ( string  name,
List< Directories >  hierarchie = null,
bool  use_install_folder = false,
bool  overwrite = true 
)

TODO? move to interface? TODO: document

◆ undo()

void FactOrganizer.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 FactOrganizer.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 FactOrganizer.WorkflowAdd ( stepnote  note)
private

prunes & adds note to Workflow; Invokes Events

Parameters
noteto be added

◆ yeetusdeletus()

void FactOrganizer.yeetusdeletus ( List< string >  deletereverse,
bool  samestep = false 
)
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 FactOrganizer.backlog = 0
package

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

◆ FactDict

Dictionary<string, Fact> FactOrganizer.FactDict
package

◆ hierState

List<Directories> FactOrganizer.hierState = new List<Directories> { Directories.FactStateMachines }
staticprivate

◆ invoke

bool FactOrganizer.invoke

◆ marker

int FactOrganizer.marker = 0
package

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

◆ MaxLabelId

int FactOrganizer.MaxLabelId = 0
package

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

◆ MetaInf

Dictionary<string, meta> FactOrganizer.MetaInf = new Dictionary<string, meta>()
package

◆ path

◆ soft_resetted

bool FactOrganizer.soft_resetted = false
package

Set to true if recently been resetted.

◆ UnusedLabelIds

SortedSet<int> FactOrganizer.UnusedLabelIds = new SortedSet<int>()
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> FactOrganizer.Workflow = new List<stepnote>()
package

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

◆ worksteps

int FactOrganizer.worksteps = 0
package

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

◆ this[string id]

Fact FactOrganizer.this[string id]
get

wrappes FactDict[id ]

See also
ContainsKey(string)

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

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