OpenASIP  2.0
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. More...
 
OSEdAddOperationCmd operator= (OSEdAddOperationCmd &)
 Assignment not allowed. More...
 

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.

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 
102  assert(&module != &NullOperationModule::instance());
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 }

References ObjectState::addChild(), OSEdTreeView::addItem(), assert, Exception::errorMessage(), NullOperationModule::instance(), OperationContainer::module(), Operation::name(), OperationPropertyDialog::operation(), OperationContainer::operation(), OperationIndex::operationCount(), OperationContainer::operationIndex(), OperationIndex::operationName(), OperationContainer::operationSerializer(), GUICommand::parentWindow(), OSEdTreeView::pathOfModule(), OperationModule::propertiesModule(), 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 }

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 }

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:
OperationPropertyDialog
Definition: OperationPropertyDialog.hh:51
OSEdTreeView::selectedModule
std::string selectedModule()
Definition: OSEdTreeView.cc:513
OperationIndex::refreshModule
void refreshModule(const std::string &path, const std::string &modName)
Definition: OperationIndex.cc:272
OSEdTreeView::selectedModuleId
wxTreeItemId selectedModuleId()
Definition: OSEdTreeView.cc:537
WxConversion::toWxString
static wxString toWxString(const std::string &source)
FileSystem::removeFileOrDirectory
static bool removeFileOrDirectory(const std::string &path)
Definition: FileSystem.cc:493
OSEdConstants::CMD_ADD_OPERATION
@ CMD_ADD_OPERATION
Add operation command id.
Definition: OSEdConstants.hh:93
OSEdTreeView::pathOfModule
std::string pathOfModule(wxTreeItemId id)
Definition: OSEdTreeView.cc:431
OperationSerializer::writeState
virtual void writeState(const ObjectState *state)
Definition: OperationSerializer.cc:96
OperationContainer::operationSerializer
static OperationSerializer & operationSerializer()
Definition: OperationContainer.cc:111
OperationSerializer::setDestinationFile
void setDestinationFile(const std::string &filename)
Definition: OperationSerializer.cc:546
OSEdTreeView::addItem
void addItem(wxTreeItemId parent, std::string item)
Definition: OSEdTreeView.cc:573
OperationContainer::module
static OperationModule & module(const std::string &path, const std::string &mod)
Definition: OperationContainer.cc:148
ObjectState
Definition: ObjectState.hh:59
OSEdConstants::CMD_NAME_ADD_OPERATION
static const std::string CMD_NAME_ADD_OPERATION
Add operation command name.
Definition: OSEdConstants.hh:57
Operation::name
virtual TCEString name() const
Definition: Operation.cc:93
OSEdMainFrame::treeView
OSEdTreeView * treeView() const
Definition: OSEdMainFrame.cc:241
assert
#define assert(condition)
Definition: Application.hh:86
OperationModule::propertiesModule
virtual std::string propertiesModule() const
Definition: OperationModule.cc:121
ErrorDialog
Definition: ErrorDialog.hh:42
OSEdTreeView
Definition: OSEdTreeView.hh:54
OperationSerializer
Definition: OperationSerializer.hh:49
ObjectState::addChild
void addChild(ObjectState *child)
Definition: ObjectState.cc:376
Operation::saveState
virtual ObjectState * saveState() const
Definition: Operation.cc:490
SerializerException
Definition: Exception.hh:675
FileSystem::createFile
static bool createFile(const std::string &file)
Definition: FileSystem.cc:468
Operation
Definition: Operation.hh:59
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
FileSystem::DIRECTORY_SEPARATOR
static const std::string DIRECTORY_SEPARATOR
Definition: FileSystem.hh:189
OSEdMainFrame
Definition: OSEdMainFrame.hh:49
GUICommand::GUICommand
GUICommand(std::string name, wxWindow *parent)
Definition: GUICommand.cc:42
OperationModule
Definition: OperationModule.hh:46
OSEdTreeView::update
void update()
Definition: OSEdTreeView.cc:670
OperationIndex
Definition: OperationIndex.hh:58
OperationContainer::operation
static Operation * operation(const std::string &path, const std::string &module, const std::string &oper)
Definition: OperationContainer.cc:173
OSEdAddOperationCmd::OSEdAddOperationCmd
OSEdAddOperationCmd()
Definition: OSEdAddOperationCmd.cc:57
NullOperationModule::instance
static NullOperationModule & instance()
OperationIndex::operationCount
int operationCount(const OperationModule &om)
Definition: OperationIndex.cc:363
OperationContainer::operationIndex
static OperationIndex & operationIndex()
Definition: OperationContainer.cc:94
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75
OperationIndex::operationName
std::string operationName(int i, const OperationModule &om)
Definition: OperationIndex.cc:337