OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
OSEdAddOperationCmd Class Reference

#include <OSEdAddOperationCmd.hh>

Inheritance diagram for OSEdAddOperationCmd:
Inheritance graph
Collaboration diagram for OSEdAddOperationCmd:
Collaboration graph

Public Member Functions

 OSEdAddOperationCmd ()
 
virtual ~OSEdAddOperationCmd ()
 
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

 OSEdAddOperationCmd (const OSEdAddOperationCmd &)
 Copying not allowed.
 
OSEdAddOperationCmd operator= (OSEdAddOperationCmd &)
 Assignment not allowed.
 

Detailed Description

Command for adding new operation to operation set.

Definition at line 43 of file OSEdAddOperationCmd.hh.

Constructor & Destructor Documentation

◆ OSEdAddOperationCmd() [1/2]

OSEdAddOperationCmd::OSEdAddOperationCmd ( )

Constructor.

Definition at line 57 of file OSEdAddOperationCmd.cc.

57 :
59}
static const std::string CMD_NAME_ADD_OPERATION
Add operation command name.

Referenced by create().

◆ ~OSEdAddOperationCmd()

OSEdAddOperationCmd::~OSEdAddOperationCmd ( )
virtual

Destructor.

Definition at line 64 of file OSEdAddOperationCmd.cc.

64 {
65}

◆ OSEdAddOperationCmd() [2/2]

OSEdAddOperationCmd::OSEdAddOperationCmd ( const OSEdAddOperationCmd )
private

Copying not allowed.

Member Function Documentation

◆ create()

GUICommand * OSEdAddOperationCmd::create ( ) const
virtual

Creates a new command.

Returns
New command.

Implements GUICommand.

Definition at line 83 of file OSEdAddOperationCmd.cc.

83 {
84 return new OSEdAddOperationCmd();
85}

References OSEdAddOperationCmd().

Here is the call graph for this function:

◆ Do()

bool OSEdAddOperationCmd::Do ( )
virtual

Executes the command.

Implements GUICommand.

Definition at line 91 of file OSEdAddOperationCmd.cc.

91 {
92
93 OSEdMainFrame* mainFrame = wxGetApp().mainFrame();
94 OSEdTreeView* treeView = mainFrame->treeView();
95 string modName = treeView->selectedModule();
96
97 wxTreeItemId modId = treeView->selectedModuleId();
98 string pathName = treeView->pathOfModule(modId);
100 OperationModule& module = OperationContainer::module(pathName, modName);
101
103
104 OperationPropertyDialog dialog(parentWindow(), NULL, module, pathName);
105
106 if (dialog.ShowModal() == wxID_OK) {
107 Operation* op = dialog.operation();
108
109 OperationSerializer& serializer =
111 serializer.setDestinationFile(module.propertiesModule());
112 ObjectState* root = new ObjectState("");
113
114 for (int k = 0; k < index.operationCount(module); k++) {
115
116 string opName = index.operationName(k, module);
118 pathName, modName, opName);
119
120 root->addChild(oper->saveState());
121 delete oper;
122 }
123
124 root->addChild(op->saveState());
125
126 try {
127 serializer.writeState(root);
128 delete root;
129 } catch (const SerializerException& s) {
130 wxString msg = WxConversion::toWxString(s.errorMessage());
131 ErrorDialog eDialog(parentWindow(), msg);
132 eDialog.ShowModal();
133 delete root;
134 delete op;
135 return false;
136 }
137
138 index.refreshModule(pathName, modName);
139 treeView->addItem(modId, op->name());
140 treeView->update();
141 }
142
143 return true;
144}
#define assert(condition)
std::string errorMessage() const
Definition Exception.cc:123
wxWindow * parentWindow() const
Definition GUICommand.cc:75
static NullOperationModule & instance()
OSEdTreeView * treeView() const
wxTreeItemId selectedModuleId()
std::string pathOfModule(wxTreeItemId id)
void addItem(wxTreeItemId parent, std::string item)
std::string selectedModule()
void addChild(ObjectState *child)
static OperationSerializer & operationSerializer()
static Operation * operation(const std::string &path, const std::string &module, const std::string &oper)
static OperationIndex & operationIndex()
std::string operationName(int i, const OperationModule &om)
int operationCount(const OperationModule &om)
void refreshModule(const std::string &path, const std::string &modName)
virtual void writeState(const ObjectState *state)
void setDestinationFile(const std::string &filename)
virtual TCEString name() const
Definition Operation.cc:93
virtual ObjectState * saveState() const
Definition Operation.cc:490
static wxString toWxString(const std::string &source)

References ObjectState::addChild(), OSEdTreeView::addItem(), assert, Exception::errorMessage(), NullOperationModule::instance(), Operation::name(), OperationPropertyDialog::operation(), OperationContainer::operation(), OperationIndex::operationCount(), OperationContainer::operationIndex(), OperationIndex::operationName(), OperationContainer::operationSerializer(), GUICommand::parentWindow(), OSEdTreeView::pathOfModule(), OperationIndex::refreshModule(), Operation::saveState(), OSEdTreeView::selectedModule(), OSEdTreeView::selectedModuleId(), OperationSerializer::setDestinationFile(), WxConversion::toWxString(), OSEdMainFrame::treeView(), OSEdTreeView::update(), and OperationSerializer::writeState().

Here is the call graph for this function:

◆ icon()

string OSEdAddOperationCmd::icon ( ) const
virtual

Returns the icon path.

Returns
Empty string (no icons used).

Implements GUICommand.

Definition at line 178 of file OSEdAddOperationCmd.cc.

178 {
179 return "";
180}

◆ id()

int OSEdAddOperationCmd::id ( ) const
virtual

Returns the id of the command.

Returns
The id of the command.

Implements GUICommand.

Definition at line 73 of file OSEdAddOperationCmd.cc.

73 {
75}
@ CMD_ADD_OPERATION
Add operation command id.

References OSEdConstants::CMD_ADD_OPERATION.

◆ isEnabled()

bool OSEdAddOperationCmd::isEnabled ( )
virtual

Returns true, if command is enabled.

Operation can be added, if path is writable.

Returns
True if command is enabled.

Implements GUICommand.

Definition at line 154 of file OSEdAddOperationCmd.cc.

154 {
155 OSEdTreeView* treeView = wxGetApp().mainFrame()->treeView();
156 string modName = treeView->selectedModule();
157 if (modName != "") {
158 wxTreeItemId modId = treeView->selectedModuleId();
159 string pathName = treeView->pathOfModule(modId);
160 string tempFile = pathName + FileSystem::DIRECTORY_SEPARATOR +
161 "temp12341";
162 if (FileSystem::createFile(tempFile)) {
164 return true;
165 } else {
166 return false;
167 }
168 }
169 return false;
170}
static bool createFile(const std::string &file)
static bool removeFileOrDirectory(const std::string &path)
static const std::string DIRECTORY_SEPARATOR

References FileSystem::createFile(), FileSystem::DIRECTORY_SEPARATOR, OSEdTreeView::pathOfModule(), FileSystem::removeFileOrDirectory(), OSEdTreeView::selectedModule(), and OSEdTreeView::selectedModuleId().

Here is the call graph for this function:

◆ operator=()

OSEdAddOperationCmd OSEdAddOperationCmd::operator= ( OSEdAddOperationCmd )
private

Assignment not allowed.


The documentation for this class was generated from the following files: