OpenASIP  2.0
HDBEditor.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file HDBEditor.cc
26  *
27  * Definition of HDBEditor class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2006 (vjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include <wx/cmdline.h>
34 
35 #include "HDBEditor.hh"
36 #include "HDBEditorMainFrame.hh"
37 #include "WxConversion.hh"
38 #include "FileSystem.hh"
39 
40 IMPLEMENT_APP(HDBEditor)
41 
42 /**
43  * Constructor.
44  */
45 HDBEditor::HDBEditor() : mainFrame_(NULL) {
46 }
47 
48 /**
49  * Destructor.
50  */
52 }
53 
54 /**
55  * Initializes the application.
56  *
57  * Creates mainframe as well as reads the configure file.
58  *
59  * @return True.
60  */
61 bool
63 
65 
66  mainFrame_ = new HDBEditorMainFrame(_T("HDB Editor"),
67  wxPoint(50, 50), wxSize(900, 500));
68 
69  // parse command line
70  static const wxCmdLineEntryDesc cmdLineDesc[] = {
71 #if wxCHECK_VERSION(3,0,0)
72  { wxCMD_LINE_PARAM, "", "", "file", wxCMD_LINE_VAL_STRING,
73  wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE },
74 
75  { wxCMD_LINE_NONE, "", "", "", wxCMD_LINE_VAL_STRING, 0}
76 #else
77  { wxCMD_LINE_PARAM, _T(""), _T(""), _T("file"), wxCMD_LINE_VAL_STRING,
78  wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE },
79 
80  { wxCMD_LINE_NONE, _T(""), _T(""), _T(""), wxCMD_LINE_VAL_STRING, 0}
81 #endif
82  };
83 
84  wxCmdLineParser parser(cmdLineDesc, argc, argv);
85  int parserStatus = parser.Parse();
86  if (parserStatus != 0) {
87  return false;
88  }
89 
90  // open documents given in command line
91  for (unsigned int i = 0; i < parser.GetParamCount(); i++) {
92  wxString file = parser.GetParam(i);
93  std::string fileName = WxConversion::toString(file);
94  if (!FileSystem::fileExists(fileName)) {
95  std::cerr << "File '" << fileName << "' not found." << std::endl;
96  } else {
97  mainFrame_->setHDB(fileName);
98  }
99  }
100  mainFrame_->Show(true);
101  SetTopWindow(mainFrame_);
102  return true;
103 }
104 
105 /**
106  * Deletes the application level dynamic objects not handled by wxWindows.
107  *
108  * This function is called when application is about to exit.
109  *
110  * @return 0.
111  */
112 int
114  return 0;
115 }
116 
117 
118 /**
119  * Returns the main frame of the application.
120  *
121  * @return The main frame of the application.
122  */
125  return *mainFrame_;
126 }
127 
128 
129 /**
130  * Returns pointer to the browser window of the application main frame.
131  *
132  * @return Browser window of the mainframe.
133  */
136  return mainFrame_->browser();
137 }
FileSystem.hh
HDBBrowserWindow
Definition: HDBBrowserWindow.hh:59
HDBEditor.hh
HDBEditor::~HDBEditor
virtual ~HDBEditor()
Definition: HDBEditor.cc:51
HDBEditorMainFrame::setHDB
bool setHDB(const std::string &hdbFile)
Definition: HDBEditorMainFrame.cc:252
HDBEditor::browser
HDBBrowserWindow * browser() const
Definition: HDBEditor.cc:135
HDBEditorMainFrame.hh
HDBEditor::OnInit
virtual bool OnInit()
Definition: HDBEditor.cc:62
HDBEditor::mainFrame
HDBEditorMainFrame & mainFrame() const
Definition: HDBEditor.cc:124
HDBEditor::mainFrame_
HDBEditorMainFrame * mainFrame_
Main window of the application.
Definition: HDBEditor.hh:67
HDBEditor
Definition: HDBEditor.hh:48
HDBEditorMainFrame
Definition: HDBEditorMainFrame.hh:50
FileSystem::fileExists
static bool fileExists(const std::string fileName)
Application::initialize
static void initialize()
Definition: Application.cc:99
WxConversion.hh
HDBEditorMainFrame::browser
HDBBrowserWindow * browser() const
Definition: HDBEditorMainFrame.cc:335
WxConversion::toString
static std::string toString(const wxString &source)
WxConversion::toCStringArray
static char ** toCStringArray(size_t elements, wxChar **source)
Definition: WxConversion.cc:123
HDBEditor::OnExit
virtual int OnExit()
Definition: HDBEditor.cc:113