OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
AttWriter.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: AttWriter.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.4 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: AttWriter
10 // The worker class for OPAL ATTLIST commands.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2002/03/28 21:27:54 $
15 // $Author: jsberg $
16 //
17 // ------------------------------------------------------------------------
18 
19 #include "Tables/AttWriter.h"
20 
23 #include "AbsBeamline/Corrector.h"
24 #include "AbsBeamline/Drift.h"
26 #include "AbsBeamline/Multipole.h"
27 #include "AbsBeamline/Patch.h"
28 #include "AbsBeamline/RBend.h"
29 #include "AbsBeamline/RFCavity.h"
31 #include "AbsBeamline/SBend.h"
32 #include "AbsBeamline/Separator.h"
33 #include "AbsBeamline/Solenoid.h"
34 
39 #include "Beamlines/Beamline.h"
41 #include "Elements/AttCell.h"
42 #include "Elements/OpalElement.h"
43 #include "Physics/Physics.h"
44 #include "Utilities/Timer.h"
45 #include <fstream>
46 #include <vector>
47 
48 
49 // Class AttWriter
50 // ------------------------------------------------------------------------
51 
53  std::ostream &os,
55  const std::vector<AttCell *> &buffer):
56  DefaultVisitor(line, false, false),
57  itsStream(os),
58  itsBuffer(buffer),
59  itsValueFlag(flag)
60 {}
61 
62 
64 {}
65 
66 
68  ElementBase *base = fep.getElement()->removeWrappers();
69  const std::string &nam = base->getName();
70  if(dynamic_cast<Beamline *>(base)) {
72  } else if(fep.getSelectionFlag()) {
73  // Fill the line buffer.
74  if(nam[0] == '[') {
76  OpalElement::setRegisteredAttribute("KEYWORD", "DRIFT");
77  } else {
78  OpalElement *elem = dynamic_cast<OpalElement *>(OpalData::getInstance()->find(nam));
80  }
81 
82  // Write the current output line and clear it.
83  itsStream << ' ';
84  std::vector<AttCell *>::size_type n = itsBuffer.size();
85  std::vector<AttCell *>::size_type i;
86  for(i = 0; i < n; ++i) {
87  itsStream << ' ';
88  itsBuffer[i]->printValue(itsStream);
89  itsBuffer[i]->clearValue();
90  }
91  itsStream << '\n';
92  }
93 }
Interface for basic beam line object.
Definition: ElementBase.h:128
virtual void fillRegisteredAttributes(const ElementBase &, ValueFlag)
Fill in all registered attributes.
ValueFlag
Switch for value desired on ATTLIST command.
Definition: OpalElement.h:71
virtual ElementBase * removeWrappers()
Return the design element.
virtual void visitFlaggedElmPtr(const FlaggedElmPtr &)
Apply the algorithm to a FlaggedElmPtr.
Definition: AttWriter.cpp:67
std::ostream & itsStream
Definition: AttWriter.h:77
virtual void visitFlaggedElmPtr(const FlaggedElmPtr &)
Apply the algorithm to a FlaggedElmPtr.
virtual const std::string & getName() const
Get element name.
Definition: ElementBase.cpp:95
static void setRegisteredAttribute(const std::string &, double)
Store a registered real attribute.
Default algorithms.
const std::vector< AttCell * > & itsBuffer
Definition: AttWriter.h:80
static OpalData * getInstance()
Definition: OpalData.cpp:209
virtual double getElementLength() const
Get design length.
Definition: ElementBase.h:511
Base class for all beam line elements.
Definition: OpalElement.h:41
bool getSelectionFlag() const
Get selection flag.
An abstract sequence of beam line components.
Definition: Beamline.h:37
virtual ~AttWriter()
Definition: AttWriter.cpp:63
Object * find(const std::string &name)
Find entry.
Definition: OpalData.cpp:618
ElementBase * getElement() const
Get the element pointer.
Definition: ElmPtr.h:58
OpalElement::ValueFlag itsValueFlag
Definition: AttWriter.h:83
A section of a beam line.
Definition: FlaggedElmPtr.h:36