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

#include <OSEdModifyBehaviorCmd.hh>

Inheritance diagram for OSEdModifyBehaviorCmd:
Inheritance graph
Collaboration diagram for OSEdModifyBehaviorCmd:
Collaboration graph

Public Member Functions

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

 OSEdModifyBehaviorCmd (const OSEdModifyBehaviorCmd &)
 Copying not allowed.
 
OSEdModifyBehaviorCmdoperator= (const OSEdModifyBehaviorCmd &)
 Assignment not allowed.
 

Detailed Description

Command for modifying operation behavior.

Definition at line 43 of file OSEdModifyBehaviorCmd.hh.

Constructor & Destructor Documentation

◆ OSEdModifyBehaviorCmd() [1/2]

OSEdModifyBehaviorCmd::OSEdModifyBehaviorCmd ( )

Constructor.

Definition at line 54 of file OSEdModifyBehaviorCmd.cc.

54 :
56}
static const std::string CMD_NAME_MODIFY_BEHAVIOR
Modify behavior command name.

Referenced by create().

◆ ~OSEdModifyBehaviorCmd()

OSEdModifyBehaviorCmd::~OSEdModifyBehaviorCmd ( )
virtual

Destructor.

Definition at line 61 of file OSEdModifyBehaviorCmd.cc.

61 {
62}

◆ OSEdModifyBehaviorCmd() [2/2]

OSEdModifyBehaviorCmd::OSEdModifyBehaviorCmd ( const OSEdModifyBehaviorCmd )
private

Copying not allowed.

Member Function Documentation

◆ create()

GUICommand * OSEdModifyBehaviorCmd::create ( ) const
virtual

Creates a new command.

Returns
A new command.

Implements GUICommand.

Definition at line 80 of file OSEdModifyBehaviorCmd.cc.

80 {
81 return new OSEdModifyBehaviorCmd();
82}

References OSEdModifyBehaviorCmd().

Here is the call graph for this function:

◆ Do()

bool OSEdModifyBehaviorCmd::Do ( )
virtual

Executes the command.

Returns
True if execution is successful.

Implements GUICommand.

Definition at line 90 of file OSEdModifyBehaviorCmd.cc.

90 {
91
93 OSEdOptions* options = wxGetApp().options();
94 string editor = options->editor();
95 if (editor == "") {
98 error.ShowModal();
99 return false;
100 } else if (!FileSystem::fileExists(editor)) {
101 format fmt = texts.text(OSEdTextGenerator::TXT_ERROR_OPEN);
102 fmt % editor;
104 error.ShowModal();
105 return false ;
106 } else {
107
108 OSEdTreeView* treeView = wxGetApp().mainFrame()->treeView();
109 wxTreeItemId opId = treeView->selectedOperationId();
110 string modName = treeView->moduleOfOperation(opId);
111 wxTreeItemId modId = treeView->moduleIdOfOperation(opId);
112 string pathName = treeView->pathOfModule(modId);
113
114 OperationModule& module = OperationContainer::module(pathName, modName);
115 string cmd = "";
116 if (module.hasBehaviorSource()) {
117 string code = module.behaviorSourceModule();
118 cmd = editor + " " + code;
119 } else {
120 // new behavior is added for the module
121 string code = module.propertiesModule();
122 size_t pos = code.find_last_of(".");
123 code.erase(pos);
124 code += ".cc";
125
126 // copy template file as new file
127 string dir = Environment::dataDirPath(
129
130 string templateFile = dir + FileSystem::DIRECTORY_SEPARATOR +
132
133 FileSystem::copy(templateFile, code);
134 cmd = editor + " " + code;
135 }
136 // we are using detached thread that will be automatically cleaned
137 CommandThread* thread = new CommandThread(cmd);
138 thread->Create();
139 thread->Run();
140 return true;
141 }
142
143 assert(false);
144 return false;
145}
#define assert(condition)
find Finds info of the inner loops in the false
static MachInfoCmdLineOptions options
Definition MachInfo.cc:46
static std::string dataDirPath(const std::string &prog)
static const std::string DIRECTORY_SEPARATOR
static void copy(const std::string &source, const std::string &target)
static bool fileExists(const std::string fileName)
wxWindow * parentWindow() const
Definition GUICommand.cc:75
static const wxString APPLICATION_NAME
The name of the application.
static const std::string BEHAVIOR_TEMPLATE_FILE_NAME
Name of the behavior template file name.
static OSEdTextGenerator & instance()
@ TXT_ERROR_OPEN
Error when opening fails.
@ TXT_ERROR_NO_EDITOR
Error when no editor is given.
std::string pathOfModule(wxTreeItemId id)
wxTreeItemId selectedOperationId()
wxTreeItemId moduleIdOfOperation(wxTreeItemId id)
std::string moduleOfOperation(wxTreeItemId id)
virtual boost::format text(int textId)
static wxString toWxString(const std::string &source)
static std::string toString(const wxString &source)

References OSEdConstants::APPLICATION_NAME, assert, OSEdConstants::BEHAVIOR_TEMPLATE_FILE_NAME, FileSystem::copy(), Environment::dataDirPath(), FileSystem::DIRECTORY_SEPARATOR, false, FileSystem::fileExists(), OSEdTextGenerator::instance(), OSEdTreeView::moduleIdOfOperation(), OSEdTreeView::moduleOfOperation(), options, GUICommand::parentWindow(), OSEdTreeView::pathOfModule(), OSEdTreeView::selectedOperationId(), Texts::TextGenerator::text(), WxConversion::toString(), WxConversion::toWxString(), OSEdTextGenerator::TXT_ERROR_NO_EDITOR, and OSEdTextGenerator::TXT_ERROR_OPEN.

Here is the call graph for this function:

◆ icon()

string OSEdModifyBehaviorCmd::icon ( ) const
virtual

Returns the icon path.

Returns
Empty string (icons not used).

Implements GUICommand.

Definition at line 179 of file OSEdModifyBehaviorCmd.cc.

179 {
180 return "";
181}

◆ id()

int OSEdModifyBehaviorCmd::id ( ) const
virtual

Returns the id of the command.

Returns
The id of the command.

Implements GUICommand.

Definition at line 70 of file OSEdModifyBehaviorCmd.cc.

70 {
72}
@ CMD_MODIFY_BEHAVIOR
Modify operation behavior command id.

References OSEdConstants::CMD_MODIFY_BEHAVIOR.

◆ isEnabled()

bool OSEdModifyBehaviorCmd::isEnabled ( )
virtual

Returns true if command is enabled.

Command is enable when path of the selected operation is writable.

Returns
True if command is enabled.

Implements GUICommand.

Definition at line 155 of file OSEdModifyBehaviorCmd.cc.

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

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

Here is the call graph for this function:

◆ operator=()

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

Assignment not allowed.


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