OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
RangeSelector.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: RangeSelector.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.3 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: RangeSelector
10 // This abstract class runs through a beam line and calls the pure
11 // virtual methods RangeSelector::handleXXX() for each element or
12 // beamline in a range.
13 //
14 // ------------------------------------------------------------------------
15 //
16 // $Date: 2001/08/24 19:35:16 $
17 // $Author: jsberg $
18 //
19 // ------------------------------------------------------------------------
20 
21 #include "Tables/RangeSelector.h"
25 #include "AbstractObjects/Object.h"
26 #include "Beamlines/Beamline.h"
28 
29 class Element;
30 
31 
32 // Class RangeSelector
33 // ------------------------------------------------------------------------
34 
35 RangeSelector::RangeSelector(const Beamline &beamline, const RangeRep &range):
36  DefaultVisitor(beamline, false, false), itsRange(range)
37 {}
38 
39 
41 {}
42 
43 
47 }
48 
49 
51  // Are we past the beginning of the range ?
52  itsRange.enter(fep);
53 
54  // Do the required operations on the beamline or element.
55  ElementBase *base = fep.getElement()->removeWrappers();
56 
57  if(dynamic_cast<Beamline *>(base)) {
58  handleBeamline(fep);
59  } else {
60  handleElement(fep);
61  }
62 
63  // Are we past the end of the range ?
64  itsRange.leave(fep);
65 }
66 
67 
70 }
71 
72 
74  // Default: delegate algorithm to the element, if in range.
75  if(itsRange.isActive()) {
77  }
78 }
Interface for basic beam line object.
Definition: ElementBase.h:128
virtual void handleElement(const FlaggedElmPtr &)
The operation to be done for elements.
void leave(const FlaggedElmPtr &) const
Leave an element or line.
Definition: RangeRep.cpp:81
virtual ElementBase * removeWrappers()
Return the design element.
void enter(const FlaggedElmPtr &) const
Enter an element or line.
Definition: RangeRep.cpp:71
virtual void visitFlaggedElmPtr(const FlaggedElmPtr &)
Apply the algorithm to a FlaggedElmPtr.
RangeRep itsRange
Working data for range.
Definition: RangeSelector.h:58
Default algorithms.
bool isActive() const
Test for active range.
Definition: RangeRep.cpp:66
void initialize()
Initialise data for search.
Definition: RangeRep.cpp:55
The base class for all OPAL elements.
Definition: Element.h:46
virtual void handleBeamline(const FlaggedElmPtr &)
The operation to be done for beamlines.
virtual void visitFlaggedElmPtr(const FlaggedElmPtr &)
Apply the visitor to an FlaggedElmPtr.
virtual ~RangeSelector()
Representation of a range within a beam line or sequence.
Definition: RangeRep.h:34
An abstract sequence of beam line components.
Definition: Beamline.h:37
virtual void execute()
Apply the algorithm to the top-level beamline.
ElementBase * getElement() const
Get the element pointer.
Definition: ElmPtr.h:58
virtual void execute()
Execute the algorithm.
A section of a beam line.
Definition: FlaggedElmPtr.h:36