OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
ElementFactory.h
Go to the documentation of this file.
1 #ifndef CLASSIC_ElementFactory_HH
2 #define CLASSIC_ElementFactory_HH
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: ElementFactory.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.1.1.1 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 //
12 // Class: ElementFactory
13 //
14 // ------------------------------------------------------------------------
15 // Class category: Construction
16 // ------------------------------------------------------------------------
17 //
18 // $Date: 2000/03/27 09:32:35 $
19 // $Author: fci $
20 //
21 // ------------------------------------------------------------------------
22 
23 #include "Construction/Factory.h"
24 #include <map>
25 
26 
27 // Class ElementFactory
28 // ------------------------------------------------------------------------
30 // Defines the beamline element creation via the factory pattern.
31 // When the factory is constructed, empty elements are first created and
32 // stored.
33 // {p}
34 // With the makeElement() method, these elements can be cloned and then
35 // filled in with from an ElementImage. The factory also implements an
36 // element repository which can store beam lines.
37 
38 
39 class ElementFactory: public Factory {
40 
41 public:
42 
44  // Fills the repository with all standard element definitions.
46 
47  virtual ~ElementFactory();
48 
50  // The element [b]newElement[/b] is linked to the repository.
51  // If an element with the same name exists already, replacement is
52  // rejected, and [b]newElement[/b] is deleted.
53  virtual bool define(ElementBase *newElement);
54 
56  // If there is no element with the given [b]name[/b],
57  // the request is ignored.
58  virtual void erase(const std::string &name);
59 
61  // If an element with the name [b]name[/b] exists,
62  // return a pointer to this element, otherwise return NULL.
63  virtual ElementBase *find(const std::string &name) const;
64 
66  // Create a new element with the type [b]type[/b], the name [b]name[/b]
67  // and the attributes in [b]set[/b].
68  // If an element with the name [b]name[/b] already exists, it is replaced.
69  virtual ElementBase *makeElement(const std::string &type,
70  const std::string &name,
71  const AttributeSet &set);
72 
74  // The element [b]newElement[/b] is linked to the repository.
75  // If an element with the same name exists already, it is replaced.
76  virtual bool storeElement(ElementBase *newElement);
77 
78 private:
79 
80  // Not implemented.
82  void operator=(const ElementFactory &);
83 
84  // The beamline elements are stored in this map.
85  typedef std::map<std::string, ElementBase *, std::less<std::string> > MapType;
87 };
88 
89 #endif // CLASSIC_ElementFactory_HH
virtual ElementBase * find(const std::string &name) const
Find element by name.
ElementFactory()
Default constructor.
Interface for basic beam line object.
Definition: ElementBase.h:128
Map of std::string versus double value.
Definition: AttributeSet.h:41
virtual ElementBase * makeElement(const std::string &type, const std::string &name, const AttributeSet &set)
Make new element.
std::map< std::string, ElementBase *, std::less< std::string > > MapType
virtual bool define(ElementBase *newElement)
Define a new element.
void operator=(const ElementFactory &)
virtual bool storeElement(ElementBase *newElement)
Define a new element.
virtual ~ElementFactory()
const std::string name
Concrete factory class for CLASSIC elements.
virtual void erase(const std::string &name)
Erase element by name.
Abstract interface for an element factory.
Definition: Factory.h:33