/////////////////////////////////////////////////////////////////// // // Two logical groups of processors of which one is executed // sequentially depending on the result of the conditional processor. // This block executes the fProcessorList DSEvent IFF the conditional // processor returns OKTRUE or the fFalseProcessList DSEvent IFF the // conditional processor returns OKFALSE. If the conditional processor // returns anything else it does nothing. Note, the BeginOfRun and // EndOfRun methods are called for ALL processors including the // conditional. // // Author: P G Jones // // REVISION HISTORY: // 2013-10-11 : P G Jones - New File. // /////////////////////////////////////////////////////////////////// #ifndef __RAT_ConditionalProcBlock__ #define __RAT_ConditionalProcBlock__ #include #include #include namespace RAT { class ConditionalProcBlock : public ProcBlock { public: // Construct the ConditionalProcBlock // // proc: the conditional processor ConditionalProcBlock( Processor* const proc ); // Destroy the ConditionalProcBlock virtual ~ConditionalProcBlock(); // Command to add a new processor // // Will add to either the true or false list depending on the current mode. // // proc: Processor to add virtual void AddProcessorCommand( Processor* const proc ); // Command to add a new process to the end of the list // // Will add to either the true or false list depending on the current mode. // Processor is only added after the block is closed. // // proc: Processor to defer add virtual void DeferAddProcessorCommand( Processor* const proc ); // Command to add a new ConditionalProcBlock to the list // // Will add to either the true or false list depending on the current mode. // Subsequent AddCommands will be passed to this ProcBlock until it is closed. // // proc: Processor the ConditionalProcBlock should be conditional upon. virtual void IfCommand( Processor* const proc ); // Command to switch the last ConditionalProcBlock or this one to false mode. // // Will Log::Die if last processor is closed. virtual void ElseCommand(); // Command to add a new WhileProcBlock to the list, with the // // Will add to either the true or false list depending on the current mode. // Subsequent AddCommands will be passed to this ProcBlock until it is closed. // // proc: Processor the WhileProcBlock should be conditional upon. virtual void WhileCommand( Processor* const proc ); // Close the the current ProcBlock // // Will close this ProcBlock if no nested ProcBlocks are open. // // type: Identifies the command used, block will Log::Die if incorrect command applied. virtual void EndCommand( const EEndCommand type ); // Called at the beginning of a run // // Each processor is called in turn (no conditional aspect here) // // run: Data structure for the run virtual void BeginOfRun( DS::Run& run ); // Called for each event // // Firstly the conditional processor is evaluated, if the result is OKTRUE // then each true list processor is called in turn if the result is OKFALSE // then each false list processor is called in turn if the result is anything // else no processors are called. // // run: Data structure for the run // ds: Data structure for the event // // Returns a Is the net condition for all processors in the list, will be OK, FAIL or ABORT virtual Processor::Result DSEvent( DS::Run& run, DS::Entry& ds ); // Called at the end of a run. // // Each processor is called in turn (no conditional aspect) // // run: Data structure for the run virtual void EndOfRun( DS::Run& run ); // Change the mode of this conditional block // // mode: indicates the mode i.e. true or false default is false void ChangeMode( const bool mode=false ) { fTruthMode = mode; fLastAddedProcessor = NULL; } // Closes THIS clock. virtual void CloseBlock(); protected: std::vector fFalseProcessorList; // List of processors executed by this ProcBlock for each DSEvent IFF condition is OKFALSE std::vector fFalseDeferProcessorList; // List of processors to be added to the end of the FalseProcessorList on close of the block. std::vector fFalseEventProfilers; // Profiler details by processor (total time, calls) for DSEvents std::vector fFalseBeginProfilers; // Profiler details by processor (total time, calls) for BeginOfRun std::vector fFalseEndProfilers; // Profiler details by processor (total time, calls) for EndOfRun Profiler fConditionalBeginProfiler; // Profiler details (total time, calls) for the BeginOfRun call Profiler fConditionalEventProfiler; // Profiler details (total time, calls) for the conditional DSEvent call Profiler fConditionalEndProfiler; // Profiler details (total time, calls) for the EndOfRun call Processor* fConditionalProcessor; // The processor this is conditional upon bool fTruthMode; // The current list mode, applicable only when open. Decides which list processors are added to }; } // namespace RAT #endif