OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Element.h
Go to the documentation of this file.
1 #ifndef OPAL_Element_HH
2 #define OPAL_Element_HH
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: Element.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.1.1.1 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 //
12 // Class: Element
13 //
14 // ------------------------------------------------------------------------
15 //
16 // $Date: 2000/03/27 09:33:34 $
17 // $Author: Andreas Adelmann $
18 //
19 // ------------------------------------------------------------------------
20 
21 #include "AbstractObjects/Object.h"
24 
25 
26 // Class Element
27 // ------------------------------------------------------------------------
29 // It implements the common behaviour of elements, it can also be used via
30 // dynamic casting to determine whether an object represents an element.
31 //
32 // Each Element object contains a pointer to a CLASSIC beam line element,
33 // known as the ``ideal'' element. To represent imperfections, this element
34 // is ``wrapped'' as required in a field wrapper and an AlignWrapper.
35 // This assembly represents the actual element as it occurs in a beam line.
36 //
37 // If sharable flag is set, all occurrences of the element are supposed to
38 // have the same imperfections. Thus the assembly is shared when it is used
39 // more than once in beam lines or sequences.
40 //
41 // If the sharable flag is not set, each occurrence of the element is supposed
42 // to have its own imperfections, but the same ideal representation. Thus
43 // the wrappers are cloned for each new use in a beam line or sequence,
44 // but they point to the same ideal element.
45 
46 class Element: public Object {
47 
48 public:
49 
51  // Used in the SEQUENCE command.
53  IS_ENTRY, // Reference point is at element entrance.
54  IS_CENTRE, // Reference point is at element centre
55  IS_EXIT // Reference point is at element exit.
56  };
57 
58  virtual ~Element();
59 
61  // Return true, if the replacement is also an Element.
62  virtual bool canReplaceBy(Object *object);
63 
65  // If an element with the name [b]name[/b] exists,
66  // return a pointer to that element.
67  // If no such element exists, throw [b]OpalException[/b].
68  static Element *find(const std::string &name);
69 
71  // Return the string "ELEMENT".
72  virtual const std::string getCategory() const;
73 
75  // If true, the object's execute() function should be traced.
76  // Always false for elements.
77  virtual bool shouldTrace() const;
78 
80  // If true, the data structure should be updated before calling execute().
81  // Always false for elements.
82  virtual bool shouldUpdate() const;
83 
84 
86  virtual double getLength() const = 0;
87 
89  virtual double getEntrance(ReferenceType) const;
90 
92  virtual double getExit(ReferenceType) const;
93 
95  // If true, all references to this name are to the same object.
96  virtual void setShared(bool);
97 
99  // Return a pointer to the embedded CLASSIC ElementBase
100  inline ElementBase *getElement() const;
101 
103  inline void setElement(ElementBase *);
104 
105 protected:
106 
108  Element(int size, const char *name, const char *help);
109 
111  Element(const std::string &name, Element *parent);
112 
113 private:
114 
115  // Not implemented.
116  Element();
117  Element(const Element &);
118  void operator=(const Element &);
119 
120  // The embedded CLASSIC element.
122 };
123 
124 
125 // Inline functions.
126 // ------------------------------------------------------------------------
127 
129  return &*itsClassicElement;
130 }
131 
132 
133 inline void Element::setElement(ElementBase *base) {
134  itsClassicElement = base;
135 }
136 
137 #endif // OPAL_Element_HH
Pointer< ElementBase > itsClassicElement
Definition: Element.h:121
virtual double getExit(ReferenceType) const
Return arc length from origin to exit (positive !).
Definition: Element.cpp:78
Interface for basic beam line object.
Definition: ElementBase.h:128
virtual void setShared(bool)
Set shared flag.
Definition: Element.cpp:93
virtual bool shouldUpdate() const
Update flag.
Definition: Element.cpp:58
virtual bool canReplaceBy(Object *object)
Test if replacement is allowed.
Definition: Element.cpp:32
The base class for all OPAL elements.
Definition: Element.h:46
ReferenceType
Reference for element positioning.
Definition: Element.h:52
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition: Element.h:133
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:128
static Element * find(const std::string &name)
Find named Element.
Definition: Element.cpp:37
virtual double getLength() const =0
Return element length.
virtual bool shouldTrace() const
Trace flag.
Definition: Element.cpp:53
The base class for all OPAL objects.
Definition: Object.h:48
const std::string name
void operator=(const Element &)
virtual const std::string getCategory() const
Return the object category as a string.
Definition: Element.cpp:48
virtual double getEntrance(ReferenceType) const
Return arc length from origin to entrance (negative !).
Definition: Element.cpp:63
virtual ~Element()
Definition: Element.cpp:28