diff --git a/src/lib/iter-explorer.hpp b/src/lib/iter-explorer.hpp index f95e0fa26..f89a9e992 100644 --- a/src/lib/iter-explorer.hpp +++ b/src/lib/iter-explorer.hpp @@ -789,9 +789,9 @@ namespace lib { iterate () { REQUIRE (outSeq_); - ResultIter nextStep = explore_(*outSeq_); + ResultIter nextSteps = explore_(*outSeq_); ++ outSeq_; - build(outSeq_).usingSequence(nextStep); // extension point: free function build (...).usingSequence(...) + build(outSeq_).usingSequence(nextSteps); // extension point: free function build (...).usingSequence(...) } diff --git a/src/proc/engine/job-planning.hpp b/src/proc/engine/job-planning.hpp index e7b023b51..e4f6203ed 100644 --- a/src/proc/engine/job-planning.hpp +++ b/src/proc/engine/job-planning.hpp @@ -62,7 +62,7 @@ namespace engine { { JobTicket::iterator plannedOperations_; FrameCoord point_to_calculate_; - + public: /** by default create the bottom element of job planning, * which happens to to plan no job at all. It is represented @@ -112,6 +112,12 @@ namespace engine { ,this->point_to_calculate_); } + friend void + integrate (JobPlanning const& newStartingPoint, JobPlanning existingPlan) + { + existingPlan.plannedOperations_.push (newStartingPoint.plannedOperations_); + } + /* === Iteration control API for IterStateWrapper== */ @@ -131,10 +137,12 @@ namespace engine { friend void iterNext (JobPlanning & plan) { - ++plan.plannedOperations_; + ++(plan.plannedOperations_); } }; -#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #827 + + + class PlanningState @@ -142,33 +150,32 @@ namespace engine { { typedef lib::IterStateWrapper _Iter; - JobTicket::ExplorationStack explorationStack_; public: /** inactive evaluation */ PlanningState() : _Iter() - , explorationStack_() { } explicit PlanningState (JobPlanning const& startingPoint) : _Iter(startingPoint) // note: invoking copy ctor on state core - , explorationStack_() { } // using the standard copy operations + + /* === API for JobPlanningSequence to expand the tree of prerequisites === */ + /** 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 */ + * Actually the evaluation proceeds depth-first with the other state, + * returning later on to the current position for further evaluation */ PlanningState & wrapping (JobPlanning const& startingPoint) { - explorationStack_.push (stateCore()); - stateCore() = startingPoint; + integrate (startingPoint, this->stateCore()); return *this; } @@ -179,6 +186,10 @@ namespace engine { return *this; else return this->wrapping(*prerequisites); + // explanation: PlanningState represents a sequence of successive planning points. + // actually this is implemented by switching an embedded JobPlanning element + // through a sequence of states. Thus the initial state of the investigation + // (which is a JobPlanning) can stand-in for the sequence of prerequisites } ///TODO what elements are accepted by the explorationStack? provide conversion operator to extract those from stateCore() @@ -194,17 +205,15 @@ namespace engine { { return attachmentPoint; } - - }; inline PlanningState - expandPrerequisites (JobPlanning const& calculationStep) + expandPrerequisites (PlanningState const& calculationStep) { PlanningState newSubEvaluation( - calculationStep.discoverPrerequisites()); + calculationStep->discoverPrerequisites()); return newSubEvaluation; } @@ -224,28 +233,35 @@ namespace engine { */ class PlanningStepGenerator { + public: + typedef JobPlanning value_type; + typedef JobPlanning& reference; + typedef JobPlanning * pointer; + + /* === Iteration control API for IterStateWrapper== */ friend bool checkPoint (PlanningStepGenerator const& gen) { - return bool(seq.feed()); + UNIMPLEMENTED ("determine planing chunk size"); /// return bool(seq.feed()); } friend JobPlanning& yield (PlanningStepGenerator const& gen) { - return *(seq.feed()); + UNIMPLEMENTED ("generate a single frame job planning tree"); ///return *(seq.feed()); } friend void iterNext (PlanningStepGenerator & gen) { - seq.iterate(); + UNIMPLEMENTED ("proceed to next frame"); ///////seq.iterate(); } }; +#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #827 #endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #827 @@ -254,6 +270,8 @@ namespace engine { * @todo 6/12 WIP-WIP-WIP how to prepare jobs for scheduling */ class JobPlanningSequence + : public lib::IterExplorer { public: diff --git a/src/proc/engine/job-ticket.hpp b/src/proc/engine/job-ticket.hpp index 12f74c5d6..6a13df71f 100644 --- a/src/proc/engine/job-ticket.hpp +++ b/src/proc/engine/job-ticket.hpp @@ -34,6 +34,7 @@ #include "lib/iter-adapter.hpp" #include +#include namespace proc { @@ -101,6 +102,7 @@ using lib::LinkedElements; struct Prerequisite { Prerequisite* next; + JobTicket* descriptor; }; struct Prerequisites ///< per channel @@ -110,44 +112,19 @@ using lib::LinkedElements; }; - struct PrerequisitesDiscovery - { - /////////////TODO - - /* === Iteration control API for IterStateWrapper== */ - - friend bool - checkPoint (PrerequisitesDiscovery const& plan) - { - UNIMPLEMENTED ("detect end of prerequisites"); - } - - friend JobTicket& - yield (PrerequisitesDiscovery const& plan) - { - UNIMPLEMENTED ("access prerequisite and follow up to prerequisite JobTicket"); - } - - friend void - iterNext (PrerequisitesDiscovery & plan) - { - UNIMPLEMENTED ("step ahead to next prerequisite"); - } - - }; - - LinkedElements channelConfig_; LinkedElements requirement_; + + class ExplorationState; + friend class ExplorationState; + + struct TraversalOfPrerequisites; + public: - - class ExplorationStack; - - friend class ExplorationStack; - - typedef lib::IterStateWrapper iterator; + + typedef TraversalOfPrerequisites iterator; JobTicket() @@ -156,11 +133,7 @@ using lib::LinkedElements; } - iterator - discoverPrerequisites() const - { - UNIMPLEMENTED("delve into the requirement_ datastructure"); - } + iterator discoverPrerequisites() const; Job createJobFor (FrameCoord coordinates); @@ -172,13 +145,59 @@ using lib::LinkedElements; } }; - class JobTicket::ExplorationStack + + class JobTicket::ExplorationState + { + typedef LinkedElements::iterator SubTicketSeq; + typedef std::stack SubTicketStack; //////////////////////////TODO use a custom container to avoid heap allocations + + SubTicketStack toExplore_; + + public: + // using default ctor and copy operations + + + + /* === Iteration control API for IterStateWrapper== */ + + friend bool + checkPoint (ExplorationState const& plan) { - JobTicket top_; - - public: - - }; + UNIMPLEMENTED ("detect end of prerequisites"); + } + + friend JobTicket& + yield (ExplorationState const& plan) + { + UNIMPLEMENTED ("access prerequisite and follow up to prerequisite JobTicket"); + } + + friend void + iterNext (ExplorationState & plan) + { + UNIMPLEMENTED ("step ahead to next prerequisite"); + } + }; + + + struct JobTicket::TraversalOfPrerequisites + : lib::IterStateWrapper + { + void + push (TraversalOfPrerequisites subExploration) + { + UNIMPLEMENTED ("integrate a branch of prerequisites"); + } + + }; + + + inline JobTicket::iterator + JobTicket::discoverPrerequisites() const + { + UNIMPLEMENTED("delve into the requirement_ datastructure"); + } +