Skip to content

Commit f48df6c

Browse files
committed
parameter for setting the title name in vglog
1 parent edd7dc6 commit f48df6c

File tree

8 files changed

+22
-8
lines changed

8 files changed

+22
-8
lines changed

.cproject

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<folderInfo id="org.omnetpp.cdt.gnu.config.debug.1181511094." name="/" resourcePath="">
2121
<toolChain id="org.omnetpp.cdt.gnu.toolchain.debug.1458356819" name="C++ Toolchain for OMNeT++" superClass="org.omnetpp.cdt.gnu.toolchain.debug">
2222
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.MachO64;org.eclipse.cdt.core.PE" id="org.omnetpp.cdt.targetPlatform.1593072366" isAbstract="false" name="Windows, Linux, Mac" osList="win32,linux,macosx" superClass="org.omnetpp.cdt.targetPlatform"/>
23-
<builder id="org.omnetpp.cdt.gnu.builder.debug.1834363135" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="OMNeT++ Make Builder (opp_makemake)" parallelBuildOn="true" parallelizationNumber="4" superClass="org.omnetpp.cdt.gnu.builder.debug"/>
23+
<builder id="org.omnetpp.cdt.gnu.builder.debug.1834363135" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="OMNeT++ Make Builder (opp_makemake)" parallelBuildOn="true" parallelizationNumber="optimal" superClass="org.omnetpp.cdt.gnu.builder.debug"/>
2424
<tool id="cdt.managedbuild.tool.gnu.archiver.base.319999884" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
2525
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.13888097" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base">
2626
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1647669064" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ VENTOS is an open-source VANET C++ simulator for studying vehicular traffic flow
1515
+ using shorter relative path for sumoConfig
1616
+ gnuplot has its own class now
1717
+ vehicle equilibrium is now working for emulated cars
18+
+ enable parallel build
19+
+ loggingWindowTitle sets the vglog window title name
1820
+ updating the manual
1921
+ various small improvements
2022

src/logging/modules.ned

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ simple vglog extends vlog
2828

2929
// relative path to mainWindow
3030
string loggingWindowPath = default("src/loggingWindow/mainWindow");
31+
string loggingWindowTitle = default("Log window");
3132

3233
bool syntaxHighlighting = default(true);
3334
string syntaxHighlightingExpression = default("");

src/logging/vglog.cc

+11-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ void vglog::initialize(int stage)
7474
if(stage == 0)
7575
{
7676
loggingWindowPath = par("loggingWindowPath").stringValue();
77+
if(loggingWindowPath == "")
78+
throw omnetpp::cRuntimeError("loggingWindowPath parameter is invalid");
79+
80+
loggingWindowTitle = par("loggingWindowTitle").stringValue();
81+
if(loggingWindowTitle == "")
82+
throw omnetpp::cRuntimeError("loggingWindowTitle parameter is invalid");
83+
7784
syntaxHighlighting = par("syntaxHighlighting").boolValue();
7885

7986
if(syntaxHighlighting)
@@ -230,9 +237,12 @@ void vglog::openLogWindow()
230237
// make the child process ignore the SIGINT signal
231238
signal(SIGINT, SIG_IGN);
232239

240+
std::ostringstream cmd;
241+
cmd << boost::format("%s \"%s\"") % loggingWindowPath % loggingWindowTitle;
242+
233243
// run 'logWindow' inside this child process
234244
// if execution is successful then child will be blocked at this line
235-
int r = system(loggingWindowPath.c_str());
245+
int r = system(cmd.str().c_str());
236246

237247
if (r == -1)
238248
throw omnetpp::cRuntimeError("Running logWindow failed during system()");

src/logging/vglog.h

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class vglog : public vlog
4444

4545
// NED variables
4646
std::string loggingWindowPath = "";
47+
std::string loggingWindowTitle = "";
4748
bool syntaxHighlighting;
4849
std::string syntaxHighlightingExpression = "";
4950

src/loggingWindow/main.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ int main(int argc, char* argv[])
3333
{
3434
try
3535
{
36-
auto app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
36+
auto app = Gtk::Application::create("VENTOS.vglog");
3737

38-
VENTOS::mainWindow logWindow(argv[0]);
38+
VENTOS::mainWindow logWindow(argv[0] /*path to mainWindow file*/, argv[1] /*window title*/);
3939

4040
// Shows the window and returns when it is closed
41-
return app->run(logWindow, argc, argv);
41+
return app->run(logWindow);
4242
}
4343
catch(const Glib::Exception& ex)
4444
{

src/loggingWindow/mainWindow.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@
4444

4545
namespace VENTOS {
4646

47-
mainWindow::mainWindow(std::string filePath)
47+
mainWindow::mainWindow(std::string filePath, std::string title)
4848
{
4949
boost::filesystem::path full_path(filePath);
5050
std::string logoPath = (full_path.parent_path() / "log_128.png").string();
5151

52-
set_title("Log window");
52+
set_title(title.c_str());
5353
set_border_width(1);
5454
set_default_size(1200, 550 /*height*/);
5555
set_icon_from_file(logoPath.c_str());

src/loggingWindow/mainWindow.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class mainWindow : public Gtk::Window
5757
{
5858

5959
public:
60-
mainWindow(std::string filePath);
60+
mainWindow(std::string filePath, std::string title);
6161
virtual ~mainWindow();
6262

6363
protected:

0 commit comments

Comments
 (0)