experimental: allow implicit converisons to/from Placement-ID
This commit is contained in:
parent
120973311a
commit
884e3600bd
7 changed files with 42 additions and 10 deletions
|
|
@ -93,7 +93,8 @@ namespace mobject {
|
|||
: public lib::Handle<MO>
|
||||
{
|
||||
typedef lib::Handle<MO> _Handle;
|
||||
|
||||
typedef PlacementMO::Id<MO> _Id;
|
||||
|
||||
|
||||
PlacementRef<MO> pRef_;
|
||||
using _Handle::smPtr_;
|
||||
|
|
@ -126,13 +127,22 @@ namespace mobject {
|
|||
|
||||
|
||||
/** allow to use a MObjectRef like a (bare) PlacementRef
|
||||
* @note not test if this MObjectRef is NIL */
|
||||
* @note no test if this MObjectRef is NIL */
|
||||
PlacementRef<MO> const&
|
||||
getRef() const
|
||||
{
|
||||
return pRef_;
|
||||
}
|
||||
|
||||
/** allow to use MObjectRef instead of a Placement-ID (hash)
|
||||
* @todo not sure if that leads to unexpected conversions,
|
||||
* because the underlying implementation can be
|
||||
* converted to size_t */ //////////////////////////TICKET #682 revisit that decision later
|
||||
operator _Id const&() const
|
||||
{
|
||||
return pRef_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** resolves the referred placement to an
|
||||
|
|
|
|||
|
|
@ -68,6 +68,10 @@ namespace session {
|
|||
: anchor_(constitutingPlacement)
|
||||
{ }
|
||||
|
||||
Scope::Scope (PlacementMO::ID const& constitutingPlacement)
|
||||
: anchor_(constitutingPlacement)
|
||||
{ }
|
||||
|
||||
|
||||
Scope::Scope ()
|
||||
: anchor_()
|
||||
|
|
|
|||
|
|
@ -72,6 +72,9 @@ namespace session {
|
|||
Scope (PlacementMO const& constitutingPlacement);
|
||||
Scope (); ///< unlocated NIL scope
|
||||
|
||||
explicit
|
||||
Scope (PlacementMO::ID const& constitutingPlacement);
|
||||
|
||||
Scope (Scope const&);
|
||||
Scope& operator= (Scope const&);
|
||||
|
||||
|
|
|
|||
|
|
@ -179,13 +179,19 @@ namespace session {
|
|||
{
|
||||
return resolvingWrapper_;
|
||||
}
|
||||
|
||||
|
||||
PlacementMO&
|
||||
getScope (PlacementMO const& placement2locate)
|
||||
{
|
||||
return IMPL::getPlacementIndex().getScope(placement2locate);
|
||||
}
|
||||
|
||||
PlacementMO&
|
||||
getScope (PlacementMO::ID const& placement2locate)
|
||||
{
|
||||
return IMPL::getPlacementIndex().getScope(placement2locate);
|
||||
}
|
||||
|
||||
PlacementMO&
|
||||
getScopeRoot()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ namespace session {
|
|||
static QueryResolver const& getResolver();
|
||||
|
||||
static PlacementMO& getScope (PlacementMO const&);
|
||||
static PlacementMO& getScope (PlacementMO::ID const&);
|
||||
static PlacementMO& getScopeRoot();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -162,6 +162,13 @@ namespace session {
|
|||
}
|
||||
|
||||
|
||||
PlacementMO&
|
||||
SessionServiceExploreScope::getScope (PlacementMO::ID const& placementToLocate)
|
||||
{
|
||||
return SessionImplAPI::current->getScope(placementToLocate);
|
||||
}
|
||||
|
||||
|
||||
/** @return root scope of the current model (session datastructure) */
|
||||
PlacementMO&
|
||||
SessionServiceExploreScope::getScopeRoot()
|
||||
|
|
|
|||
|
|
@ -100,7 +100,8 @@ namespace test {
|
|||
MORef<DummyMO> dummy1 = queryAPI.pick (elementID_contains("MO2"));
|
||||
CHECK (dummy1);
|
||||
CHECK (dummy1->isValid());
|
||||
INFO (test, "Location in Tree: %s", cStr(ScopePath(dummy1.getPlacement())));
|
||||
INFO (test, "Location in Tree: %s", cStr(ScopePath(dummy1.getPlacement())));
|
||||
|
||||
string elementID = dummy1->operator string();
|
||||
CHECK (contains (elementID, "MO2"));
|
||||
|
||||
|
|
@ -115,12 +116,12 @@ namespace test {
|
|||
|
||||
// put aside a new handle holding onto the MObject
|
||||
PDum newPlacement(dummy1.getPlacement());
|
||||
CHECK (testSession->contains(dummy1.getRef()));
|
||||
CHECK (testSession->contains(dummy1));
|
||||
CHECK (!testSession->contains(newPlacement));
|
||||
|
||||
// and now remove the placement and all contained elements
|
||||
testSession->clear (dummy1.getRef());
|
||||
CHECK (!testSession->contains(dummy1.getRef()));
|
||||
testSession->clear (dummy1);
|
||||
CHECK (!testSession->contains(dummy1));
|
||||
|
||||
MORef<DummyMO> findAgain = queryAPI.pick (elementID_contains(specificID));
|
||||
CHECK (!findAgain); // empty result because searched element was removed from session...
|
||||
|
|
@ -128,14 +129,14 @@ namespace test {
|
|||
MORef<DummyMO> otherElm = queryAPI.pick (elementID_contains("MO1"));
|
||||
CHECK (otherElm); // now pick just some other arbitrary element
|
||||
|
||||
testSession->insert(newPlacement, otherElm.getRef());
|
||||
testSession->insert(newPlacement, otherElm);
|
||||
dummy2 = queryAPI.pick (elementID_contains(specificID));
|
||||
CHECK (dummy2);
|
||||
CHECK (dummy2 != dummy1);
|
||||
CHECK (dummy2 != newPlacement);
|
||||
CHECK (isSharedPointee(newPlacement, dummy2.getPlacement()));
|
||||
CHECK (Scope::containing(dummy2.getPlacement()) == Scope(otherElm.getPlacement()));
|
||||
INFO (test, "New treelocation: %s", cStr(ScopePath(dummy2.getPlacement())));
|
||||
CHECK (Scope::containing (dummy2.getRef()) == Scope (otherElm));
|
||||
INFO (test, "New treelocation: %s", cStr(ScopePath(dummy2.getPlacement())));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue