add diagnostic self display to placement-Scope
This commit is contained in:
parent
48605827a6
commit
e48a9fb811
4 changed files with 35 additions and 5 deletions
|
|
@ -47,6 +47,7 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using lib::IterSource;
|
||||
using lib::iter_source::wrapIter;
|
||||
|
|
@ -225,6 +226,19 @@ namespace session {
|
|||
}
|
||||
|
||||
|
||||
/** Scope diagnostic self display.
|
||||
* Implemented based on the self-display of the MObject
|
||||
* attached through the scope top placement. Usually this
|
||||
* should yield a reasonably unique, descriptive string. */
|
||||
Scope::operator string() const
|
||||
{
|
||||
string res("[");
|
||||
res += anchor_->shortID();
|
||||
res += "]";
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
#include "proc/mobject/placement-ref.hpp"
|
||||
#include "lib/error.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace mobject {
|
||||
namespace session {
|
||||
|
|
@ -72,16 +74,17 @@ namespace session {
|
|||
|
||||
Scope (Scope const&);
|
||||
Scope& operator= (Scope const&);
|
||||
|
||||
|
||||
static const Scope INVALID;
|
||||
|
||||
|
||||
static Scope containing (PlacementMO const& aPlacement);
|
||||
static Scope containing (RefPlacement const& refPlacement);
|
||||
|
||||
operator std::string() const;
|
||||
Scope getParent() const;
|
||||
PlacementMO& getTop() const;
|
||||
bool isValid() const;
|
||||
bool isRoot() const;
|
||||
bool isValid() const;
|
||||
bool isRoot() const;
|
||||
|
||||
friend bool operator== (Scope const&, Scope const&);
|
||||
friend bool operator!= (Scope const&, Scope const&);
|
||||
|
|
|
|||
|
|
@ -169,9 +169,21 @@ END
|
|||
|
||||
|
||||
TEST "Placement search scope" PlacementScope_test <<END
|
||||
out: Scope: \[Label\.[0-9]{3}\]
|
||||
out: Placement<.+TestSubMO21.>
|
||||
out: Scope: \[DummyMO\.[0-9]{3}\]
|
||||
out: Placement<.+TestSubMO21.>
|
||||
out: Scope: \[DummyMO\.[0-9]{3}\]
|
||||
out: Placement<.+TestSubMO21.>
|
||||
out: Scope: \[DummyMO\.[0-9]{3}\]
|
||||
out: Placement<.+TestSubMO21.>
|
||||
out: Scope: \[DummyMO\.[0-9]{3}\]
|
||||
out: Placement<.+TestSubMO21.>
|
||||
out: Scope: \[Label\.[0-9]{3}\]
|
||||
out: Placement<.+TestSubMO2.>
|
||||
out: Scope: \[DummyMO\.[0-9]{3}\]
|
||||
out: Placement<.+TestSubMO1.>
|
||||
out: Scope: \[Label\.[0-9]{3}\]
|
||||
out: Placement<.+DummyMO.>
|
||||
return: 0
|
||||
END
|
||||
|
|
|
|||
|
|
@ -100,8 +100,9 @@ namespace test {
|
|||
{
|
||||
PlacementMO& elm = *ii;
|
||||
ASSERT (elm.isValid());
|
||||
std::cout << string(elm) << std::endl;
|
||||
Scope const& scope1 = Scope::containing(elm);
|
||||
std::cout << "Scope: " << string(scope1) << std::endl;
|
||||
std::cout << string(elm) << std::endl;
|
||||
|
||||
RefPlacement ref (elm);
|
||||
Scope const& scope2 = Scope::containing(ref);
|
||||
|
|
|
|||
Loading…
Reference in a new issue