OpenASIP  2.0
Public Member Functions | Private Member Functions | List of all members
OSEdRemoveOperationCmd Class Reference

#include <OSEdRemoveOperationCmd.hh>

Inheritance diagram for OSEdRemoveOperationCmd:
Inheritance graph
Collaboration diagram for OSEdRemoveOperationCmd:
Collaboration graph

Public Member Functions

 OSEdRemoveOperationCmd ()
 
virtual ~OSEdRemoveOperationCmd ()
 
virtual int id () const
 
virtual GUICommandcreate () const
 
virtual bool Do ()
 
virtual bool isEnabled ()
 
virtual std::string icon () const
 
- Public Member Functions inherited from GUICommand
 GUICommand (std::string name, wxWindow *parent)
 
virtual ~GUICommand ()
 
virtual bool isChecked () const
 
virtual std::string shortName () const
 
void setParentWindow (wxWindow *view)
 
wxWindow * parentWindow () const
 
std::string name () const
 

Private Member Functions

 OSEdRemoveOperationCmd (const OSEdRemoveOperationCmd &)
 Copying not allowed. More...
 
OSEdRemoveOperationCmdoperator= (const OSEdRemoveOperationCmd &)
 Assignment not allowed. More...
 

Detailed Description

Command for removing an operation.

Definition at line 43 of file OSEdRemoveOperationCmd.hh.

Constructor & Destructor Documentation

◆ OSEdRemoveOperationCmd() [1/2]

OSEdRemoveOperationCmd::OSEdRemoveOperationCmd ( )

Constructor.

Definition at line 58 of file OSEdRemoveOperationCmd.cc.

Referenced by create().

◆ ~OSEdRemoveOperationCmd()

OSEdRemoveOperationCmd::~OSEdRemoveOperationCmd ( )
virtual

Destructor.

Definition at line 65 of file OSEdRemoveOperationCmd.cc.

65  {
66 }

◆ OSEdRemoveOperationCmd() [2/2]

OSEdRemoveOperationCmd::OSEdRemoveOperationCmd ( const OSEdRemoveOperationCmd )
private

Copying not allowed.

Member Function Documentation

◆ create()

GUICommand * OSEdRemoveOperationCmd::create ( ) const
virtual

Creates a new command.

Returns
New command.

Implements GUICommand.

Definition at line 84 of file OSEdRemoveOperationCmd.cc.

84  {
85  return new OSEdRemoveOperationCmd();
86 }

References OSEdRemoveOperationCmd().

Here is the call graph for this function:

◆ Do()

bool OSEdRemoveOperationCmd::Do ( )
virtual

Executes the command.

Returns
True if execution is successful.

Implements GUICommand.

Definition at line 94 of file OSEdRemoveOperationCmd.cc.

94  {
95 
97  OSEdTreeView* treeView = wxGetApp().mainFrame()->treeView();
98  Operation* op = treeView->selectedOperation();
99  wxTreeItemId opId = treeView->selectedOperationId();
100  string modName = treeView->moduleOfOperation(opId);
101  wxTreeItemId modId = treeView->moduleIdOfOperation(opId);
102  string pathName = treeView->pathOfModule(modId);
103 
104  OperationModule& module = OperationContainer::module(pathName, modName);
105 
107  fmt % op->name();
109 
110  if (dialog.ShowModal() == wxID_YES) {
111  OperationSerializer& serializer =
113 
114  serializer.setSourceFile(module.propertiesModule());
115  ObjectState* root = NULL;
116  try {
117  root = serializer.readState();
118  for (int i = 0; i < root->childCount(); i++) {
119  ObjectState* child = root->child(i);
120  if (child->stringAttribute("name") == op->name()) {
121  delete child;
122  break;
123  }
124  }
125  serializer.setDestinationFile(module.propertiesModule());
126  serializer.writeState(root);
127  delete root;
128  } catch (const Exception& e) {
129  fmt = texts.text(
131 
132  fmt % op->name();
133  ErrorDialog error(
134  parentWindow(), WxConversion::toWxString(fmt.str()));
135  error.ShowModal();
136  delete root;
137  delete op;
138  return false;
139  }
140 
142  index.refreshModule(pathName, modName);
143  treeView->removeItem(opId);
144  treeView->infoView()->operationView(pathName, modName);
145  }
146  delete op;
147  return true;
148 }

References ObjectState::child(), ObjectState::childCount(), OSEdTreeView::infoView(), OSEdTextGenerator::instance(), OperationContainer::module(), OSEdTreeView::moduleIdOfOperation(), OSEdTreeView::moduleOfOperation(), Operation::name(), OperationContainer::operationIndex(), OperationContainer::operationSerializer(), OSEdInfoView::operationView(), GUICommand::parentWindow(), OSEdTreeView::pathOfModule(), OperationModule::propertiesModule(), OperationSerializer::readState(), OperationIndex::refreshModule(), OSEdTreeView::removeItem(), OSEdTreeView::selectedOperation(), OSEdTreeView::selectedOperationId(), OperationSerializer::setDestinationFile(), OperationSerializer::setSourceFile(), ObjectState::stringAttribute(), Texts::TextGenerator::text(), WxConversion::toWxString(), OSEdTextGenerator::TXT_ERROR_CAN_NOT_REMOVE_OPERATION, OSEdTextGenerator::TXT_QUESTION_REMOVE_OPERATION, and OperationSerializer::writeState().

Here is the call graph for this function:

◆ icon()

string OSEdRemoveOperationCmd::icon ( ) const
virtual

Returns the icon of the command.

Returns
Empty string (icons not used).

Implements GUICommand.

Definition at line 180 of file OSEdRemoveOperationCmd.cc.

180  {
181  return "";
182 }

◆ id()

int OSEdRemoveOperationCmd::id ( ) const
virtual

Returns the id of the command.

Returns
The id of the command.

Implements GUICommand.

Definition at line 74 of file OSEdRemoveOperationCmd.cc.

74  {
76 }

References OSEdConstants::CMD_REMOVE_OPERATION.

◆ isEnabled()

bool OSEdRemoveOperationCmd::isEnabled ( )
virtual

Returns true if command is enabled, otherwise false.

Command is enabled when the path of the operation is writable.

Returns
True if command is enabled, otherwise false.

Implements GUICommand.

Definition at line 158 of file OSEdRemoveOperationCmd.cc.

158  {
159  OSEdTreeView* treeView = wxGetApp().mainFrame()->treeView();
160  if (treeView->isOperationSelected()) {
161  wxTreeItemId opId = treeView->selectedOperationId();
162  wxTreeItemId modId = treeView->moduleIdOfOperation(opId);
163  string path = treeView->pathOfModule(modId);
164  if (FileSystem::fileIsWritable(path)) {
165  return true;
166  } else {
167  return false;
168  }
169  } else {
170  return false;
171  }
172 }

References FileSystem::fileIsWritable(), OSEdTreeView::isOperationSelected(), OSEdTreeView::moduleIdOfOperation(), OSEdTreeView::pathOfModule(), and OSEdTreeView::selectedOperationId().

Here is the call graph for this function:

◆ operator=()

OSEdRemoveOperationCmd& OSEdRemoveOperationCmd::operator= ( const OSEdRemoveOperationCmd )
private

Assignment not allowed.


The documentation for this class was generated from the following files:
OSEdInfoView::operationView
void operationView(const std::string &path, const std::string &mod)
Definition: OSEdInfoView.cc:161
OperationIndex::refreshModule
void refreshModule(const std::string &path, const std::string &modName)
Definition: OperationIndex.cc:272
OSEdTextGenerator::TXT_QUESTION_REMOVE_OPERATION
@ TXT_QUESTION_REMOVE_OPERATION
Remove operation question.
Definition: OSEdTextGenerator.hh:211
WxConversion::toWxString
static wxString toWxString(const std::string &source)
OSEdTreeView::removeItem
void removeItem(wxTreeItemId id)
Definition: OSEdTreeView.cc:622
OSEdTreeView::pathOfModule
std::string pathOfModule(wxTreeItemId id)
Definition: OSEdTreeView.cc:431
ObjectState::stringAttribute
std::string stringAttribute(const std::string &name) const
Definition: ObjectState.cc:249
OSEdRemoveOperationCmd::OSEdRemoveOperationCmd
OSEdRemoveOperationCmd()
Definition: OSEdRemoveOperationCmd.cc:58
OperationSerializer::writeState
virtual void writeState(const ObjectState *state)
Definition: OperationSerializer.cc:96
OperationContainer::operationSerializer
static OperationSerializer & operationSerializer()
Definition: OperationContainer.cc:111
OSEdTreeView::moduleIdOfOperation
wxTreeItemId moduleIdOfOperation(wxTreeItemId id)
Definition: OSEdTreeView.cc:420
OperationSerializer::setDestinationFile
void setDestinationFile(const std::string &filename)
Definition: OperationSerializer.cc:546
OperationContainer::module
static OperationModule & module(const std::string &path, const std::string &mod)
Definition: OperationContainer.cc:148
OSEdConstants::CMD_REMOVE_OPERATION
@ CMD_REMOVE_OPERATION
Remove operation command id.
Definition: OSEdConstants.hh:96
OSEdTextGenerator::TXT_ERROR_CAN_NOT_REMOVE_OPERATION
@ TXT_ERROR_CAN_NOT_REMOVE_OPERATION
Error when operation can not be removed.
Definition: OSEdTextGenerator.hh:148
ObjectState
Definition: ObjectState.hh:59
OSEdTreeView::infoView
OSEdInfoView * infoView() const
Definition: OSEdTreeView.cc:662
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
Operation::name
virtual TCEString name() const
Definition: Operation.cc:93
OperationModule::propertiesModule
virtual std::string propertiesModule() const
Definition: OperationModule.cc:121
ErrorDialog
Definition: ErrorDialog.hh:42
FileSystem::fileIsWritable
static bool fileIsWritable(const std::string fileName)
OSEdTreeView
Definition: OSEdTreeView.hh:54
OperationSerializer::readState
virtual ObjectState * readState()
Definition: OperationSerializer.cc:118
OSEdTreeView::moduleOfOperation
std::string moduleOfOperation(wxTreeItemId id)
Definition: OSEdTreeView.cc:407
OSEdTreeView::isOperationSelected
bool isOperationSelected() const
Definition: OSEdTreeView.cc:745
OperationSerializer
Definition: OperationSerializer.hh:49
ObjectState::child
ObjectState * child(int index) const
Definition: ObjectState.cc:471
OSEdTreeView::selectedOperation
Operation * selectedOperation()
Definition: OSEdTreeView.cc:328
ObjectState::childCount
int childCount() const
OperationSerializer::setSourceFile
void setSourceFile(const std::string &filename)
Definition: OperationSerializer.cc:536
Exception
Definition: Exception.hh:54
ConfirmDialog
Definition: ConfirmDialog.hh:41
Operation
Definition: Operation.hh:59
GUICommand::GUICommand
GUICommand(std::string name, wxWindow *parent)
Definition: GUICommand.cc:42
OperationModule
Definition: OperationModule.hh:46
OSEdConstants::CMD_NAME_REMOVE_OPERATION
static const std::string CMD_NAME_REMOVE_OPERATION
Remove operation command name.
Definition: OSEdConstants.hh:73
OperationIndex
Definition: OperationIndex.hh:58
OSEdTextGenerator::instance
static OSEdTextGenerator & instance()
Definition: OSEdTextGenerator.cc:214
OSEdTreeView::selectedOperationId
wxTreeItemId selectedOperationId()
Definition: OSEdTreeView.cc:379
OSEdTextGenerator
Definition: OSEdTextGenerator.hh:42
OperationContainer::operationIndex
static OperationIndex & operationIndex()
Definition: OperationContainer.cc:94
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75