2009-10-14 05:48:24 +02:00
|
|
|
/*
|
|
|
|
|
SCOPE-PATH.hpp - logical access path down from Session root
|
|
|
|
|
|
|
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2009, Hermann Vosseler <Ichthyostega@web.de>
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
|
|
|
|
published by the Free Software Foundation; either version 2 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef MOBJECT_SESSION_SCOPE_PATH_H
|
|
|
|
|
#define MOBJECT_SESSION_SCOPE_PATH_H
|
|
|
|
|
|
|
|
|
|
//#include "proc/mobject/mobject.hpp"
|
2009-10-18 19:08:21 +02:00
|
|
|
//#include "proc/mobject/placement-ref.hpp"
|
|
|
|
|
#include "proc/mobject/session/scope.hpp"
|
2009-11-21 20:55:14 +01:00
|
|
|
#include "lib/bool-checkable.hpp"
|
2009-11-21 04:48:29 +01:00
|
|
|
#include "lib/iter-adapter.hpp"
|
2009-10-14 05:48:24 +02:00
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
//#include <string>
|
|
|
|
|
|
|
|
|
|
using std::vector;
|
|
|
|
|
//using std::string;
|
|
|
|
|
|
|
|
|
|
namespace mobject {
|
|
|
|
|
namespace session {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* TODO type comment
|
|
|
|
|
*/
|
|
|
|
|
class ScopePath
|
2009-11-21 20:55:14 +01:00
|
|
|
: public lib::BoolCheckable<ScopePath>
|
2009-10-14 05:48:24 +02:00
|
|
|
{
|
2009-10-18 01:30:43 +02:00
|
|
|
vector<Scope> path_;
|
2009-10-14 05:48:24 +02:00
|
|
|
|
2009-11-21 04:48:29 +01:00
|
|
|
typedef vector<Scope> _VType;
|
|
|
|
|
typedef _VType::const_reverse_iterator _VIter;
|
|
|
|
|
typedef lib::RangeIter<_VIter> _IterType;
|
|
|
|
|
|
2009-10-14 05:48:24 +02:00
|
|
|
public:
|
2009-11-21 20:55:14 +01:00
|
|
|
ScopePath ();
|
|
|
|
|
ScopePath (Scope const& leaf);
|
|
|
|
|
|
|
|
|
|
static const ScopePath INVALID;
|
|
|
|
|
|
|
|
|
|
/* == state diagnostics == */
|
|
|
|
|
bool isValid() const;
|
|
|
|
|
bool empty() const;
|
|
|
|
|
size_t size() const;
|
|
|
|
|
size_t length() const;
|
|
|
|
|
////////////////////////////////////////TICKET #429 : diagnostic output to be added later
|
2009-10-14 05:48:24 +02:00
|
|
|
|
2009-11-21 04:48:29 +01:00
|
|
|
/// Iteration is always ascending from leaf to root
|
|
|
|
|
typedef _IterType iterator;
|
|
|
|
|
iterator begin() const;
|
|
|
|
|
iterator end() const;
|
2009-10-29 04:32:00 +01:00
|
|
|
|
|
|
|
|
|
2009-11-21 20:55:14 +01:00
|
|
|
/* == relations == */
|
|
|
|
|
Scope& getLeaf() const;
|
|
|
|
|
bool endsAt (Scope const&) const;
|
|
|
|
|
bool contains (Scope const&) const;
|
|
|
|
|
bool contains (ScopePath const&) const;
|
|
|
|
|
|
|
|
|
|
friend ScopePath commonPrefix (ScopePath const&, ScopePath const&);
|
|
|
|
|
friend bool disjoint (ScopePath const&, ScopePath const&);
|
|
|
|
|
|
|
|
|
|
friend bool operator== (ScopePath const&, ScopePath const&);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* == mutations == */
|
2009-10-29 04:32:00 +01:00
|
|
|
void clear();
|
2009-11-21 20:55:14 +01:00
|
|
|
Scope& moveUp();
|
|
|
|
|
Scope& goRoot();
|
|
|
|
|
void navigate (Scope const&);
|
2009-10-29 04:32:00 +01:00
|
|
|
|
2009-10-14 05:48:24 +02:00
|
|
|
};
|
|
|
|
|
///////////////////////////TODO currently just fleshing the API
|
|
|
|
|
|
|
|
|
|
|
2009-11-21 20:55:14 +01:00
|
|
|
inline bool
|
|
|
|
|
operator== (ScopePath const& path1, ScopePath const& path2)
|
|
|
|
|
{
|
|
|
|
|
return path1.path_ == path2.path_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool
|
|
|
|
|
operator!= (ScopePath const& path1, ScopePath const& path2)
|
|
|
|
|
{
|
|
|
|
|
return !(path1 == path2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline size_t
|
|
|
|
|
ScopePath::length() const
|
|
|
|
|
{
|
|
|
|
|
return path_.size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline size_t
|
|
|
|
|
ScopePath::size() const
|
|
|
|
|
{
|
|
|
|
|
return path_.size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-11-21 04:48:29 +01:00
|
|
|
inline ScopePath::iterator
|
|
|
|
|
ScopePath::begin() const
|
|
|
|
|
{
|
|
|
|
|
return iterator (path_.rbegin(), path_.rend());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline ScopePath::iterator
|
|
|
|
|
ScopePath::end() const
|
|
|
|
|
{
|
|
|
|
|
return iterator();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-10-14 05:48:24 +02:00
|
|
|
}} // namespace mobject::session
|
|
|
|
|
#endif
|