Envision
A visual programming IDE for object-oriented languages
List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends
Model::Reference Class Reference
Inheritance diagram for Model::Reference:
Core::Reflect< Base >

Public Member Functions

 Reference (::Model::Node *parent, ::Model::PersistentStore &store, bool loadPartially)
 
 Reference (::Model::Node *parent=nullptr)
 
 Reference (const Reference &other)
 
virtual ~Reference () override
 
Referenceclone () const override
 
virtual NodecomputeTarget () const
 
bool isResolved () const
 
virtual void load (PersistentStore &store) override
 
const QString & name () const
 
bool resolve ()
 
virtual void save (PersistentStore &store) const override
 
void setName (const QString &name)
 
void setResolutionNeeded ()
 Invalidates the target of this reference and enters a state where resolution is needed. More...
 
Nodetarget ()
 

Static Public Member Functions

static void addUnresolutionSteps (std::function< void(Node *subTree)> step)
 Adds the step function to be called when references are being unresolved after a sub tree is added. More...
 
static ReferencecreateDefaultInstance (Node *parent=nullptr)
 
static bool isReferenceResolutionEnabled ()
 
static void resolvePending ()
 
static void setReferenceResolutionEnabled (bool enable)
 
static void unresolveAfterNewSubTree (Node *subTree)
 Performs all necessary operations to unresolve refrences after a new tree has been introduced. More...
 
static void unresolveAll (Node *subTree)
 Marks all the references in the provided subTree as unresolved. More...
 
static void unresolveIfNameIntroduced (Node *subTreeToUnresolve, Node *subTreeToLookForNewNames)
 Marks as unresolved references in subTreeToUnresolve, whose name is identical to any NameText node in subTreeToLookForNewNames. More...
 
static void unresolveNames (Node *subTree, const QSet< QString > &names)
 Marks references whose name is in names in the provided subTree as unresolved. More...
 

Private Types

enum  State { ReferenceEstablished , ReferenceNeedsToBeResolved , ReferenceIsBeingResolved }
 

Private Member Functions

bool resolveHelper (bool indirect)
 
virtual void targetChanged (Node *oldTarget)
 

Static Private Member Functions

template<typename NodeType >
static void forAll (Node *subTree, std::function< void(NodeType *node)> function)
 
static void unresolveReferencesHelper (Node *subTree, bool all, const QSet< QString > &names)
 

Private Attributes

QString name_
 
State state_ {ReferenceNeedsToBeResolved}
 
Nodetarget_ {}
 

Static Private Attributes

static QList< Reference * > allReferences_
 A set of all existing reference objects. More...
 
static bool enableGlobalReferenceResolution_ {true}
 
static QSet< Reference * > pendingResolution_
 A set of all unresolved references which are pending resolution. More...
 
static QList< std::function< void(Node *subTree)> > unresolutionSteps_
 

Friends

class PersistentStore
 

Additional Inherited Members

- Protected Types inherited from Core::Reflect< Base >
using Super = Reflect< Base >
 

Member Enumeration Documentation

◆ State

Enumerator
ReferenceEstablished 
ReferenceNeedsToBeResolved 
ReferenceIsBeingResolved 

Constructor & Destructor Documentation

◆ Reference() [1/3]

Model::Reference::Reference ( ::Model::Node parent = nullptr)

◆ Reference() [2/3]

Model::Reference::Reference ( ::Model::Node parent,
::Model::PersistentStore store,
bool  loadPartially 
)

◆ Reference() [3/3]

Model::Reference::Reference ( const Reference other)

◆ ~Reference()

Model::Reference::~Reference ( )
overridevirtual

Member Function Documentation

◆ addUnresolutionSteps()

void Model::Reference::addUnresolutionSteps ( std::function< void(Node *subTree)>  step)
static

Adds the step function to be called when references are being unresolved after a sub tree is added.

◆ clone()

Reference * Model::Reference::clone ( ) const
override

◆ computeTarget()

Node * Model::Reference::computeTarget ( ) const
virtual

◆ createDefaultInstance()

Reference * Model::Reference::createDefaultInstance ( Node parent = nullptr)
static

◆ forAll()

template<typename NodeType >
void Model::Reference::forAll ( Node subTree,
std::function< void(NodeType *node)>  function 
)
staticprivate

◆ isReferenceResolutionEnabled()

bool Model::Reference::isReferenceResolutionEnabled ( )
inlinestatic

◆ isResolved()

bool Model::Reference::isResolved ( ) const
inline

◆ load()

void Model::Reference::load ( PersistentStore store)
overridevirtual

◆ name()

const QString & Model::Reference::name ( ) const
inline

◆ resolve()

bool Model::Reference::resolve ( )
inline

◆ resolveHelper()

bool Model::Reference::resolveHelper ( bool  indirect)
private

◆ resolvePending()

void Model::Reference::resolvePending ( )
static

◆ save()

void Model::Reference::save ( PersistentStore store) const
overridevirtual

◆ setName()

void Model::Reference::setName ( const QString &  name)

◆ setReferenceResolutionEnabled()

void Model::Reference::setReferenceResolutionEnabled ( bool  enable)
static

◆ setResolutionNeeded()

void Model::Reference::setResolutionNeeded ( )

Invalidates the target of this reference and enters a state where resolution is needed.

◆ target()

Node * Model::Reference::target ( )

◆ targetChanged()

void Model::Reference::targetChanged ( Node oldTarget)
privatevirtual

◆ unresolveAfterNewSubTree()

void Model::Reference::unresolveAfterNewSubTree ( Node subTree)
static

Performs all necessary operations to unresolve refrences after a new tree has been introduced.

◆ unresolveAll()

void Model::Reference::unresolveAll ( Node subTree)
static

Marks all the references in the provided subTree as unresolved.

◆ unresolveIfNameIntroduced()

void Model::Reference::unresolveIfNameIntroduced ( Node subTreeToUnresolve,
Node subTreeToLookForNewNames 
)
static

Marks as unresolved references in subTreeToUnresolve, whose name is identical to any NameText node in subTreeToLookForNewNames.

◆ unresolveNames()

void Model::Reference::unresolveNames ( Node subTree,
const QSet< QString > &  names 
)
static

Marks references whose name is in names in the provided subTree as unresolved.

◆ unresolveReferencesHelper()

void Model::Reference::unresolveReferencesHelper ( Node subTree,
bool  all,
const QSet< QString > &  names 
)
staticprivate

Friends And Related Function Documentation

◆ PersistentStore

friend class PersistentStore
friend

Member Data Documentation

◆ allReferences_

QList< Reference * > Model::Reference::allReferences_
staticprivate

A set of all existing reference objects.

◆ enableGlobalReferenceResolution_

bool Model::Reference::enableGlobalReferenceResolution_ {true}
staticprivate

◆ name_

QString Model::Reference::name_
private

◆ pendingResolution_

QSet< Reference * > Model::Reference::pendingResolution_
staticprivate

A set of all unresolved references which are pending resolution.

Note that there can be unresolved references which are not pending resolution, e.g. references in deleted branches of a tree, which are now owned by the undo stack.

◆ state_

State Model::Reference::state_ {ReferenceNeedsToBeResolved}
private

◆ target_

Node* Model::Reference::target_ {}
private

◆ unresolutionSteps_

QList< std::function< void(Node *subTree)> > Model::Reference::unresolutionSteps_
staticprivate