Lumiera  0.pre.03
»edit your freedom«
PlacementIndex Class Reference

#include "steam/mobject/session/placement-index.hpp"

Description

Structured compound of Placement instances with lookup capabilities.

Core of the session datastructure. Adding a Placement creates a separate instance within this network, owned and managed by the backing implementation. All placements are related in a tree-like hierarchy of scopes, where each Placement is within the scope of a parent Placement. There is an additional reverse index, allowing to find the immediate children of any given Placement efficiently. All lookup is based on the Placement's hash-IDs.

Definition at line 181 of file placement-index.hpp.

Public Types

using ID = PlacementMO::ID const &
 
using iterator = _ID_TableIterator
 
using PRef = PlacementRef< MObject >
 

Public Member Functions

 PlacementIndex (PlacementMO const &)
 
void clear (ID targetScope)
 recursively kill a complete scope, including the given element and all children. More...
 
void clear ()
 
bool contains (PlacementMO const &) const
 
bool contains (ID) const
 
PlacementMOfind (ID) const
 
template<class MO >
Placement< MO > & find (PlacementMO::Id< MO >) const
 
template<class MO >
Placement< MO > & find (PlacementRef< MO > const &) const
 
iterator getReferrers (ID) const
 Retrieve all the elements attached to the given entry (scope) Each element (Placement) can act as a scope, containing other Placements, which will be discovered by this query one level deep (not recursive). More...
 
PlacementMOgetRoot () const
 retrieve the logical root scope
 
PlacementMOgetScope (PlacementMO const &) const
 
PlacementMOgetScope (ID) const
 retrieve the Scope information registered alongside with the denoted Placement. More...
 
ID insert (PlacementMO const &newObj, ID targetScope)
 Add a new Placement (Object "instance") into the index. More...
 
template<class PLA >
BuildID< PLA >::Type insert (PLA const &, ID)
 convenience shortcut to insert a placement immediately followed by creating a typed-ID, allowing to retain the original typed context More...
 
bool isValid () const
 validity self-check, used for sanity checks and the session self-check. More...
 
bool remove (PlacementMO &)
 
bool remove (ID)
 Remove and discard a Placement (Object "instance") from the index. More...
 
size_t size () const
 

Classes

class  Table
 Storage and implementation backing the PlacementIndex. More...
 
class  Validator
 PlacementIndex self-verification code Executes all built-in checks automatically on object creation. More...
 

Private Types

using _ID_TableIterator = lib::TransformIter< ScopeRangeIter, PlacementMO & >
 
using _PID = PlacementMO::ID
 
using ScopeIter = std::unordered_multimap< _PID, _PID >::const_iterator
 
using ScopeRangeIter = lib::RangeIter< ScopeIter >
 

Private Attributes

unique_ptr< TablepTab_
 

Additional Inherited Members

- Private Member Functions inherited from NonCopyable
 NonCopyable (NonCopyable const &)=delete
 
NonCopyableoperator= (NonCopyable const &)=delete
 

Member Function Documentation

◆ getScope()

PlacementMO & getScope ( ID  id) const

retrieve the Scope information registered alongside with the denoted Placement.

Exceptions
error::Invalidwhen the given ID isn't registered
Note
root is it's own scope, per definition.

Definition at line 478 of file placement-index.cpp.

◆ getReferrers()

PlacementIndex::iterator getReferrers ( ID  id) const

Retrieve all the elements attached to the given entry (scope) Each element (Placement) can act as a scope, containing other Placements, which will be discovered by this query one level deep (not recursive).

Returns
a Lumiera Forward Iterator, yielding the children, possibly empty if the denoted element is a leaf.
Note
results are returned in arbitrary order (hashtable)

Definition at line 493 of file placement-index.cpp.

Referenced by PlacementIndex_test::checkContentsEnumeration(), and PlacementIndexQueryResolver::setupExploration().

+ Here is the caller graph for this function:

◆ isValid()

bool isValid ( ) const

validity self-check, used for sanity checks and the session self-check.

The following checks are performed (causing at least one full table scan)

  • root element exists and is valid.
  • each element
    • has a known scope
    • is registered as child of it's scope
  • can reach root from each scope
  • element count of the allocator matches table size

Definition at line 706 of file placement-index.cpp.

◆ insert() [1/2]

ID insert ( PlacementMO const &  newObj,
ID  targetScope 
)

Add a new Placement (Object "instance") into the index.

Usually this means effectively adding this "Object" to the Session. The given Placement is copied into the storage managed within the session. This copy within the storage is what will be "the placement of this object". It can be discovered as index (Session) content, re-accessed by the ID returned from this call and modified in the course of editing the session.

Parameters
newObjreference placement pointing to the MObject to be added
targetScoperef to a placement already added to the index, serving as container "into" which the new placement will be located
Returns
placement ID of the newly added Placement
Note
the newly added Placement has an identity of its own.

Definition at line 513 of file placement-index.cpp.

Referenced by SessionImpl::attach().

+ Here is the caller graph for this function:

◆ remove()

bool remove ( ID  id)

Remove and discard a Placement (Object "instance") from the index.

Usually this means removing this Object from the session.

Returns
true if actually removed an object.
Exceptions
error::Stateif the object to be removed is an non-empty scope

Definition at line 530 of file placement-index.cpp.

◆ insert() [2/2]

BuildID< PLA >::Type insert ( PLA const &  newObj,
ID  targetScope 
)

convenience shortcut to insert a placement immediately followed by creating a typed-ID, allowing to retain the original typed context

Todo:

this solution is half-baked ///////////////////////////////////TICKET #523

is this API used in application code? or just used in tests?

Definition at line 331 of file placement-index.hpp.

◆ clear()

void clear ( ID  targetScope)

recursively kill a complete scope, including the given element and all children.

Note
as an exception, when specifying model root, any sub-elements are cleared but root is retained

Definition at line 545 of file placement-index.cpp.

+ Inheritance diagram for PlacementIndex:
+ Collaboration diagram for PlacementIndex:

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