From b52a1a8366325f538cc39caf5163c008cc19ced6 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Wed, 22 Aug 2012 10:43:55 +0200 Subject: [PATCH] refactor JobTicket to remove the double layering basically we had two lines of doubly nested capsules, due to using the IterAdaptor template. Actually, the evaluation stack within JobTicket can be considered an implementation detail and thus doesn't require an iterator interface; the intention is to use this through JobPlanning solely. Thus this reworking removes the special iterator within JobTicket, but retains the idea of exposing the "current" JobTicket through a smart pointer or operator->() work done during the FrOSCon travel --- src/proc/engine/job-planning.hpp | 20 +++++------ src/proc/engine/job-ticket.hpp | 58 ++++++++++++++------------------ 2 files changed, 35 insertions(+), 43 deletions(-) diff --git a/src/proc/engine/job-planning.hpp b/src/proc/engine/job-planning.hpp index e4f6203ed..dbdcc8c52 100644 --- a/src/proc/engine/job-planning.hpp +++ b/src/proc/engine/job-planning.hpp @@ -60,8 +60,8 @@ namespace engine { */ class JobPlanning { - JobTicket::iterator plannedOperations_; - FrameCoord point_to_calculate_; + JobTicket::ExplorationState plannedOperations_; + FrameCoord point_to_calculate_; public: /** by default create the bottom element of job planning, @@ -71,12 +71,11 @@ namespace engine { JobPlanning() { } - /** further job planning can be initiated by continuing - * off a given previous planning state. This is how - * the forks are created, expanding into a multitude - * of prerequisites of a given job + /** further job planning can be initiated by continuing off a given previous planning state. + * This is how the forks are created, expanding into a multitude of prerequisites for + * the job in question. */ - JobPlanning (JobTicket::iterator const& startingPoint, FrameCoord requestedFrame) + JobPlanning (JobTicket::ExplorationState const& startingPoint, FrameCoord requestedFrame) : plannedOperations_(startingPoint) , point_to_calculate_(requestedFrame) { } @@ -112,6 +111,9 @@ namespace engine { ,this->point_to_calculate_); } + /** integrate another chain of prerequisites into the current evaluation line. + * Further evaluation will start to visit prerequisites from the new starting point, + * and return to the current evaluation chain later on exhaustion of the side chain. */ friend void integrate (JobPlanning const& newStartingPoint, JobPlanning existingPlan) { @@ -137,7 +139,7 @@ namespace engine { friend void iterNext (JobPlanning & plan) { - ++(plan.plannedOperations_); + plan.plannedOperations_.pullNext(); } }; @@ -192,8 +194,6 @@ namespace engine { // (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() - /** Extension point to be picked up by ADL. diff --git a/src/proc/engine/job-ticket.hpp b/src/proc/engine/job-ticket.hpp index 6a13df71f..56148907d 100644 --- a/src/proc/engine/job-ticket.hpp +++ b/src/proc/engine/job-ticket.hpp @@ -117,15 +117,10 @@ using lib::LinkedElements; LinkedElements requirement_; + public: class ExplorationState; friend class ExplorationState; - struct TraversalOfPrerequisites; - - public: - - typedef TraversalOfPrerequisites iterator; - JobTicket() { @@ -133,7 +128,7 @@ using lib::LinkedElements; } - iterator discoverPrerequisites() const; + ExplorationState discoverPrerequisites() const; Job createJobFor (FrameCoord coordinates); @@ -157,42 +152,39 @@ using lib::LinkedElements; // using default ctor and copy operations + bool + empty() const + { + UNIMPLEMENTED ("detect empty/no prerequisites"); + } - /* === Iteration control API for IterStateWrapper== */ - - friend bool - checkPoint (ExplorationState const& plan) - { - 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) + pullNext() + { + UNIMPLEMENTED ("step ahead to next prerequisite, maybe pop"); + } + + void + push (ExplorationState subExploration) { UNIMPLEMENTED ("integrate a branch of prerequisites"); } + + JobTicket* + operator->() const + { + UNIMPLEMENTED ("yield the current job ticket"); + // access prerequisite and follow up to prerequisite JobTicket + } + }; + - inline JobTicket::iterator + + inline JobTicket::ExplorationState JobTicket::discoverPrerequisites() const { UNIMPLEMENTED("delve into the requirement_ datastructure");