DefaultVisitor.h 7.83 KB
Newer Older
gsell's avatar
gsell committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#ifndef CLASSIC_DefaultVisitor_HH
#define CLASSIC_DefaultVisitor_HH

// ------------------------------------------------------------------------
// $RCSfile: DefaultVisitor.h,v $
// ------------------------------------------------------------------------
// $Revision: 1.3 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
//
// Class: DefaultVisitor
//   The default interface for a BeamlineVisitor.
//
// ------------------------------------------------------------------------
// Class category: Algorithms
// ------------------------------------------------------------------------
//
// $Date: 2000/05/03 08:16:04 $
// $Author: mad $
//
// ------------------------------------------------------------------------

#include "AbsBeamline/BeamlineVisitor.h"

snuverink_j's avatar
snuverink_j committed
26
class ElementBase;
gsell's avatar
gsell committed
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58

// Class DefaultVisitor
// ------------------------------------------------------------------------
/// Default algorithms.
//  A default implementation for all visitors that can iterate over a
//  beam line representation.
//  This abstract base class implements the default behaviour for the
//  structural classes Beamline and FlaggedElmPtr, and for all wrappers.
//  It also holds the data required for all visitors in a protected area.

class DefaultVisitor: public BeamlineVisitor {

public:

    /// Constructor.
    //  Arguments:
    //  [ol]
    //  [li]The beamline to be used.
    //  [li]If true, the beam runs backwards through the line.
    //  [li]If true, we track against the beam.
    //  [/ol]
    DefaultVisitor(const Beamline &beamline, bool backBeam, bool backTrack);

    virtual ~DefaultVisitor() = 0;

    /// Apply the algorithm to the top-level beamline.
    virtual void execute();

    /// Apply the algorithm to a beam-beam.
    virtual void visitBeamBeam(const BeamBeam &);

    /// Apply the algorithm to a collimator.
59
    virtual void visitCCollimator(const CCollimator &);
gsell's avatar
gsell committed
60 61 62 63 64 65 66

    /// Apply the algorithm to an arbitrary component.
    virtual void visitComponent(const Component &);

    /// Apply the algorithm to an cyclotron
    virtual void visitCyclotron(const Cyclotron &);

67
    /// Apply the algorithm to an opal ring..
kraus's avatar
kraus committed
68
    virtual void visitRing(const Ring &);
69

gsell's avatar
gsell committed
70 71 72
    /// Apply the algorithm to a corrector.
    virtual void visitCorrector(const Corrector &);

adelmann's avatar
adelmann committed
73 74 75
    /// Apply the algorithm to a drift.
    virtual void visitDegrader(const Degrader &);

gsell's avatar
gsell committed
76 77 78 79 80 81
    /// Apply the algorithm to a diagnostic.
    virtual void visitDiagnostic(const Diagnostic &);

    /// Apply the algorithm to a drift.
    virtual void visitDrift(const Drift &);

82 83 84
    /// Apply the algorithm to a flexible collimator
    virtual void visitFlexibleCollimator(const FlexibleCollimator &);

gsell's avatar
gsell committed
85 86 87 88 89 90 91 92 93 94 95 96
    /// Apply the algorithm to a Lambertson.
    virtual void visitLambertson(const Lambertson &);

    /// Apply the algorithm to a marker.
    virtual void visitMarker(const Marker &);

    /// Apply the algorithm to a monitor.
    virtual void visitMonitor(const Monitor &);

    /// Apply the algorithm to a multipole.
    virtual void visitMultipole(const Multipole &);

ext-rogers_c's avatar
ext-rogers_c committed
97 98 99
    /// Apply the algorithm to a multipoleT.
    virtual void visitMultipoleT(const MultipoleT &);

100 101 102 103 104 105 106 107 108
    /// Apply the algorithm to a multipoleTStraight.
    virtual void visitMultipoleTStraight(const MultipoleTStraight &);

    /// Apply the algorithm to a multipoleTCurvedConstRadius.
    virtual void visitMultipoleTCurvedConstRadius(const MultipoleTCurvedConstRadius &);

    /// Apply the algorithm to a multipoleTCurvedVarRadius.
    virtual void visitMultipoleTCurvedVarRadius(const MultipoleTCurvedVarRadius &);

109 110 111
    /// Apply the algorithm to an Offset.
    virtual void visitOffset(const Offset &);

gsell's avatar
gsell committed
112 113 114 115 116 117 118 119 120
    /// Apply the algorithm to a patch.
    virtual void visitPatch(const Patch &pat);

    /// Apply the algorithm to a probe.
    virtual void visitProbe(const Probe &prob);

    /// Apply the algorithm to a rectangular bend.
    virtual void visitRBend(const RBend &);

121 122 123
    /// Apply the algorithm to a rectangular bend.
    virtual void visitRBend3D(const RBend3D &);

124 125 126
    /// Apply the algorithm to a RF cavity.
    virtual void visitVariableRFCavity(const VariableRFCavity &vcav);

127 128 129
    /// Apply the algorithm to a RF cavity.
    virtual void visitVariableRFCavityFringeField(const VariableRFCavityFringeField &vcav);

gsell's avatar
gsell committed
130 131 132 133 134 135 136 137 138 139 140 141
    /// Apply the algorithm to a RF cavity.
    virtual void visitRFCavity(const RFCavity &);

    /// Apply the algorithm to a RF cavity.
    virtual void visitTravelingWave(const TravelingWave &);

    /// Apply the algorithm to a RF quadrupole.
    virtual void visitRFQuadrupole(const RFQuadrupole &);

    /// Apply the algorithm to a sector bend.
    virtual void visitSBend(const SBend &);

142 143 144
    /// Apply the algorithm to a sector bend.
    virtual void visitSBend3D(const SBend3D &);

ext-rogers_c's avatar
ext-rogers_c committed
145 146
    /// Apply the algorithm to a scaling FFA magnet.
    virtual void visitScalingFFAMagnet(const ScalingFFAMagnet &);
147

gsell's avatar
gsell committed
148 149 150 151 152 153 154 155 156
    /// Apply the algorithm to a separator.
    virtual void visitSeparator(const Separator &);

    /// Apply the algorithm to a septum.
    virtual void visitSeptum(const Septum &);

    /// Apply the algorithm to a solenoid.
    virtual void visitSolenoid(const Solenoid &);

157 158 159
    /// Apply the algorithm to a source.
    virtual void visitSource(const Source &);

gsell's avatar
gsell committed
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
    /// Apply the algorithm to a ParallelPlate.
    virtual void visitParallelPlate(const ParallelPlate &);

    /// Apply the algorithm to a CyclotronValley.
    virtual void visitCyclotronValley(const CyclotronValley &);

    /// Apply the algorithm to a charge stripper.
    virtual void visitStripper(const Stripper &);

    /// Apply the algorithm to a beam line.
    virtual void visitBeamline(const Beamline &);

    /// Apply the algorithm to a FlaggedElmPtr.
    virtual void visitFlaggedElmPtr(const FlaggedElmPtr &);


    /// Apply the algorithm to an align wrapper..
    virtual void visitAlignWrapper(const AlignWrapper &);

    /// Apply the algorithm to an corrector wrapper..
    virtual void visitCorrectorWrapper(const CorrectorWrapper &);

    /// Apply the algorithm to an cyclotron wrapper..
    virtual void visitCyclotronWrapper(const CyclotronWrapper &);

    /// Apply the algorithm to an multipole wrapper..
    virtual void visitMultipoleWrapper(const MultipoleWrapper &);

    /// Apply the algorithm to an RBend wrapper..
    virtual void visitRBendWrapper(const RBendWrapper &);

    /// Apply the algorithm to an SBend wrapper..
    virtual void visitSBendWrapper(const SBendWrapper &);


    /// Apply the algorithm to a generic integrator.
    virtual void visitIntegrator(const Integrator &);

    /// Apply the algorithm to an integrator capable of mapping.
    virtual void visitMapIntegrator(const MapIntegrator &);

    /// Apply the algorithm to an integrator capable of tracking.
    virtual void visitTrackIntegrator(const TrackIntegrator &);

protected:

    // The top level beamline.
    const Beamline &itsLine;

    // The direction flags and corresponding factors.
    bool back_beam;   // true, if beam runs from right (s=C) to left (s=0).
    bool back_track;  // true, if tracking opposite to the beam direction.
    bool back_path;   // true, if tracking from right (s=C) to left (s=0).
    // back_path = back_beam && ! back_track || back_track && ! back_beam.

    double flip_B;    // set to -1.0 to flip B fields, when back_beam is true.
    double flip_s;    // set to -1.0 to flip direction of s,
    // when back_path is true.

private:

    // Not implemented.
    DefaultVisitor();
    DefaultVisitor(const DefaultVisitor &);
    void operator=(const DefaultVisitor &);

    // Default do-nothing routine.
    virtual void applyDefault(const ElementBase &);

    // The element order flag. Initially set to back_path.
    // This flag is reversed locally for reflected beam lines.
    bool local_flip;
};

234
#endif // CLASSIC_DefaultVisitor_HH