OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
OpalElement.h
Go to the documentation of this file.
1 #ifndef OPAL_OpalElement_HH
2 #define OPAL_OpalElement_HH
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: OpalElement.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.2 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 //
12 // Class: OpalElement
13 //
14 // ------------------------------------------------------------------------
15 //
16 // $Date: 2001/08/13 15:32:23 $
17 // $Author: jowett $
18 //
19 // ------------------------------------------------------------------------
20 
22 #include "Elements/AttCell.h"
24 #include <map>
25 
26 class Statement;
27 
28 
29 // Class OpalElement
30 // ------------------------------------------------------------------------
32 //
33 // It defines a registry for attribute cells, used in the ATTLIST command
34 // only. The exemplar constructors for all OPAL element commands store all
35 // defined attribute names in this registry. The ATTLIST command can walk
36 // through a beam line or sequence, and call the fillRegisteredAttributes()
37 // method for each element. This method will fill in the values for all
38 // attributes which exist for this element, and the ATTLIST command can
39 // look them up with findRegisteredAttribute() to build up a print line.
40 
41 class OpalElement: public Element {
42 
43 public:
44 
46  enum {
47  TYPE, // The design type.
48  APERT, // The aperture data.
49  LENGTH, // The element length.
50  ELEMEDGE, // The position of the element (in path length)
51  WAKEF, // The wake function to be used
52  PARTICLEMATTERINTERACTION, // The particle mater interaction handler to be used
53  ORIGIN, // The location of the element in floor coordinates
54  ORIENTATION, // The orientation of the element (Tait Bryan angles)
55  X, // The x-coordinate of the location of the element in floor coordinates
56  Y, // The y-coordinate of the location of the element in floor coordinates
57  Z, // The z-coordinate of the location of the element in floor coordinates
58  THETA, // The rotation about the y-axis
59  PHI, // The rotation about the x-axis
60  PSI, // The rotation about the z-axis
61  DX, // Misalignment in x (local coordinate system)
62  DY, // Misalignment in y (local coordinate system)
63  DZ, // Misalignment in z (local coordinate system)
64  DTHETA, // The rotation around y axis in rad.
65  DPHI, // The rotation around x axis in rad.
66  DPSI, // The rotation around s axis in rad.
68  };
69 
71  enum ValueFlag {
72  ACTUAL_FLAG, // Actual field values (design + error).
73  IDEAL_FLAG, // Ideal field values (design only).
74  ERROR_FLAG // Field errors.
75  };
76 
77  virtual ~OpalElement();
78 
80  virtual void fillRegisteredAttributes(const ElementBase &, ValueFlag);
81 
83  // Return a pointer to the AttCell for a named attribute.
84  static AttCell *findRegisteredAttribute(const std::string &name);
85 
86 
88  virtual double getLength() const;
89 
91  const std::string getTypeName() const;
92 
93  //return the element aperture vector
94  std::pair<ElementBase::ApertureType, std::vector<double> > getApert() const;
95 
96 
98  const std::string getWakeF() const;
99 
100  const std::string getParticleMatterInteraction() const;
101 
102  const std::string getWMaterial() const;
103 
104  const std::string getWakeGeom() const;
105 
106  std::vector<double> getWakeParam() const;
107 
108  const std::string getWakeConductivity() const;
109 
111  // This special version for elements handles unknown attributes by
112  // appending them to the attribute list.
113  virtual void parse(Statement &);
114 
116  // This special version handles special printing in OPAL-8 format.
117  virtual void print(std::ostream &) const;
118 
120  static void setRegisteredAttribute(const std::string &, double);
121 
123  static void setRegisteredAttribute(const std::string &, const std::string &);
124 
126  virtual void update();
127 
129  virtual void updateUnknown(ElementBase *);
130 
131 protected:
132 
134  OpalElement(int size, const char *name, const char *help);
135 
137  OpalElement(const std::string &name, OpalElement *parent);
138 
140  // This function is accessible to all multipole-like elements
141  // (RBend, SBend, Quadrupole, Sextupole, Octupole, Multipole).
142  static void printMultipoleStrength(std::ostream &os,
143  int order,
144  int &len,
145  const std::string &sName,
146  const std::string &tName,
147  const Attribute &length,
148  const Attribute &vNorm,
149  const Attribute &vSkew);
150 
152  static void printAttribute(std::ostream &os,
153  const std::string &name,
154  const std::string &image,
155  int &len);
156 
158  static void printAttribute(std::ostream &os,
159  const std::string &name,
160  double value,
161  int &len);
162 
164  // A registered attribute can be listed by the ATTLIST command.
165  static AttCell *registerRealAttribute(const std::string &name);
166 
168  // A registered attribute can be listed by the ATTLIST command.
169  static AttCell *registerStringAttribute(const std::string &name);
170 
172  static std::map < std::string, OwnPtr<AttCell> > attributeRegistry;
173 
174  void registerOwnership() const;
175 private:
176 
177  // Not implemented.
178  OpalElement();
179  void operator=(const OpalElement &);
180 
181  // The original size of the attribute list.
182  int itsSize;
183 };
184 
185 #endif // OPAL_OpalElement_HH
const std::string getWakeConductivity() const
const std::string getTypeName() const
Return the element&#39;s type name.
static AttCell * registerStringAttribute(const std::string &name)
Register a ``string&#39;&#39; element attribute.
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
The abstract base class for attribute cells.
Definition: AttCell.h:30
virtual double getLength() const
Return element length.
const std::string getWakeGeom() const
const std::string getWMaterial() const
static void setRegisteredAttribute(const std::string &, double)
Store a registered real attribute.
std::pair< ElementBase::ApertureType, std::vector< double > > getApert() const
virtual void parse(Statement &)
Parse the element.
static std::map< std::string, OwnPtr< AttCell > > attributeRegistry
The registry for named attributes.
Definition: OpalElement.h:172
The base class for all OPAL elements.
Definition: Element.h:46
A representation of an Object attribute.
Definition: Attribute.h:55
const std::string getWakeF() const
Return the element&#39;s type name.
Interface for statements.
Definition: Statement.h:38
void operator=(const OpalElement &)
Base class for all beam line elements.
Definition: OpalElement.h:41
const std::string getParticleMatterInteraction() const
static void printAttribute(std::ostream &os, const std::string &name, const std::string &image, int &len)
Print an attribute with a OPAL-8 name (as an expression).
void registerOwnership() const
virtual void update()
Update the embedded CLASSIC element.
static void printMultipoleStrength(std::ostream &os, int order, int &len, const std::string &sName, const std::string &tName, const Attribute &length, const Attribute &vNorm, const Attribute &vSkew)
Print multipole components in OPAL-8 format.
virtual void updateUnknown(ElementBase *)
Transmit the ``unknown&#39;&#39; (not known to OPAL) attributes to CLASSIC.
const std::string name
std::vector< double > getWakeParam() const
static AttCell * findRegisteredAttribute(const std::string &name)
Find a registered attribute.
virtual ~OpalElement()
static AttCell * registerRealAttribute(const std::string &name)
Register a ``real&#39;&#39; element attribute.
virtual void print(std::ostream &) const
Print the object.