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

#include <OSEdPropertiesCmd.hh>

Inheritance diagram for OSEdPropertiesCmd:
Inheritance graph
Collaboration diagram for OSEdPropertiesCmd:
Collaboration graph

Public Member Functions

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

 OSEdPropertiesCmd (const OSEdPropertiesCmd &)
 Copying not allowed. More...
 
OSEdPropertiesCmdoperator= (const OSEdPropertiesCmd &)
 Assignment not allowed. More...
 

Detailed Description

Executes the command when operation is modified.

Definition at line 43 of file OSEdPropertiesCmd.hh.

Constructor & Destructor Documentation

◆ OSEdPropertiesCmd() [1/2]

OSEdPropertiesCmd::OSEdPropertiesCmd ( )

Constructor.

Definition at line 62 of file OSEdPropertiesCmd.cc.

62  :
64 }

Referenced by create().

◆ ~OSEdPropertiesCmd()

OSEdPropertiesCmd::~OSEdPropertiesCmd ( )
virtual

Destructor.

Definition at line 69 of file OSEdPropertiesCmd.cc.

69  {
70 }

◆ OSEdPropertiesCmd() [2/2]

OSEdPropertiesCmd::OSEdPropertiesCmd ( const OSEdPropertiesCmd )
private

Copying not allowed.

Member Function Documentation

◆ create()

GUICommand * OSEdPropertiesCmd::create ( ) const
virtual

Creates a new command.

Returns
The created command.

Implements GUICommand.

Definition at line 88 of file OSEdPropertiesCmd.cc.

88  {
89  return new OSEdPropertiesCmd();
90 }

References OSEdPropertiesCmd().

Here is the call graph for this function:

◆ Do()

bool OSEdPropertiesCmd::Do ( )
virtual

Executes the command.

Returns
True if execution is successful, false otherwise.

Implements GUICommand.

Definition at line 98 of file OSEdPropertiesCmd.cc.

98  {
99 
101  OSEdMainFrame* mainFrame = wxGetApp().mainFrame();
102  OSEdTreeView* treeView = mainFrame->treeView();
103  Operation* op = treeView->selectedOperation();
104  string opName = op->name();
105  wxTreeItemId opId = treeView->selectedOperationId();
106  string modName = treeView->moduleOfOperation(opId);
107  wxTreeItemId modId = treeView->moduleIdOfOperation(opId);
108  string pathName = treeView->pathOfModule(modId);
109  OperationModule& module = OperationContainer::module(pathName, modName);
110 
111  assert(&module != &NullOperationModule::instance());
112 
116  error.ShowModal();
117  delete op;
118  return false;
119  } else {
120  OperationPropertyDialog dialog(parentWindow(), op, module, pathName);
121  ObjectState* orig = op->saveState();
122  if (dialog.ShowModal() == wxID_OK) {
123 
124  ObjectState* mod = op->saveState();
125  if (*mod != *orig) {
126  // write operation properties to file
127  OperationSerializer& serializer =
129  serializer.setSourceFile(module.propertiesModule());
130  ObjectState* root = NULL;
131  try {
132  root = serializer.readState();
133  for (int i = 0; i < root->childCount(); i++) {
134  ObjectState* child = root->child(i);
135  if (child->stringAttribute("name") == opName) {
136  root->replaceChild(child, op->saveState());
137  break;
138  }
139  }
140  serializer.setDestinationFile(module.propertiesModule());
141  serializer.writeState(root);
142  } catch (const Exception& s) {
143  format fmt =
145  ErrorDialog eDialog(
146  parentWindow(), WxConversion::toWxString(fmt.str()));
147  eDialog.ShowModal();
148  }
149  delete root;
150 
151  // update the tree.
152  if (opName != op->name()) {
154  index.refreshModule(pathName, modName);
155  treeView->changeText(opId, op->name());
156  }
157 
158  treeView->update();
159  }
160  delete mod;
161  }
162  delete orig;
163  delete op;
164  return true;
165  }
166 
167  assert(false);
168  return false;
169 }

References assert, OSEdTreeView::changeText(), ObjectState::child(), ObjectState::childCount(), FileSystem::fileIsWritable(), OSEdTextGenerator::instance(), NullOperationModule::instance(), OperationContainer::module(), OSEdTreeView::moduleIdOfOperation(), OSEdTreeView::moduleOfOperation(), Operation::name(), OperationContainer::operationIndex(), OperationContainer::operationSerializer(), GUICommand::parentWindow(), OSEdTreeView::pathOfModule(), OperationModule::propertiesModule(), OperationSerializer::readState(), OperationIndex::refreshModule(), ObjectState::replaceChild(), Operation::saveState(), OSEdTreeView::selectedOperation(), OSEdTreeView::selectedOperationId(), OperationSerializer::setDestinationFile(), OperationSerializer::setSourceFile(), ObjectState::stringAttribute(), Texts::TextGenerator::text(), WxConversion::toWxString(), OSEdMainFrame::treeView(), OSEdTextGenerator::TXT_ERROR_CAN_NOT_MODIFY, OSEdTreeView::update(), and OperationSerializer::writeState().

Here is the call graph for this function:

◆ icon()

string OSEdPropertiesCmd::icon ( ) const
virtual

Returns the icon path.

Returns
Empty string (icons not used).

Implements GUICommand.

Definition at line 194 of file OSEdPropertiesCmd.cc.

194  {
195  return "";
196 }

◆ id()

int OSEdPropertiesCmd::id ( ) const
virtual

Returns the id of the command.

Returns
The id of the command.

Implements GUICommand.

Definition at line 78 of file OSEdPropertiesCmd.cc.

78  {
80 }

References OSEdConstants::CMD_PROPERTIES.

◆ isEnabled()

bool OSEdPropertiesCmd::isEnabled ( )
virtual

Returns true, if command is enabled.

Returns
True, if command is enabled.

Implements GUICommand.

Definition at line 177 of file OSEdPropertiesCmd.cc.

177  {
178  OSEdTreeView* treeView = wxGetApp().mainFrame()->treeView();
179  Operation* op = treeView->selectedOperation();
180  if (op != NULL) {
181  delete op;
182  return true;
183  } else {
184  return false;
185  }
186 }

References OSEdTreeView::selectedOperation().

Here is the call graph for this function:

◆ operator=()

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

Assignment not allowed.


The documentation for this class was generated from the following files:
OperationPropertyDialog
Definition: OperationPropertyDialog.hh:51
OperationIndex::refreshModule
void refreshModule(const std::string &path, const std::string &modName)
Definition: OperationIndex.cc:272
WxConversion::toWxString
static wxString toWxString(const std::string &source)
OSEdTreeView::pathOfModule
std::string pathOfModule(wxTreeItemId id)
Definition: OSEdTreeView.cc:431
OSEdPropertiesCmd::OSEdPropertiesCmd
OSEdPropertiesCmd()
Definition: OSEdPropertiesCmd.cc:62
ObjectState::stringAttribute
std::string stringAttribute(const std::string &name) const
Definition: ObjectState.cc:249
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
OSEdTextGenerator::TXT_ERROR_CAN_NOT_MODIFY
@ TXT_ERROR_CAN_NOT_MODIFY
Error when can not modify.
Definition: OSEdTextGenerator.hh:133
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
ObjectState
Definition: ObjectState.hh:59
OSEdConstants::CMD_PROPERTIES
@ CMD_PROPERTIES
Operation properties command id.
Definition: OSEdConstants.hh:94
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
Operation::name
virtual TCEString name() const
Definition: Operation.cc:93
OSEdMainFrame::treeView
OSEdTreeView * treeView() const
Definition: OSEdMainFrame.cc:241
ObjectState::replaceChild
void replaceChild(ObjectState *old, ObjectState *newChild)
Definition: ObjectState.cc:408
assert
#define assert(condition)
Definition: Application.hh:86
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::changeText
void changeText(wxTreeItemId id, const std::string &text)
Definition: OSEdTreeView.cc:592
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
Operation::saveState
virtual ObjectState * saveState() const
Definition: Operation.cc:490
OperationSerializer::setSourceFile
void setSourceFile(const std::string &filename)
Definition: OperationSerializer.cc:536
Exception
Definition: Exception.hh:54
Operation
Definition: Operation.hh:59
OSEdConstants::CMD_NAME_PROPERTIES
static const std::string CMD_NAME_PROPERTIES
Operation properties command name.
Definition: OSEdConstants.hh:53
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
OSEdTextGenerator::instance
static OSEdTextGenerator & instance()
Definition: OSEdTextGenerator.cc:214
OSEdTreeView::selectedOperationId
wxTreeItemId selectedOperationId()
Definition: OSEdTreeView.cc:379
OSEdTextGenerator
Definition: OSEdTextGenerator.hh:42
NullOperationModule::instance
static NullOperationModule & instance()
OperationContainer::operationIndex
static OperationIndex & operationIndex()
Definition: OperationContainer.cc:94
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75