-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.cpp
99 lines (93 loc) · 2.48 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include <ShapesDialog.hpp>
#include <QtWidgets/QApplication>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
#ifdef _WIN32
#include <Windows.h>
#endif
#ifdef TESTBUILD
#include <QtTest/QtTest>
#endif
/**
* @addtogroup demos_iShapes ISO C++ DCPS iShapes Demonstrator Application
* Refer to @ref ishapes_readme for information on building and running
* this demo.
*/
/** @{*/
/** @dir */
/** @file */
namespace demo { namespace ishapes {
class iShapes : public QApplication {
public:
iShapes(int& argc, char ** argv) :
QApplication(argc, argv) { }
virtual ~iShapes() { }
// reimplemented from QApplication so we can throw exceptions in slots
virtual bool notify(QObject * receiver, QEvent * event)
{
try
{
return QApplication::notify(receiver, event);
}
catch(std::exception& e)
{
std::string message = "Exception caught:-\n";
message += e.what();
QString qmessage(message.c_str());
QMessageBox::critical(NULL, "Error", qmessage);
}
return false;
}
};
}}
int main(int argc, char *argv[])
{
srand(clock());
demo::ishapes::iShapes app(argc, argv);
#ifdef TESTBUILD
Q_INIT_RESOURCE(ishape_qrc);
#else
Q_INIT_RESOURCE(ishape);
#endif
int retval;
try
{
demo::ishapes::ShapesDialog shapes;
#ifndef TESTBUILD
if(argc > 1)
{
dds::core::StringSeq partitions;
for(int i = 1; i < argc; i++)
{
if(isdigit(argv[i][0]))
shapes.setDomainID(atoi(argv[i]));
else
partitions.push_back(std::string(argv[i]));
}
if(partitions.size() > 0)
shapes.setPartition(partitions);
}
#endif
#ifdef TESTBUILD
// Start publishing a circle with default QoS
QTest::qExec(&shapes, argc, argv);
#else
#ifdef _WIN32
FreeConsole();
#endif
shapes.show();
#endif
retval = app.exec();
}
catch(const dds::core::Exception& e)
{
std::string message = "Exception caught:-\n";
message += e.what();
QString qmessage(message.c_str());
QMessageBox::critical(NULL, "Error", qmessage);
retval = 1;
}
return retval;
}
/** @}*/