OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
EditCycle.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: EditCycle.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: EditCycle
10 // The class for the OPAL sequence editor CYCLE command.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2000/03/27 09:33:38 $
15 // $Author: Andreas Adelmann $
16 //
17 // ------------------------------------------------------------------------
18 
19 #include "Editor/EditCycle.h"
21 #include "Attributes/Attributes.h"
22 #include "Editor/Edit.h"
24 #include "Utilities/Options.h"
25 #include <iostream>
26 
27 
28 // Class EditCycle
29 // ------------------------------------------------------------------------
30 
31 
33  Editor(1, "CYCLE",
34  "The \"CYCLE\" sub-command changes the starting point "
35  "by cyclic interchange.") {
37  ("START", "The new start position for the sequence");
38 
40 }
41 
42 
43 EditCycle::EditCycle(const std::string &name, EditCycle *parent):
44  Editor(name, parent)
45 {}
46 
47 
49 {}
50 
51 
52 EditCycle *EditCycle::clone(const std::string &name) {
53  return new EditCycle(name, this);
54 }
55 
56 
58  const PlaceRep start = Attributes::getPlace(itsAttr[0]);
59 
60  if(Edit::block->cycle(start)) {
61  if(Options::info) {
62  std::cerr << "\nStart position changed to \"" << itsAttr[0] << "\".\n"
63  << std::endl;
64  }
65  } else {
66  throw OpalException("EditCycle::execute()", "Could not find place \"" +
67  itsAttr[0].getImage() + "\" in top-level sequence.");
68  }
69 }
The base class for all OPAL exceptions.
Definition: OpalException.h:28
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
Definition: Object.h:214
bool info
Info flag.
Definition: Options.cpp:8
The base class for all OPAL sequence editor commands.
Definition: Editor.h:31
PlaceRep getPlace(const Attribute &attr)
Get place value.
Definition: Attributes.cpp:143
Representation of a place within a beam line or sequence.
Definition: PlaceRep.h:41
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
Definition: Object.cpp:194
static Edit * block
Pointer to the edit data.
Definition: Edit.h:134
EditCycle()
Exemplar constructor.
Definition: EditCycle.cpp:32
The sequence editor CYCLE command.
Definition: EditCycle.h:28
Attribute makePlace(const std::string &name, const std::string &help)
Create a place attribute.
Definition: Attributes.cpp:137
virtual ~EditCycle()
Definition: EditCycle.cpp:48
const std::string name
virtual void execute()
Execute the command.
Definition: EditCycle.cpp:57
Inform & endl(Inform &inf)
Definition: Inform.cpp:42
virtual EditCycle * clone(const std::string &name)
Make clone.
Definition: EditCycle.cpp:52