OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
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 <iosfwd> //tream>
22#include <string>
23#include <vector>
24
25class FlaggedElmPtr;
26
27// Class PlaceRep
28// ------------------------------------------------------------------------
30// This representation holds data to keep track wether the place was
31// already passed when tracking through the line. The place may be
32// one of the following:
33// [ul]
34// [li]"#S", the start of the beam line.
35// [li]"#E", the end of the beam line.
36// [li]"SELECTED", all selected positions (flag set in FlaggedElmPtr).
37// [li]name[occurrence]::name[occurrence]..., denoting a specific place.
38// [/ul]
39
40class PlaceRep {
41public:
43 // Constructs undefined place.
44 PlaceRep();
45
47 // Used for places like "#S", "#E", "SELECTED".
48 explicit PlaceRep(const std::string&);
49
50 PlaceRep(const PlaceRep&);
51 ~PlaceRep();
52 const PlaceRep& operator=(const PlaceRep&);
53
55 void append(const std::string&, int occur);
56
58 // Sets the internal state to the beginning of the line.
59 void initialize();
60
62 // Sets the internal state to active, when the specified place is
63 // entered.
64 void enter(const FlaggedElmPtr&) const;
65
67 // Sets the internal state to inactive, when the specified place is
68 // left.
69 void leave(const FlaggedElmPtr&) const;
70
72 // Returns true, if we are at the specified place.
73 bool isActive() const;
74
76 // Returns true, if the place has the value "SELECTED".
77 bool isSelected() const;
78
80 void print(std::ostream& os) const;
81
82private:
83 typedef std::vector<std::pair<std::string, int> > Data;
85
86 // If true, this place refers to "SELECTED"
88
89 // If true, we are at this position.
90 mutable bool status;
91
92 // Ancillary variable, keeps track of levels seen.
93 mutable Data::size_type seen;
94};
95
96inline std::ostream& operator<<(std::ostream& os, const PlaceRep& data) {
97 data.print(os);
98 return os;
99}
100
101#endif // OPAL_PlaceRep_HH
std::ostream & operator<<(std::ostream &os, const PlaceRep &data)
Definition PlaceRep.h:96
A section of a beam line.
Representation of a place within a beam line or sequence.
Definition PlaceRep.h:40
bool isActive() const
Return status.
Definition PlaceRep.cpp:78
void print(std::ostream &os) const
Print in input format.
Definition PlaceRep.cpp:82
std::vector< std::pair< std::string, int > > Data
Definition PlaceRep.h:83
bool status
Definition PlaceRep.h:90
Data data
Definition PlaceRep.h:84
void initialize()
Initialise data for search.
Definition PlaceRep.cpp:51
PlaceRep()
Default constructor.
Definition PlaceRep.cpp:28
bool is_selected
Definition PlaceRep.h:87
void enter(const FlaggedElmPtr &) const
Enter an element or line.
Definition PlaceRep.cpp:56
Data::size_type seen
Definition PlaceRep.h:93
bool isSelected() const
Return select flag.
Definition PlaceRep.cpp:80
void append(const std::string &, int occur)
Add a name/occurrence pair.
Definition PlaceRep.cpp:47
const PlaceRep & operator=(const PlaceRep &)
Definition PlaceRep.cpp:41
void leave(const FlaggedElmPtr &) const
Leave an element or line.
Definition PlaceRep.cpp:67