OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
EditCmd.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: EditCmd.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: EditCmd
10 // The class for the OPAL sequence editor SEQEDIT command.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2000/03/27 09:33:38 $
15 // $Author: Andreas Adelmann $
16 //
17 // ------------------------------------------------------------------------
18 
19 #include "Editor/EditCmd.h"
21 #include "Attributes/Attributes.h"
22 #include "Editor/Edit.h"
24 
25 
26 // Class EditCmd
27 // ------------------------------------------------------------------------
28 
30  Action(1, "SEQEDIT",
31  "The \"SEQEDIT\" command specifies a sequence for editing.") {
33  ("SEQUENCE", "Name of sequence to be edited");
34 
44 }
45 
46 
47 EditCmd::EditCmd(const std::string &name, EditCmd *parent):
48  Action(name, parent)
49 {}
50 
51 
53 {}
54 
55 
56 EditCmd *EditCmd::clone(const std::string &name) {
57  return new EditCmd(name, this);
58 }
59 
60 
62  // The parser strategy for sequence edit mode.
63  std::string seqName = Attributes::getString(itsAttr[0]);
64 
65  if(seqName == "") {
66  throw OpalException("EditCmd::execute()",
67  "Sequence name is required for \"SEQEDIT\".");
68  } else {
69  // find sequence definition
70  Object *object = OpalData::getInstance()->find(seqName);
71  Sequence *seq = dynamic_cast<Sequence *>(object);
72 
73  if(seq == 0) {
74  throw OpalException("EditCmd::execute()",
75  "Sequence \"" + seqName + "\" not found.");
76  } else {
77  // Execute edit block.
78  Edit::block = new Edit(seq);
80 
81  // Clean up.
82  delete Edit::block;
83  Edit::block = 0;
84  }
85  }
86 }
virtual ~EditCmd()
Definition: EditCmd.cpp:52
virtual void execute()
Execute the command.
Definition: EditCmd.cpp:61
The base class for all OPAL actions.
Definition: Action.h:30
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
static void addAttributeOwner(const std::string &owner, const OwnerType &type, const std::string &name)
static OpalData * getInstance()
Definition: OpalData.cpp:209
The sequence editor SEQEDIT command.
Definition: EditCmd.h:28
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
Definition: Object.cpp:194
The SEQUENCE definition.
Definition: Sequence.h:38
static Edit * block
Pointer to the edit data.
Definition: Edit.h:134
virtual void run() const
Read current stream.
Definition: OpalParser.cpp:601
This class contains all data for the sequence editor.
Definition: Edit.h:38
Object * find(const std::string &name)
Find entry.
Definition: OpalData.cpp:618
The base class for all OPAL objects.
Definition: Object.h:48
EditCmd()
Exemplar constructor.
Definition: EditCmd.cpp:29
const std::string name
EditParser parser
The parser used during a sequence edit.
Definition: Edit.h:131
virtual EditCmd * clone(const std::string &name)
Make clone.
Definition: EditCmd.cpp:56
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
Definition: Attributes.cpp:296
std::string getString(const Attribute &attr)
Get string value.
Definition: Attributes.cpp:307