Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
solverstack
vite
Commits
6f0796c1
Commit
6f0796c1
authored
Apr 15, 2009
by
Johnny Jazeix
Browse files
Barre d'avancement.
parent
abbc344e
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
src/interface/Progress_bar_thread.cpp
deleted
100644 → 0
View file @
abbc344e
#include
"Progress_bar_thread.hpp"
void
Progress_bar_thread
::
init
(
Parser
*
p
,
Interface_console
*
i
){
_interface_console
=
i
;
_parser
=
p
;
}
void
Progress_bar_thread
::
run
()
{
int
loaded
=
0
;
while
(
!
_parser
->
is_end_of_parsing
())
{
loaded
=
_parser
->
get_size_loaded
();
sleep
(
1
);
// We wait 1 second
QApplication
::
processEvents
();
std
::
cout
<<
"Loading of the trace : "
<<
loaded
<<
"%"
<<
std
::
endl
;
//_interface_console->update_progress_bar(loaded);
}
((
ParserPaje
*
)
_parser
)
->
reinit_cursor
();
}
src/interface/interface_console.cpp
View file @
6f0796c1
...
...
@@ -97,12 +97,11 @@ Interface_console::~Interface_console(){
**********************************/
bool
Interface_console
::
draw_trace
(
const
string
&
filename
,
const
int
format
){
// Trace trace;
ParserPaje
parser
;
ParserPaje
parser
;
parser
.
set_file_to_parse
(
filename
);
QApplication
::
setOverrideCursor
(
Qt
::
WaitCursor
);
...
...
@@ -113,39 +112,39 @@ bool Interface_console::draw_trace(const string & filename, const int format){
case
_DRAW_OPENGL
:
{
DrawTrace
<
Render_opengl
>
drawing_ogl
;
// // Init of the thread
Progress_bar_thread
thread
;
thread
.
init
(
&
parser
,
this
);
// _progress_dialog = new QProgressDialog("Parsing", "Cancel", 0, 100, _main_window);
// _progress_dialog->show();
thread
.
start
();
if
(
NULL
==
_trace
){
/* no trace is loaded, parse the file */
if
(
NULL
==
_trace
){
/* no trace is loaded, parse the file */
_trace
=
new
Trace
();
try
{
_main_window
->
setDisabled
(
true
);
parser
.
parse
(
filename
,
*
_trace
);
}
catch
(
const
string
&
error
)
{
_main_window
->
setDisabled
(
false
);
Error
::
print_numbers
();
Error
::
flush_in_file
(
"log.txt"
);
//delete _progress_dialog;
*
Message
::
get_instance
()
<<
"Reason : "
<<
error
<<
Message
::
ende
;
QApplication
::
restoreOverrideCursor
();
parser
.
finish
();
// Wait for the end thread
while
(
!
thread
.
isFinished
()){
}
// Init of the thread
parsing_thread
thread
;
thread
.
init
(
&
parser
,
_trace
,
filename
);
_progress_dialog
=
new
QProgressDialog
(
"Parsing"
,
"Cancel"
,
0
,
100
,
_main_window
);
_progress_dialog
->
show
();
return
false
;
thread
.
start
();
int
loaded
=
0
;
_main_window
->
setDisabled
(
true
);
while
(
!
parser
.
is_end_of_parsing
())
{
loaded
=
parser
.
get_size_loaded
();
sleep
(
1
);
// We wait 1 second
update_progress_bar
(
loaded
);
QApplication
::
processEvents
();
std
::
cout
<<
"Loading of the trace : "
<<
loaded
<<
"%"
<<
std
::
endl
;
}
//delete _progress_dialog;
((
ParserPaje
)
parser
).
reinit_cursor
();
Error
::
print_numbers
();
Error
::
flush
(
"log.txt"
);
delete
_progress_dialog
;
_main_window
->
setDisabled
(
false
);
// Wait for the end thread
while
(
!
thread
.
isFinished
()){
while
(
!
thread
.
isFinished
())
{
}
...
...
src/interface/interface_console.hpp
View file @
6f0796c1
...
...
@@ -25,7 +25,7 @@ class Interface_console;
#include
"../Tools.hpp"
#include
"
Progress_bar
_thread.hpp"
#include
"
parsing
_thread.hpp"
/*!
...
...
src/interface/option_export_window.ui
View file @
6f0796c1
...
...
@@ -41,6 +41,10 @@
<height>20</height>
</size>
</property>
<property name="toolTip" >
<string>if not checked, export all the trace. Else just the part selected.
By default, the value is the same as the trace selection opened.</string>
</property>
<property name="text" >
<string>export a part of the trace</string>
</property>
...
...
@@ -205,6 +209,10 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>If not checked, the accuracy will be 0 so the exported file will
contain every event of the trace.</string>
</property>
<property name="text" >
<string>accuracy</string>
</property>
...
...
@@ -221,6 +229,11 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Set the accuracy for export.
The lower it is, the better the precision will be but the file will also be bigger.
If 0, everything will appear in the exported file.</string>
</property>
<property name="text" >
<string>0.1</string>
</property>
...
...
src/interface/parsing_thread.cpp
0 → 100644
View file @
6f0796c1
#include
"parsing_thread.hpp"
void
parsing_thread
::
init
(
Parser
*
p
,
Trace
*
t
,
std
::
string
filename
){
_parser
=
p
;
_trace
=
t
;
_filename
=
filename
;
}
void
parsing_thread
::
run
()
{
try
{
_parser
->
parse
(
_filename
,
*
_trace
);
}
catch
(
const
std
::
string
&
error
)
{
((
ParserPaje
*
)
_parser
)
->
finish
();
}
}
src/interface/
Progress_bar
_thread.hpp
→
src/interface/
parsing
_thread.hpp
View file @
6f0796c1
#ifndef P
ROGRESS_BAR
_THREAD_HPP
#define P
ROGRESS_BAR
_THREAD_HPP
#ifndef P
ARSING
_THREAD_HPP
#define P
ARSING
_THREAD_HPP
#include
<QThread>
#include
"../parser/Parser.hpp"
#include
"
interface_consol
e.hpp"
#include
"../parser/Parser
Paje
.hpp"
#include
"
../trace/Trac
e.hpp"
#include
<iostream>
/*!
* \class
Progress_bar
_thread
* \class
parsing
_thread
* \brief Contains the progress bar while loading of a trace
* Doesn't work well so not added to the soft yet.
*/
class
Progress_bar
_thread
:
public
QThread
{
class
parsing
_thread
:
public
QThread
{
Q_OBJECT
private:
Interface_console
*
_interface_console
;
Parser
*
_parser
;
Trace
*
_trace
;
std
::
string
_filename
;
public:
/*!
* \fn init(Parser *p,
Interface_console *i
)
* \fn init(Parser *p,
Trace *t, std::string filename
)
* \param p the parser used to parse the file.
* \param i the interface where is stored the progress bar.
* \param filename the file parsed.
* \param t the trace where we store data.
*/
void
init
(
Parser
*
p
,
Interface_console
*
i
);
void
init
(
Parser
*
p
,
Trace
*
t
,
std
::
string
filename
);
protected:
/*!
...
...
@@ -34,4 +36,4 @@ protected:
void
run
();
};
#endif // P
ROGRESS_BAR
_THREAD_HPP
#endif // P
ARSING
_THREAD_HPP
src/message/Errors.cpp
View file @
6f0796c1
...
...
@@ -54,6 +54,12 @@ void Error::set(const string kind_of_error, const int priority){
}
}
void
Error
::
set
(
const
string
kind_of_error
,
const
unsigned
int
line_number
,
const
int
priority
){
char
line
[
10
];
sprintf
(
line
,
"%d"
,
line_number
);
set
(
kind_of_error
+
" on line "
+
line
,
priority
);
}
void
Error
::
set_and_print
(
const
string
kind_of_error
,
const
int
priority
){
set
(
kind_of_error
,
priority
);
print
(
priority
);
...
...
@@ -78,7 +84,7 @@ bool Error::set_if(bool condition, const string kind_of_error, const unsigned in
}
void
Error
::
print
(
const
int
priority
){
void
Error
::
print
(
const
int
priority
)
{
*
Message
::
get_instance
()
<<
_content
;
switch
(
priority
){
case
_WARNING
:
...
...
@@ -90,6 +96,17 @@ void Error::print(const int priority){
}
}
void
Error
::
print
(
const
string
content
,
const
int
priority
)
{
*
Message
::
get_instance
()
<<
content
;
switch
(
priority
){
case
_WARNING
:
*
Message
::
get_instance
()
<<
Message
::
endw
;
break
;
default:
// Include the _ERROR
*
Message
::
get_instance
()
<<
Message
::
ende
;
break
;
}
}
void
Error
::
print_numbers
(){
*
Message
::
get_instance
()
<<
Error
::
_errors
.
size
()
<<
" errors and "
<<
Error
::
_warnings
.
size
()
<<
" warnings were found during parsing."
;
...
...
@@ -104,12 +121,15 @@ void Error::print_numbers(){
}
}
void
Error
::
flush
_in_file
(
const
string
&
filename
){
void
Error
::
flush
(
const
string
&
filename
){
if
(
_errors
.
empty
()
&&
_warnings
.
empty
())
{
return
;
}
else
{
print
(
"Errors and warnings can be found in "
+
filename
,
_ERROR
);
ofstream
outfile
(
filename
.
c_str
(),
ios
::
out
|
ios
::
trunc
);
const
int
number_of_errors
=
Error
::
_errors
.
size
();
...
...
@@ -119,25 +139,27 @@ void Error::flush_in_file(const string &filename){
cerr
<<
"unable to open "
<<
filename
<<
" to print the errors encountered in the file opening"
<<
endl
;
return
;
}
else
{
else
{
outfile
<<
"File "
<<
Message
::
get_interface
()
->
get_filename
()
<<
endl
<<
endl
;
if
(
!
_errors
.
empty
()){
if
(
!
_errors
.
empty
())
{
outfile
<<
"Errors :"
<<
endl
;
}
// Print the errors
while
(
!
_errors
.
empty
()){
while
(
!
_errors
.
empty
())
{
outfile
<<
_errors
.
front
()
<<
endl
;
//print(_errors.front(), _ERROR);
_errors
.
pop
();
}
// Print the warnings
if
(
!
_warnings
.
empty
()){
if
(
!
_warnings
.
empty
())
{
outfile
<<
endl
<<
"Warnings :"
<<
endl
;
}
while
(
!
_warnings
.
empty
()){
while
(
!
_warnings
.
empty
())
{
outfile
<<
_warnings
.
front
()
<<
endl
;
//print(_warnings.front(), _WARNING);
_warnings
.
pop
();
}
...
...
src/message/Errors.hpp
View file @
6f0796c1
...
...
@@ -170,6 +170,8 @@ public:
*/
static
void
set
(
const
std
::
string
kind_of_error
,
const
int
priority
);
static
void
set
(
const
std
::
string
kind_of_error
,
const
unsigned
int
line_number
,
const
int
priority
);
/*!
* \fn set_and_print(const std::string kind_of_error, const int priority) static void
* \brief raise and throw to the interface an error or a warning
...
...
@@ -194,6 +196,14 @@ public:
*/
static
void
print
(
const
int
priority
);
/*!
* \fn print(const std::string content, const int priority) static void
* \brief print the current error
* \param content : the string we want to print
* \param priority : _ERROR or _WARNING
*/
static
void
print
(
const
std
::
string
content
,
const
int
priority
);
/*!
* \fn set_if(bool condition, const std::string kind_of_error, const unsigned int line_number, const int priority) static bool
* \brief raise an error or a warning and the line when it occurs if the condition is satisfied
...
...
@@ -212,11 +222,11 @@ public:
static
void
print_numbers
();
/*!
* \fn flush
_in_file
(const std::string &filename) static void
* \fn flush(const std::string &filename) static void
* \brief print all the errors and warnings saved in a file and empty the queues _errors and _warnings
* \param filename : a file path
*/
static
void
flush
_in_file
(
const
std
::
string
&
filename
);
static
void
flush
(
const
std
::
string
&
filename
);
};
...
...
src/parser/ParserDefinitionDecoder.cpp
View file @
6f0796c1
...
...
@@ -16,14 +16,14 @@ int ParserDefinitionDecoder::definitions_number(){
void
ParserDefinitionDecoder
::
enter_definition
(
Line
&
line
){
if
(
_state
==
_IN_A_DEFINITION
){
Error
::
set
_and_print
(
Error
::
_EXPECT_END_DEF
,
line
.
get_line_count
(),
Error
::
_WARNING
);
Error
::
set
(
Error
::
_EXPECT_END_DEF
,
line
.
get_line_count
(),
Error
::
_WARNING
);
leave_definition
(
line
);
}
string
definition_name
;
if
(
!
line
.
item
(
2
,
definition_name
)){
Error
::
set
_and_print
(
Error
::
_EXPECT_NAME_DEF
,
line
.
get_line_count
(),
Error
::
_ERROR
);
Error
::
set
(
Error
::
_EXPECT_NAME_DEF
,
line
.
get_line_count
(),
Error
::
_ERROR
);
return
;
}
...
...
@@ -31,12 +31,12 @@ void ParserDefinitionDecoder::enter_definition(Line &line){
string
definition_identity_string
;
if
(
!
line
.
item
(
3
,
definition_identity_string
)){
Error
::
set
_and_print
(
Error
::
_EXPECT_ID_DEF
,
line
.
get_line_count
(),
Error
::
_ERROR
);
Error
::
set
(
Error
::
_EXPECT_ID_DEF
,
line
.
get_line_count
(),
Error
::
_ERROR
);
return
;
}
if
(
sscanf
(
definition_identity_string
.
c_str
(),
"%d"
,
&
definition_identity
)
!=
1
){
Error
::
set
_and_print
(
Error
::
_EXPECT_ID_DEF
,
line
.
get_line_count
(),
Error
::
_ERROR
);
Error
::
set
(
Error
::
_EXPECT_ID_DEF
,
line
.
get_line_count
(),
Error
::
_ERROR
);
return
;
}
...
...
@@ -45,7 +45,7 @@ void ParserDefinitionDecoder::enter_definition(Line &line){
_current_definition
=
definition_identity
;
if
(
line
.
length
()
>
4
){
Error
::
set
_and_print
(
Error
::
_EXTRA_TOKEN
,
line
.
get_line_count
(),
Error
::
_WARNING
);
Error
::
set
(
Error
::
_EXTRA_TOKEN
,
line
.
get_line_count
(),
Error
::
_WARNING
);
}
_state
=
_IN_A_DEFINITION
;
...
...
@@ -55,13 +55,13 @@ void ParserDefinitionDecoder::enter_definition(Line &line){
void
ParserDefinitionDecoder
::
leave_definition
(
Line
&
line
){
if
(
_state
!=
_IN_A_DEFINITION
){
Error
::
set
_and_print
(
Error
::
_EXPECT_EVENT_DEF
,
line
.
get_line_count
(),
Error
::
_WARNING
);
Error
::
set
(
Error
::
_EXPECT_EVENT_DEF
,
line
.
get_line_count
(),
Error
::
_WARNING
);
return
;
}
_state
=
_OUT_A_DEFINITION
;
if
(
!
_definitions
[
_current_definition
].
check_definition
()){
Error
::
set
_and_print
(
Error
::
_UNKNOWN_EVENT_DEF
+
_definitions
[
_current_definition
].
print_string
(),
line
.
get_line_count
(),
Error
::
_ERROR
);
Error
::
set
(
Error
::
_UNKNOWN_EVENT_DEF
+
_definitions
[
_current_definition
].
print_string
(),
line
.
get_line_count
(),
Error
::
_ERROR
);
_definitions
.
erase
(
_current_definition
);
return
;
}
...
...
@@ -70,26 +70,26 @@ void ParserDefinitionDecoder::leave_definition(Line &line){
void
ParserDefinitionDecoder
::
add_field_to_definition
(
std
::
string
&
first_token
,
Line
&
line
){
if
(
_state
==
_OUT_A_DEFINITION
){
Error
::
set
_and_print
(
Error
::
_EXPECT_EVENT_DEF
,
line
.
get_line_count
(),
Error
::
_ERROR
);
Error
::
set
(
Error
::
_EXPECT_EVENT_DEF
,
line
.
get_line_count
(),
Error
::
_ERROR
);
return
;
}
string
field_type
;
if
(
!
line
.
item
(
2
,
field_type
)){
Error
::
set
_and_print
(
Error
::
_FIELD_TYPE_MISSING
,
line
.
get_line_count
(),
Error
::
_ERROR
);
Error
::
set
(
Error
::
_FIELD_TYPE_MISSING
,
line
.
get_line_count
(),
Error
::
_ERROR
);
return
;
}
if
(
field_type
!=
"string"
&&
field_type
!=
"int"
&&
field_type
!=
"hex"
&&
field_type
!=
"date"
&&
field_type
!=
"double"
&&
field_type
!=
"color"
){
Error
::
set
_and_print
(
Error
::
_FIELD_TYPE_UNKNOWN
+
field_type
,
line
.
get_line_count
(),
Error
::
_ERROR
);
Error
::
set
(
Error
::
_FIELD_TYPE_UNKNOWN
+
field_type
,
line
.
get_line_count
(),
Error
::
_ERROR
);
return
;
}
_definitions
[
_current_definition
].
store
(
first_token
,
field_type
);
if
(
line
.
length
()
>
3
){
Error
::
set
_and_print
(
Error
::
_EXTRA_TOKEN
,
line
.
get_line_count
(),
Error
::
_WARNING
);
Error
::
set
(
Error
::
_EXTRA_TOKEN
,
line
.
get_line_count
(),
Error
::
_WARNING
);
}
}
...
...
@@ -98,7 +98,7 @@ void ParserDefinitionDecoder::store_definition(Line &line){
string
first_token
;
if
(
!
line
.
item
(
1
,
first_token
)){
Error
::
set
_and_print
(
Error
::
_EMPTY_DEF
,
line
.
get_line_count
(),
Error
::
_WARNING
);
Error
::
set
(
Error
::
_EMPTY_DEF
,
line
.
get_line_count
(),
Error
::
_WARNING
);
return
;
}
...
...
@@ -108,7 +108,7 @@ void ParserDefinitionDecoder::store_definition(Line &line){
else
if
(
first_token
==
"EndEventDef"
){
leave_definition
(
line
);
if
(
line
.
length
()
>
2
){
Error
::
set
_and_print
(
Error
::
_EXTRA_TOKEN
,
line
.
get_line_count
(),
Error
::
_WARNING
);
Error
::
set
(
Error
::
_EXTRA_TOKEN
,
line
.
get_line_count
(),
Error
::
_WARNING
);
}
}
else
{
...
...
src/parser/ParserEventDecoder.cpp
View file @
6f0796c1
This diff is collapsed.
Click to expand it.
src/parser/ParserPaje.cpp
View file @
6f0796c1
...
...
@@ -8,11 +8,10 @@ ParserPaje::ParserPaje(){
void
ParserPaje
::
parse
(
string
filename
,
Trace
&
trace
){
_is_finished
=
false
;
// If the file must have the extension .trace
//
const
unsigned
int
position_of_dot
=
filename
.
find_last_of
(
'.'
);
if
(
position_of_dot
==
string
::
npos
||
filename
.
substr
(
position_of_dot
)
!=
".trace"
){
Error
::
set
_and_print
(
Error
::
_BAD_FILE_EXTENSION
,
Error
::
_WARNING
);
Error
::
set
(
Error
::
_BAD_FILE_EXTENSION
,
Error
::
_WARNING
);
}
ParserDefinitionDecoder
*
parserdefinition
=
new
ParserDefinitionDecoder
();
ParserEventDecoder
*
parserevent
=
new
ParserEventDecoder
();
...
...
@@ -24,8 +23,6 @@ void ParserPaje::parse(string filename, Trace &trace){
string
event_identity_string
;
unsigned
int
event_identity
;
QApplication
::
processEvents
();
while
(
!
line
.
is_eof
())
{
line
.
newline
();
...
...
@@ -38,7 +35,7 @@ void ParserPaje::parse(string filename, Trace &trace){
else
{
// We check if we have an event identifier
if
(
sscanf
(
event_identity_string
.
c_str
(),
"%d"
,
&
event_identity
)
!=
1
){
Error
::
set
_and_print
(
Error
::
_EXPECT_ID_DEF
,
line
.
get_line_count
(),
Error
::
_WARNING
);
Error
::
set
(
Error
::
_EXPECT_ID_DEF
,
line
.
get_line_count
(),
Error
::
_WARNING
);
continue
;
}
Definition
current_definition
;
...
...
@@ -46,7 +43,7 @@ void ParserPaje::parse(string filename, Trace &trace){
current_definition
=
parserdefinition
->
get_definition
(
event_identity
);
}
catch
(
unsigned
int
)
{
Error
::
set
_and_print
(
Error
::
_UNKNOWN_ID_DEF
+
event_identity_string
,
line
.
get_line_count
(),
Error
::
_WARNING
);
Error
::
set
(
Error
::
_UNKNOWN_ID_DEF
+
event_identity_string
,
line
.
get_line_count
(),
Error
::
_WARNING
);
continue
;
}
parserevent
->
store_event
(
current_definition
,
...
...
@@ -58,10 +55,6 @@ void ParserPaje::parse(string filename, Trace &trace){
finish
();
trace
.
finish
();
// We print the warnings and errors
Error
::
print_numbers
();
Error
::
flush_in_file
(
"log.txt"
);
delete
parserdefinition
;
delete
parserevent
;
}
...
...
src/parser/TokenSource.cpp
View file @
6f0796c1
...
...
@@ -27,7 +27,7 @@ TokenSource::~TokenSource(){
_file
.
close
();
#else
if
(
munmap
(
_buffer
,
_filesize
)
==
-
1
){
Error
::
set
_and_print
(
Error
::
_MUNMAP
,
Error
::
_WARNING
);
Error
::
set
(
Error
::
_MUNMAP
,
Error
::
_WARNING
);
}
_buffer
=
NULL
;
close
(
_fd
);
...
...
@@ -102,14 +102,14 @@ void TokenSource::build_composite_token() {
#if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
if
(
_cursor
==
_buffer_size
)
{
if
(
!
fill_buffer
())
{
Error
::
set
_and_print
(
Error
::
_FSTAT
,
Error
::
_WARNING
);
Error
::
set
(
Error
::
_FSTAT
,
Error
::
_WARNING
);
return
;
}
_cursor
=
0
;
}
#else
if
(
ensure_capacity
())
{
Error
::
set
_and_print
(
Error
::
_FSTAT
,
Error
::
_WARNING
);
Error
::
set
(
Error
::
_FSTAT
,
Error
::
_WARNING
);
return
;
}
#endif
...
...
src/src.pro
View file @
6f0796c1
...
...
@@ -33,7 +33,7 @@ HEADERS += message/Message.hpp \
interface
/
interface
.
hpp
\
interface
/
interface_console
.
hpp
\
interface
/
interface_graphic
.
hpp
\
interface
/
Progress_bar
_thread
.
hpp
\
interface
/
parsing
_thread
.
hpp
\
interface
/
resource
.
hpp
\
interface
/
help
.
hpp
\
#
Render
headers
...
...
@@ -90,7 +90,7 @@ SOURCES += message/Message.cpp \
#
Interface
code
files
interface
/
interface_console
.
cpp
\
interface
/
interface_graphic
.
cpp
\
interface
/
Progress_bar
_thread
.
cpp
\
interface
/
parsing
_thread
.
cpp
\
interface
/
help
.
cpp
\
#
Render
code
files
render
/
render_opengl
.
cpp
\
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment