Skip to content

Commit

Permalink
update description of processors according to C++ guidelines
Browse files Browse the repository at this point in the history
- need to have a virtual destructor so that the derived class's implementation will be called when
  it is destroyed via a pointer to the base class.
- use override and only override
  • Loading branch information
tomeichlersmith committed Sep 9, 2024
1 parent 8358171 commit e1d7224
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/using/analysis/analyzer-boilerplate.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class MyAnalyzer : public framework::Analyzer {
MyAnalyzer(const std::string& name, framework::Process& p)
: framework::Analyzer(name, p) {}
~MyAnalyzer() = default;
void onProcessStart() final;
void analyze(const framework::Event& event) final;
void onProcessStart() override;
void analyze(const framework::Event& event) override;
};

void MyAnalyzer::onProcessStart() {
Expand Down
4 changes: 2 additions & 2 deletions src/using/analysis/analyzer-total-rec-energy.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class MyAnalyzer : public framework::Analyzer {
MyAnalyzer(const std::string& name, framework::Process& p)
: framework::Analyzer(name, p) {}
~MyAnalyzer() = default;
void onProcessStart() final;
void analyze(const framework::Event& event) final;
void onProcessStart() override;
void analyze(const framework::Event& event) override;
};

void MyAnalyzer::onProcessStart() {
Expand Down
11 changes: 9 additions & 2 deletions src/using/config/structure-of-event-processors.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,26 @@ class MyProducer : public Producer {
*/
MyProducer(const std::string& name, Process& p) : Producer(name, p) {}

/**
* Destructor
* Marked virtual so that it will be called when MyProducer
* is destructed via a pointer of type Producer*
*/
virtual ~MyProducer() = default;

/**
* Configure this instance of MyProducer
*
* We get an object storing all of the parameters set in the python.
*/
void configure(Parameters& params) final override;
void configure(Parameters& params) override;

/**
* Produce for the input event
*
* Here is where you do all your work on an event-by-event basis.
*/
void produce(Event& event) final override;
void produce(Event& event) override;

private:
/// a parameter we will get from python
Expand Down

0 comments on commit e1d7224

Please sign in to comment.