OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
PlaceRep.h
Go to the documentation of this file.
1#ifndef OPAL_PlaceRep_HH
2#define OPAL_PlaceRep_HH
3
4// ------------------------------------------------------------------------
5// $RCSfile: PlaceRep.h,v $
6// ------------------------------------------------------------------------
7// $Revision: 1.2 $
8// ------------------------------------------------------------------------
9// Copyright: see Copyright.readme
10// ------------------------------------------------------------------------
11//
12// Class: PlaceRep
13//
14// ------------------------------------------------------------------------
15//
16// $Date: 2001/08/24 19:35:03 $
17// $Author: jsberg $
18//
19// ------------------------------------------------------------------------
20
21#include <string>
22#include <vector>
23#include <iosfwd>//tream>
24
25class FlaggedElmPtr;
26
27
28// Class PlaceRep
29// ------------------------------------------------------------------------
31// This representation holds data to keep track wether the place was
32// already passed when tracking through the line. The place may be
33// one of the following:
34// [ul]
35// [li]"#S", the start of the beam line.
36// [li]"#E", the end of the beam line.
37// [li]"SELECTED", all selected positions (flag set in FlaggedElmPtr).
38// [li]name[occurrence]::name[occurrence]..., denoting a specific place.
39// [/ul]
40
41class PlaceRep {
42
43public:
44
46 // Constructs undefined place.
47 PlaceRep();
48
50 // Used for places like "#S", "#E", "SELECTED".
51 explicit PlaceRep(const std::string &);
52
53 PlaceRep(const PlaceRep &);
54 ~PlaceRep();
55 const PlaceRep &operator=(const PlaceRep &);
56
58 void append(const std::string &, int occur);
59
61 // Sets the internal state to the beginning of the line.
62 void initialize();
63
65 // Sets the internal state to active, when the specified place is
66 // entered.
67 void enter(const FlaggedElmPtr &) const;
68
70 // Sets the internal state to inactive, when the specified place is
71 // left.
72 void leave(const FlaggedElmPtr &) const;
73
75 // Returns true, if we are at the specified place.
76 bool isActive() const;
77
79 // Returns true, if the place has the value "SELECTED".
80 bool isSelected() const;
81
83 void print(std::ostream &os) const;
84
85private:
86
87 typedef std::vector<std::pair<std::string, int> > Data;
89
90 // If true, this place refers to "SELECTED"
92
93 // If true, we are at this position.
94 mutable bool status;
95
96 // Ancillary variable, keeps track of levels seen.
97 mutable Data::size_type seen;
98};
99
100
101inline std::ostream &operator<<(std::ostream &os, const PlaceRep &data) {
102 data.print(os);
103 return os;
104}
105
106#endif // OPAL_PlaceRep_HH
std::ostream & operator<<(std::ostream &os, const PlaceRep &data)
Definition: PlaceRep.h:101
Representation of a place within a beam line or sequence.
Definition: PlaceRep.h:41
~PlaceRep()
Definition: PlaceRep.cpp:48
bool isActive() const
Return status.
Definition: PlaceRep.cpp:98
void print(std::ostream &os) const
Print in input format.
Definition: PlaceRep.cpp:108
std::vector< std::pair< std::string, int > > Data
Definition: PlaceRep.h:87
bool status
Definition: PlaceRep.h:94
Data data
Definition: PlaceRep.h:88
void initialize()
Initialise data for search.
Definition: PlaceRep.cpp:64
PlaceRep()
Default constructor.
Definition: PlaceRep.cpp:29
bool is_selected
Definition: PlaceRep.h:91
void enter(const FlaggedElmPtr &) const
Enter an element or line.
Definition: PlaceRep.cpp:70
Data::size_type seen
Definition: PlaceRep.h:97
bool isSelected() const
Return select flag.
Definition: PlaceRep.cpp:103
void append(const std::string &, int occur)
Add a name/occurrence pair.
Definition: PlaceRep.cpp:59
const PlaceRep & operator=(const PlaceRep &)
Definition: PlaceRep.cpp:52
void leave(const FlaggedElmPtr &) const
Leave an element or line.
Definition: PlaceRep.cpp:84
A section of a beam line.
Definition: FlaggedElmPtr.h:36