OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Factory.h
Go to the documentation of this file.
1 #ifndef CLASSIC_Factory_HH
2 #define CLASSIC_Factory_HH
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: Factory.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.1.1.1 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 //
12 // Class: Factory
13 //
14 // ------------------------------------------------------------------------
15 // Class category: Construction
16 // ------------------------------------------------------------------------
17 //
18 // $Date: 2000/03/27 09:32:35 $
19 // $Author: fci $
20 //
21 // ------------------------------------------------------------------------
22 
23 #include <string>
24 
25 class ElementBase;
26 class AttributeSet;
27 
28 
29 // Class Factory
30 // ------------------------------------------------------------------------
32 
33 class Factory {
34 
35 public:
36 
37  Factory();
38  virtual ~Factory();
39 
41  // The element [b]newElement[/b] is linked to the repository.
42  // If an element with the same name exists already, replacement is
43  // rejected, and [b]newElement[/b] is deleted.
44  virtual bool define(ElementBase *newElement) = 0;
45 
47  // If there is no element with the given [b]name[/b],
48  // the request is ignored.
49  virtual void erase(const std::string &name) = 0;
50 
52  // If an element with the name [b]name[/b] exists,
53  // return a pointer to this element, otherwise return NULL.
54  virtual ElementBase *find(const std::string &name) const = 0;
55 
57  // Create a new element with the type [b]type[/b], the name [b]name[/b]
58  // and the attributes in [b]set[/b]. If an element with the name
59  // [b]name[/b] already exists, it is replaced.
60  virtual ElementBase *makeElement(const std::string &type, const std::string &name,
61  const AttributeSet &set) = 0;
62 
64  // The element [b]newElement[/b] is linked to the repository.
65  // If an element with the same name exists already, it is replaced.
66  virtual bool storeElement(ElementBase *newElement) = 0;
67 };
68 
69 #endif // CLASSIC_Factory_HH
Interface for basic beam line object.
Definition: ElementBase.h:128
virtual bool storeElement(ElementBase *newElement)=0
Define a new element.
Map of std::string versus double value.
Definition: AttributeSet.h:41
virtual ElementBase * find(const std::string &name) const =0
Find element by name.
virtual bool define(ElementBase *newElement)=0
Define a new element.
Factory()
Definition: Factory.cpp:27
virtual void erase(const std::string &name)=0
Erase element by name.
const std::string name
virtual ElementBase * makeElement(const std::string &type, const std::string &name, const AttributeSet &set)=0
Make new element.
virtual ~Factory()
Definition: Factory.cpp:31
Abstract interface for an element factory.
Definition: Factory.h:33