OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
RangeSelector.cpp
Go to the documentation of this file.
1//
2// Class RangeSelector
3// This abstract class runs through a beam line and calls the pure
4// virtual methods RangeSelector::handleXXX() for each element or
5// beamline in a range.
6//
7// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
8// All rights reserved
9//
10// This file is part of OPAL.
11//
12// OPAL is free software: you can redistribute it and/or modify
13// it under the terms of the GNU General Public License as published by
14// the Free Software Foundation, either version 3 of the License, or
15// (at your option) any later version.
16//
17// You should have received a copy of the GNU General Public License
18// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
19//
25#include "Beamlines/Beamline.h"
27
28class Element;
29
30RangeSelector::RangeSelector(const Beamline& beamline, const RangeRep& range)
31 : DefaultVisitor(beamline, false, false), itsRange(range) {}
32
34
39
41 // Are we past the beginning of the range ?
42 itsRange.enter(fep);
43
44 // Do the required operations on the beamline or element.
45 ElementBase* base = fep.getElement();
46
47 if (dynamic_cast<Beamline*>(base)) {
48 handleBeamline(fep);
49 } else {
50 handleElement(fep);
51 }
52
53 // Are we past the end of the range ?
54 itsRange.leave(fep);
55}
56
60
62 // Default: delegate algorithm to the element, if in range.
63 if (itsRange.isActive()) {
65 }
66}
An abstract sequence of beam line components.
Definition Beamline.h:34
void visitFlaggedElmPtr(const FlaggedElmPtr &) override
Apply the algorithm to a FlaggedElmPtr.
void execute() override
Apply the algorithm to the top-level beamline.
ElementBase * getElement() const
Get the element pointer.
Definition ElmPtr.h:56
A section of a beam line.
Representation of a range within a beam line or sequence.
Definition RangeRep.h:33
bool isActive() const
Test for active range.
Definition RangeRep.cpp:52
void initialize()
Initialise data for search.
Definition RangeRep.cpp:42
void leave(const FlaggedElmPtr &) const
Leave an element or line.
Definition RangeRep.cpp:63
void enter(const FlaggedElmPtr &) const
Enter an element or line.
Definition RangeRep.cpp:54
virtual void handleElement(const FlaggedElmPtr &)
The operation to be done for elements.
virtual ~RangeSelector()
virtual void visitFlaggedElmPtr(const FlaggedElmPtr &)
Apply the visitor to an FlaggedElmPtr.
virtual void handleBeamline(const FlaggedElmPtr &)
The operation to be done for beamlines.
virtual void execute()
Execute the algorithm.
RangeRep itsRange
Working data for range.