Skip to content

Commit

Permalink
Merge pull request #54 from Dr15Jones/outputModuleCommunicator
Browse files Browse the repository at this point in the history
Moved functionality from OutputWorker to OutputModuleCommunicator
  • Loading branch information
ktf committed Jul 8, 2013
2 parents 650e09d + 3ff66c2 commit 424b3eb
Show file tree
Hide file tree
Showing 11 changed files with 231 additions and 97 deletions.
2 changes: 1 addition & 1 deletion FWCore/Framework/interface/OutputModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace edm {
class OutputModule : public EDConsumerBase {
public:
template <typename T> friend class WorkerT;
friend class OutputWorker;
friend class ClassicOutputModuleCommunicator;
typedef OutputModule ModuleType;
typedef OutputWorker WorkerType;

Expand Down
6 changes: 3 additions & 3 deletions FWCore/Framework/interface/Schedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ namespace edm {
class BranchIDListHelper;
class EventSetup;
class ExceptionCollector;
class OutputWorker;
class OutputModuleCommunicator;
class RunStopwatch;
class UnscheduledCallProducer;
class WorkerInPath;
Expand All @@ -109,7 +109,7 @@ namespace edm {
typedef boost::shared_ptr<HLTGlobalStatus> TrigResPtr;
typedef boost::shared_ptr<Worker> WorkerPtr;
typedef std::vector<Worker*> AllWorkers;
typedef std::vector<OutputWorker*> AllOutputWorkers;
typedef std::vector<boost::shared_ptr<OutputModuleCommunicator>> AllOutputModuleCommunicators;

typedef std::vector<Worker*> Workers;

Expand Down Expand Up @@ -293,7 +293,7 @@ namespace edm {
TrigResPtr endpath_results_;

WorkerPtr results_inserter_;
AllOutputWorkers all_output_workers_;
AllOutputModuleCommunicators all_output_communicators_;
TrigPaths trig_paths_;
TrigPaths end_paths_;
std::vector<int> empty_trig_paths_;
Expand Down
23 changes: 23 additions & 0 deletions FWCore/Framework/src/OutputModuleCommunicator.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// -*- C++ -*-
//
// Package: Package
// Class : OutputModuleCommunicator
//
// Implementation:
// [Notes on implementation]
//
// Original Author: Chris Jones
// Created: Fri, 05 Jul 2013 17:36:58 GMT
// $Id$
//

// system include files

// user include files
#include "FWCore/Framework/src/OutputModuleCommunicator.h"

using namespace edm;

OutputModuleCommunicator::~OutputModuleCommunicator()
{
}
80 changes: 80 additions & 0 deletions FWCore/Framework/src/OutputModuleCommunicator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#ifndef FWCore_Framework_OutputModuleCommunicator_h
#define FWCore_Framework_OutputModuleCommunicator_h
// -*- C++ -*-
//
// Package: FWCore/Framework
// Class : OutputModuleCommunicator
//
/**\class edm::OutputModuleCommunicator OutputModuleCommunicator.h "FWCore/Framework/interface/OutputModuleCommunicator.h"
Description: Base class used by the framework to communicate with an OutputModule
Usage:
<usage>
*/
//
// Original Author: Chris Jones
// Created: Fri, 05 Jul 2013 17:36:51 GMT
// $Id$
//

// system include files
#include <map>
#include <string>
#include <vector>

// user include files
#include "DataFormats/Provenance/interface/Selections.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"

// forward declarations
namespace edm {
class OutputModuleCommunicator
{

public:
OutputModuleCommunicator() = default;
virtual ~OutputModuleCommunicator();

virtual void closeFile() = 0;

///\return true if output module wishes to close its file
virtual bool shouldWeCloseFile() const = 0;

virtual void openNewFileIfNeeded() = 0;

///\return true if no event filtering is applied to OutputModule
virtual bool wantAllEvents() const = 0;

virtual void openFile(FileBlock const& fb) = 0;

virtual void writeRun(RunPrincipal const& rp) = 0;

virtual void writeLumi(LuminosityBlockPrincipal const& lbp) = 0;

///\return true if OutputModule has reached its limit on maximum number of events it wants to see
virtual bool limitReached() const = 0;

virtual void configure(OutputModuleDescription const& desc) = 0;

virtual SelectionsArray const& keptProducts() const = 0;

virtual void selectProducts(ProductRegistry const& preg) = 0;

virtual void setEventSelectionInfo(std::map<std::string, std::vector<std::pair<std::string, int> > > const& outputModulePathPositions,
bool anyProductProduced) = 0;

virtual ModuleDescription const& description() const = 0;

private:
OutputModuleCommunicator(const OutputModuleCommunicator&) = delete; // stop default

const OutputModuleCommunicator& operator=(const OutputModuleCommunicator&) = delete; // stop default

// ---------- member data --------------------------------

};
}

#endif
96 changes: 77 additions & 19 deletions FWCore/Framework/src/OutputWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "FWCore/Framework/interface/OutputModule.h"
#include "FWCore/Framework/src/WorkerParams.h"
#include "FWCore/Framework/src/OutputWorker.h"
#include "FWCore/Framework/src/OutputModuleCommunicator.h"

namespace edm {
OutputWorker::OutputWorker(std::unique_ptr<OutputModule>&& mod,
Expand All @@ -17,48 +18,105 @@ namespace edm {

OutputWorker::~OutputWorker() {
}

class ClassicOutputModuleCommunicator: public edm::OutputModuleCommunicator {
public:
ClassicOutputModuleCommunicator(edm::OutputModule* iModule):
module_(iModule){}
virtual void closeFile() override;

///\return true if output module wishes to close its file
virtual bool shouldWeCloseFile() const override;

virtual void openNewFileIfNeeded() override;

///\return true if no event filtering is applied to OutputModule
virtual bool wantAllEvents() const override;

virtual void openFile(edm::FileBlock const& fb) override;

virtual void writeRun(edm::RunPrincipal const& rp) override;

virtual void writeLumi(edm::LuminosityBlockPrincipal const& lbp) override;

///\return true if OutputModule has reached its limit on maximum number of events it wants to see
virtual bool limitReached() const override;

virtual void configure(edm::OutputModuleDescription const& desc) override;

virtual edm::SelectionsArray const& keptProducts() const override;

virtual void selectProducts(edm::ProductRegistry const& preg) override;

virtual void setEventSelectionInfo(std::map<std::string, std::vector<std::pair<std::string, int> > > const& outputModulePathPositions,
bool anyProductProduced) override;

virtual ModuleDescription const& description() const override;


private:
inline edm::OutputModule& module() const { return *module_;}
edm::OutputModule* module_;
};

void
OutputWorker::closeFile() {
ClassicOutputModuleCommunicator::closeFile() {
module().doCloseFile();
}

bool
OutputWorker::shouldWeCloseFile() const {
ClassicOutputModuleCommunicator::shouldWeCloseFile() const {
return module().shouldWeCloseFile();
}

void
OutputWorker::openNewFileIfNeeded() {
ClassicOutputModuleCommunicator::openNewFileIfNeeded() {
module().maybeOpenFile();
}

void
OutputWorker::openFile(FileBlock const& fb) {
ClassicOutputModuleCommunicator::openFile(edm::FileBlock const& fb) {
module().doOpenFile(fb);
}

void
OutputWorker::writeRun(RunPrincipal const& rp) {
ClassicOutputModuleCommunicator::writeRun(edm::RunPrincipal const& rp) {
module().doWriteRun(rp);
}

void
OutputWorker::writeLumi(LuminosityBlockPrincipal const& lbp) {
ClassicOutputModuleCommunicator::writeLumi(edm::LuminosityBlockPrincipal const& lbp) {
module().doWriteLuminosityBlock(lbp);
}

bool ClassicOutputModuleCommunicator::wantAllEvents() const {return module().wantAllEvents();}

bool ClassicOutputModuleCommunicator::limitReached() const {return module().limitReached();}

void ClassicOutputModuleCommunicator::configure(OutputModuleDescription const& desc) {module().configure(desc);}

edm::SelectionsArray const& ClassicOutputModuleCommunicator::keptProducts() const {
return module().keptProducts();
}

void ClassicOutputModuleCommunicator::selectProducts(edm::ProductRegistry const& preg) {
module().selectProducts(preg);
}

void ClassicOutputModuleCommunicator::setEventSelectionInfo(std::map<std::string, std::vector<std::pair<std::string, int> > > const& outputModulePathPositions,
bool anyProductProduced) {
module().setEventSelectionInfo(outputModulePathPositions, anyProductProduced);
}

bool OutputWorker::wantAllEvents() const {return module().wantAllEvents();}
ModuleDescription const& ClassicOutputModuleCommunicator::description() const {
return module().description();
}

bool OutputWorker::limitReached() const {return module().limitReached();}

void OutputWorker::configure(OutputModuleDescription const& desc) {module().configure(desc);}

SelectionsArray const& OutputWorker::keptProducts() const {
return module().keptProducts();
std::unique_ptr<OutputModuleCommunicator>
OutputWorker::createOutputModuleCommunicator() {
return std::move(std::unique_ptr<OutputModuleCommunicator>{new ClassicOutputModuleCommunicator{& this->module()}});
}

void OutputWorker::selectProducts(ProductRegistry const& preg) {
module().selectProducts(preg);
}
}
24 changes: 2 additions & 22 deletions FWCore/Framework/src/OutputWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ appear in one worker.

#include <memory>

#include "FWCore/Framework/interface/OutputModule.h"
#include "FWCore/Framework/src/WorkerT.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"

Expand All @@ -25,29 +26,8 @@ namespace edm {

virtual ~OutputWorker();

// Call closeFile() on the controlled OutputModule.
void closeFile();

// Call shouldWeCloseFile() on the controlled OutputModule.
bool shouldWeCloseFile() const;

void openNewFileIfNeeded();

bool wantAllEvents() const;

void openFile(FileBlock const& fb);

void writeRun(RunPrincipal const& rp);

void writeLumi(LuminosityBlockPrincipal const& lbp);

bool limitReached() const;

void configure(OutputModuleDescription const& desc);
std::unique_ptr<OutputModuleCommunicator> createOutputModuleCommunicator() override;

SelectionsArray const& keptProducts() const;

void selectProducts(ProductRegistry const& preg);
};

}
Expand Down
Loading

0 comments on commit 424b3eb

Please sign in to comment.