draft indicator (helper) to support tree navigation

This commit is contained in:
Fischlurch 2013-04-29 01:36:32 +02:00
parent 3a4198b2bc
commit e0c5b18740
5 changed files with 124 additions and 151 deletions

View file

@ -1,68 +0,0 @@
/*
HierarchyOrientationIndicator - service for
Copyright (C) Lumiera.org
2013, 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.
* *****************************************************/
/** @file hierarchy-orientation-indicator.cpp
** Service for hierarchy-orientation-indicator.
** This header defines the basics of...
**
** @note as of X/2013 this is complete bs
** @todo WIP ///////////////////////TICKET #
**
** @see ////TODO_test usage example
** @see hierarchy-orientation-indicator.cpp implementation
**
*/
#include "lib/util.hpp"
//#include "lib/symbol.hpp"
//#include "include/logging.h"
//#include "p/FI.hpp"
#include "hierarchy-orientation-indicator.hpp"
//#include <boost/noncopyable.hpp>
#include <string>
#include <map>
using std::map;
using std::string;
using util::contains;
using util::isnil;
namespace lib {
namespace { // internal details
} // internal details
/**
*
* @param id
* @return
*/
string fun (string& id)
{
return "x" + id;
}
} // namespace lib

View file

@ -1,19 +1,19 @@
/*
HIERARCHY-ORIENTATION-INDICATOR.hpp - service for
HIERARCHY-ORIENTATION-INDICATOR.hpp - helper to mark level on tree navigation
Copyright (C) Lumiera.org
2013, 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.
@ -21,115 +21,89 @@
*/
/** @file hierarchy-orientation-indicator.hpp
** Service for hierarchy-orientation-indicator.
** This header defines the basics of...
** Helper to support navigating a tree structure.
** The OrientationIndicator records reference levels (depth into the tree)
** and can then be used to determine the relative orientation between the
** previously marked reference level and the current reference level.
** This simple state capturing mechanism can be used to track the path
** of a tree visitation, or to sync an external stack with a currently
** investigated tree level.
**
** @note as of X/2013 this is complete bs
** @todo WIP ///////////////////////TICKET #
** The relative orientation value can be retrieved through an int conversion;
** to ease recursive programming, this statefull value can be incremented and
** decremented without influencing the captured reference level.
**
** @see ////TODO_test usage example
** @see hierarchy-orientation-indicator.cpp implementation
** @see job-ticket.hpp usage example
** @see HierarchyOrientationIndicator_test
**
*/
#ifndef HIERARCHY_ORIENTATION_INDICATOR_HPP_
#define HIERARCHY_ORIENTATION_INDICATOR_HPP_
#include "lib/error.hpp"
#include "lib/hash-value.h"
//#include "lib/symbol.hpp"
#include "lib/util.hpp"
#ifndef HIERARCHY_ORIENTATION_INDICATOR_H
#define HIERARCHY_ORIENTATION_INDICATOR_H
#include <boost/noncopyable.hpp>
#include <string>
namespace lib {
using lib::HashVal;
using util::isnil;
using std::string;
/**
* Basic (abstracted) view of...
*
* @see SomeSystem
* @see NA_test
*/
template<class X>
class Murps
class OrientationIndicator
{
string nothing_;
public:
explicit Murps (string const& b) :
nothing_ (b)
OrientationIndicator()
: nothing_ ()
{
}
// using default copy/assignment
/* == Adapter interface for == */
void setSolution (string const& solution = "")
operator int() const
{
UNIMPLEMENTED ("tbw");
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #888
if (isDeaf())
this->transmogrify (solution);
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #888
}
protected:
void maybe ( ) const;
friend HashVal hash_value (Murps const& entry)
{
return hash_value (entry.nothing_);
}
};
class HierarchyOrientationIndicator
{
string nothing_;
public:
explicit HierarchyOrientationIndicator (string const& b) :
nothing_ (b)
{
}
// using default copy/assignment
/* == X interface for == */
void putXY (string const& crap = "")
void
markRefLevel (size_t newRefLevel)
{
UNIMPLEMENTED ("tbw");
}
protected:
void maybe ( ) const;
public:
HierarchyOrientationIndicator ( )
OrientationIndicator&
operator+= (int adj)
{
// ////TODO Auto-generated constructor stub
UNIMPLEMENTED ("tbw");
}
friend HashVal hash_value (HierarchyOrientationIndicator const& entry)
OrientationIndicator&
operator-= (int adj)
{
// return hash_value (entry.nothing_);
this->operator +=(-adj);
return *this;
}
OrientationIndicator&
operator++ ()
{
this->operator +=(1);
return *this;
}
OrientationIndicator&
operator-- ()
{
this->operator -=(1);
return *this;
}
};
/** @internal in case
*/
template<class X>
inline void Murps<X>::maybe ( ) const
{
UNIMPLEMENTED ("tbw");
}
} // namespace lib
#endif /*HIERARCHY_ORIENTATION_INDICATOR_HPP_*/

View file

@ -37,6 +37,22 @@
** - #expandPrerequisites(JobPlanning cons&) is the operation to explore further prerequisite Jobs
** - PlanningStepGenerator yields the underlying "master beat": a sequence of frame locations to be planned
**
** \par how the PlanningState (sequence) is advanced
** PlanningState is an iterator, exposing a sequence of JobPlanning elements. On the implementation level,
** there is always just a single JobPlanning element, which represents the \em current element; this element
** lives as "state core" within the PlanningState object. Advancing to the next JobPlanning element (i.e. to
** consider the next job or prerequisite job to be planned for scheduling) is performed through the iteration
** control API exposed by JobPlanning (the free functions \c checkPoint, \c yield and \c iterNext. Actually,
** these functions are invoked through the depth-first tree exploration performed by JobPlaningSequence.
** The implementation of these invocations can be found within the IterExplorer strategy
** lib::iter_explorer::RecursiveSelfIntegration. The net result is
** - the current element is always accessed through \c yield
** - advancing to the next element happens \em either
**
** - by invoking \c iterNext (when processing a sequence of sibling job prerequisites)
** - by invoking \c integrate (when starting to explore the next level of children)
**
**
** @see DispatcherInterface_test simplified usage examples
** @see JobTicket
** @see Dispatcher
@ -151,6 +167,7 @@ namespace engine {
existingPlan.point_to_calculate_ = newStartingPoint.point_to_calculate_;
}
existingPlan.plannedOperations_.push (newStartingPoint.plannedOperations_);
existingPlan.plannedOperations_.markTreeLocation();
}
@ -173,6 +190,7 @@ namespace engine {
iterNext (JobPlanning & plan)
{
plan.plannedOperations_.pullNext();
plan.plannedOperations_.markTreeLocation();
}
};
@ -208,7 +226,7 @@ namespace engine {
/** attach and integrate the given planning details into this planning state.
* Actually the evaluation proceeds depth-first with the other state,
* returning later on to the current position for further evaluation */
* returning to the current position later for further evaluation */
PlanningState &
wrapping (JobPlanning const& startingPoint)
{
@ -366,7 +384,6 @@ namespace engine {
typedef lib::IterExplorer<PlanningStepGenerator
,lib::iter_explorer::RecursiveSelfIntegration> JobPlanningChunkStartPoint;
typedef JobPlanningChunkStartPoint::FlatMapped<SIG_expandPrerequisites>::Type ExpandedPlanningSequence;

View file

@ -30,6 +30,7 @@
#include "proc/engine/frame-coord.hpp"
//#include "lib/time/timevalue.hpp"
//#include "lib/time/timequant.hpp"
#include "lib/hierarchy-orientation-indicator.hpp"
#include "lib/linked-elements.hpp"
#include "lib/iter-adapter.hpp"
#include "lib/util.hpp"
@ -46,6 +47,7 @@ namespace engine {
//using lib::time::FSecs;
//using lib::time::Time;
using lib::LinkedElements;
using lib::OrientationIndicator;
using util::isnil;
//
//class ExitNode;
@ -154,6 +156,7 @@ using util::isnil;
typedef std::stack<SubTicketSeq> SubTicketStack; //////////////////////////TODO use a custom container to avoid heap allocations
SubTicketStack toExplore_;
OrientationIndicator orientation_;
public:
ExplorationState() { }
@ -174,6 +177,13 @@ using util::isnil;
}
void
markTreeLocation()
{
UNIMPLEMENTED ("establish tree relation to previous point");
}
void
pullNext()
{
@ -193,7 +203,7 @@ using util::isnil;
void
push (ExplorationState subExploration)
push (ExplorationState subExploration) // note: passing deliberately by value
{
if (subExploration.empty()) return;

View file

@ -333,9 +333,11 @@ namespace test {
class HierarchyOrientationIndicator_test : public Test
{
virtual void run (Arg)
virtual void
run (Arg)
{
demonstrate_tree_rebuilding ();
demonstrate_tree_rebuilding();
verify_OrientationIndicator();
}
/** @test demonstrate how a Node tree structure can be rebuilt
@ -348,17 +350,55 @@ namespace test {
* and the jobs are created while exploring the dependencies in the render engine's
* node graph (low-level-model).
*/
void demonstrate_tree_rebuilding ( )
void
demonstrate_tree_rebuilding ()
{
Node::Children testWood;
for (uint i=0; i < TEST_SEQUENCE_LENGTH; ++i)
testWood.push_back(Node());
TreeRebuilder reconstructed (depthFirst (eachAddress (testWood)) >>= exploreChildren);
TreeRebuilder reconstructed (depthFirst (eachAddress(testWood)) >>= exploreChildren);
CHECK (reconstructed.children_ == testWood);
}
void
verify_OrientationIndicator ()
{
OrientationIndicator orient;
CHECK (0 == orient);
++orient;
CHECK (+1 == orient);
----orient;
CHECK (-1 == orient);
orient.markRefLevel (2);
CHECK (+3 == orient);
orient.markRefLevel (2);
CHECK ( 0 == orient);
orient.markRefLevel (3);
CHECK (+1 == orient);
orient.markRefLevel (4);
orient.markRefLevel (5);
CHECK (+1 == orient);
orient.markRefLevel (2);
CHECK (-3 == orient);
orient += 200;
orient -= 190;
CHECK (+13 == orient);
OrientationIndicator o2(orient);
o2.markRefLevel(0);
CHECK (+3 == o2);
CHECK (+13 == orient);
}
};
/** Register this test class... */