OpenASIP 2.2
Loading...
Searching...
No Matches
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.
 
OSEdRemoveOperationCmdoperator= (const OSEdRemoveOperationCmd &)
 Assignment not allowed.
 

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.

58 :
60}
static const std::string CMD_NAME_REMOVE_OPERATION
Remove operation command name.

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(
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}
wxWindow * parentWindow() const
Definition GUICommand.cc:75
void operationView(const std::string &path, const std::string &mod)
static OSEdTextGenerator & instance()
@ TXT_QUESTION_REMOVE_OPERATION
Remove operation question.
@ TXT_ERROR_CAN_NOT_REMOVE_OPERATION
Error when operation can not be removed.
std::string pathOfModule(wxTreeItemId id)
wxTreeItemId selectedOperationId()
Operation * selectedOperation()
OSEdInfoView * infoView() const
void removeItem(wxTreeItemId id)
wxTreeItemId moduleIdOfOperation(wxTreeItemId id)
std::string moduleOfOperation(wxTreeItemId id)
ObjectState * child(int index) const
std::string stringAttribute(const std::string &name) const
int childCount() const
static OperationSerializer & operationSerializer()
static OperationIndex & operationIndex()
void refreshModule(const std::string &path, const std::string &modName)
void setSourceFile(const std::string &filename)
virtual void writeState(const ObjectState *state)
void setDestinationFile(const std::string &filename)
virtual ObjectState * readState()
virtual TCEString name() const
Definition Operation.cc:93
virtual boost::format text(int textId)
static wxString toWxString(const std::string &source)

References ObjectState::child(), ObjectState::childCount(), OSEdTreeView::infoView(), OSEdTextGenerator::instance(), OSEdTreeView::moduleIdOfOperation(), OSEdTreeView::moduleOfOperation(), Operation::name(), OperationContainer::operationIndex(), OperationContainer::operationSerializer(), OSEdInfoView::operationView(), GUICommand::parentWindow(), OSEdTreeView::pathOfModule(), 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}
@ CMD_REMOVE_OPERATION
Remove operation command id.

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}
static bool fileIsWritable(const std::string fileName)
bool isOperationSelected() const

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: