OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
RangeRep.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: RangeRep.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.2 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: RangeRep
10 // A class used to represent a range specification.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2001/08/13 15:05:47 $
15 // $Author: jowett $
16 //
17 // ------------------------------------------------------------------------
18 
21 #include <iostream>
22 
23 
24 // Class RangeRep
25 // ------------------------------------------------------------------------
26 
28  first(), last(), fullRange(true)
29 {}
30 
31 
33  first(rep.first), last(rep.last), fullRange(rep.fullRange)
34 {}
35 
36 
38  first(fst), last(lst), fullRange(false)
39 {}
40 
41 
43 {}
44 
45 
47  first = rep.first;
48  last = rep.last;
49  fullRange = rep.fullRange;
50  return *this;
51 }
52 
53 
55  if(! fullRange) {
56  first.initialize();
57  last.initialize();
58  status = false;
59  } else {
60  status = true;
61  }
62 }
63 
64 
65 bool RangeRep::isActive() const {
66  return status;
67 }
68 
69 
70 void RangeRep::enter(const FlaggedElmPtr &fep) const {
71  if(! fullRange) {
72  // Enter range, if we are in first element.
73  first.enter(fep);
74  if(first.isActive()) status = true;
75  last.enter(fep);
76  }
77 }
78 
79 
80 void RangeRep::leave(const FlaggedElmPtr &fep) const {
81  if(! fullRange) {
82  // Leave range, if we are in last element.
83  if(last.isActive()) status = false;
84  first.leave(fep);
85  last.leave(fep);
86  }
87 }
88 
89 
90 void RangeRep::print(std::ostream &os) const {
91  if(fullRange) {
92  os << "FULL";
93  } else {
94  first.print(os);
95  os << '/';
96  last.print(os);
97  }
98 
99  return;
100 }
Representation of a place within a beam line or sequence.
Definition: PlaceRep.h:41
bool isActive() const
Return status.
Definition: PlaceRep.cpp:98
void print(std::ostream &os) const
Print in input format.
Definition: PlaceRep.cpp:108
void initialize()
Initialise data for search.
Definition: PlaceRep.cpp:64
void enter(const FlaggedElmPtr &) const
Enter an element or line.
Definition: PlaceRep.cpp:70
void leave(const FlaggedElmPtr &) const
Leave an element or line.
Definition: PlaceRep.cpp:84
Representation of a range within a beam line or sequence.
Definition: RangeRep.h:34
PlaceRep first
Definition: RangeRep.h:71
bool isActive() const
Test for active range.
Definition: RangeRep.cpp:65
const RangeRep & operator=(const RangeRep &)
Definition: RangeRep.cpp:46
void initialize()
Initialise data for search.
Definition: RangeRep.cpp:54
PlaceRep last
Definition: RangeRep.h:72
bool fullRange
Definition: RangeRep.h:75
~RangeRep()
Definition: RangeRep.cpp:42
void print(std::ostream &os) const
Print in input format.
Definition: RangeRep.cpp:90
void leave(const FlaggedElmPtr &) const
Leave an element or line.
Definition: RangeRep.cpp:80
bool status
Definition: RangeRep.h:78
RangeRep()
Default constructor.
Definition: RangeRep.cpp:27
void enter(const FlaggedElmPtr &) const
Enter an element or line.
Definition: RangeRep.cpp:70
A section of a beam line.
Definition: FlaggedElmPtr.h:36