OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
Selector.h
Go to the documentation of this file.
1 //
2 // Class Selector
3 // Set selection flags for a given range in a beam line.
4 //
5 // Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
6 // All rights reserved
7 //
8 // This file is part of OPAL.
9 //
10 // OPAL is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17 //
18 #ifndef OPAL_Selector_HH
19 #define OPAL_Selector_HH
20 
21 #include "Tables/RangeSelector.h"
22 #include <string>
23 
24 class Element;
25 class RangeRep;
26 class RegularExpression;
27 
28 class Selector: public RangeSelector {
29 
30 public:
31 
33  // Attach visitor to [b]bl[/b]. Remember range [b]range[/b],
34  // class name [b]cName[/b], type name [b]tName[/b], and pattern
35  // string [b]pString[/b].
36  Selector(const Beamline &, const RangeRep &range, const std::string &cName,
37  const std::string &tName, const std::string &pString);
38 
39  virtual ~Selector();
40 
42  virtual void execute();
43 
45  int getCount() const;
46 
47 protected:
48 
50  virtual void handleElement(const FlaggedElmPtr &);
51 
52 private:
53 
54  // Not implemented.
56  Selector(const Selector &);
57  void operator=(const Selector &);
58 
59  // Class of "SELECT", or zero.
60  const Element *itsClass;
61 
62  // Type name of "SELECT".
63  const std::string itsType;
64 
65  // Pattern of "SELECT", or zero.
67 
68  // The count of selected elements.
69  int itsCount;
70 };
71 
72 #endif // OPAL_Selector_HH
Representation of a range within a beam line or sequence.
Definition: RangeRep.h:34
An abstract sequence of beam line components.
Definition: Beamline.h:34
A section of a beam line.
Definition: FlaggedElmPtr.h:36
void operator=(const Selector &)
virtual void handleElement(const FlaggedElmPtr &)
The operation to be done for elements.
Definition: Selector.cpp:59
int getCount() const
Return the count of selected elements.
Definition: Selector.cpp:86
Selector(const Selector &)
virtual ~Selector()
Definition: Selector.cpp:48
virtual void execute()
Execute the selection.
Definition: Selector.cpp:53
const std::string itsType
Definition: Selector.h:63
int itsCount
Definition: Selector.h:69
const Element * itsClass
Definition: Selector.h:60
const RegularExpression * itsPattern
Definition: Selector.h:66
A regular expression.