OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
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 using namespace std;
23 
24 
25 // Class RangeRep
26 // ------------------------------------------------------------------------
27 
29  first(), last(), fullRange(true)
30 {}
31 
32 
34  first(rep.first), last(rep.last), fullRange(rep.fullRange)
35 {}
36 
37 
39  first(fst), last(lst), fullRange(false)
40 {}
41 
42 
44 {}
45 
46 
48  first = rep.first;
49  last = rep.last;
50  fullRange = rep.fullRange;
51  return *this;
52 }
53 
54 
56  if(! fullRange) {
57  first.initialize();
58  last.initialize();
59  status = false;
60  } else {
61  status = true;
62  }
63 }
64 
65 
66 bool RangeRep::isActive() const {
67  return status;
68 }
69 
70 
71 void RangeRep::enter(const FlaggedElmPtr &fep) const {
72  if(! fullRange) {
73  // Enter range, if we are in first element.
74  first.enter(fep);
75  if(first.isActive()) status = true;
76  last.enter(fep);
77  }
78 }
79 
80 
81 void RangeRep::leave(const FlaggedElmPtr &fep) const {
82  if(! fullRange) {
83  // Leave range, if we are in last element.
84  if(last.isActive()) status = false;
85  first.leave(fep);
86  last.leave(fep);
87  }
88 }
89 
90 
91 void RangeRep::print(std::ostream &os) const {
92  if(fullRange) {
93  os << "FULL";
94  } else {
95  first.print(os);
96  os << '/';
97  last.print(os);
98  }
99 
100  return;
101 }
void print(std::ostream &os) const
Print in input format.
Definition: PlaceRep.cpp:108
void print(std::ostream &os) const
Print in input format.
Definition: RangeRep.cpp:91
RangeRep()
Default constructor.
Definition: RangeRep.cpp:28
void leave(const FlaggedElmPtr &) const
Leave an element or line.
Definition: RangeRep.cpp:81
~RangeRep()
Definition: RangeRep.cpp:43
void enter(const FlaggedElmPtr &) const
Enter an element or line.
Definition: RangeRep.cpp:71
bool isActive() const
Return status.
Definition: PlaceRep.cpp:98
PlaceRep first
Definition: RangeRep.h:71
bool isActive() const
Test for active range.
Definition: RangeRep.cpp:66
Representation of a place within a beam line or sequence.
Definition: PlaceRep.h:41
void initialize()
Initialise data for search.
Definition: RangeRep.cpp:55
void enter(const FlaggedElmPtr &) const
Enter an element or line.
Definition: PlaceRep.cpp:70
const RangeRep & operator=(const RangeRep &)
Definition: RangeRep.cpp:47
void initialize()
Initialise data for search.
Definition: PlaceRep.cpp:64
Representation of a range within a beam line or sequence.
Definition: RangeRep.h:34
void leave(const FlaggedElmPtr &) const
Leave an element or line.
Definition: PlaceRep.cpp:84
bool fullRange
Definition: RangeRep.h:75
bool status
Definition: RangeRep.h:78
PlaceRep last
Definition: RangeRep.h:72
A section of a beam line.
Definition: FlaggedElmPtr.h:36