Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Guilhem Saurel
dynamic-graph
Commits
bcb3ca77
Commit
bcb3ca77
authored
Jan 31, 2020
by
Joseph Mirabel
Committed by
olivier stasse
Jan 31, 2020
Browse files
Enhance interface of RealTimeLogger and RTLoggerStream
parent
133c8819
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/dynamic-graph/real-time-logger.h
View file @
bcb3ca77
...
@@ -7,12 +7,10 @@
...
@@ -7,12 +7,10 @@
#include
<sstream>
#include
<sstream>
#include
<vector>
#include
<vector>
#include
<boost/circular_buffer.hpp>
#include
<boost/shared_ptr.hpp>
#include
<boost/shared_ptr.hpp>
#include
<boost/thread/mutex.hpp>
#include
<boost/thread/mutex.hpp>
#include
<dynamic-graph/config.hh>
#include
<dynamic-graph/config.hh>
#include
<dynamic-graph/debug.h>
namespace
dynamicgraph
{
namespace
dynamicgraph
{
/// \ingroup debug
/// \ingroup debug
...
@@ -50,22 +48,30 @@ class RealTimeLogger;
...
@@ -50,22 +48,30 @@ class RealTimeLogger;
/// This class is only used by RealTimeLogger.
/// This class is only used by RealTimeLogger.
class
RTLoggerStream
{
class
RTLoggerStream
{
public:
public:
RTLoggerStream
(
RealTimeLogger
*
logger
,
std
::
ostream
&
os
)
inline
RTLoggerStream
(
RealTimeLogger
*
logger
,
std
::
ostream
&
os
)
:
logger_
(
logger
),
os_
(
os
)
{}
:
ok_
(
logger
!=
NULL
),
logger_
(
logger
),
os_
(
os
)
{}
template
<
typename
T
>
inline
RTLoggerStream
&
operator
<<
(
T
t
)
{
template
<
typename
T
>
inline
RTLoggerStream
&
operator
<<
(
T
t
)
{
if
(
logger_
!=
NULL
)
if
(
ok_
)
os_
<<
t
;
os_
<<
t
;
return
*
this
;
return
*
this
;
}
}
inline
RTLoggerStream
&
operator
<<
(
std
::
ostream
&
(
*
pf
)(
std
::
ostream
&
))
{
inline
RTLoggerStream
&
operator
<<
(
std
::
ostream
&
(
*
pf
)(
std
::
ostream
&
))
{
if
(
logger_
!=
NULL
)
if
(
ok_
)
os_
<<
pf
;
os_
<<
pf
;
return
*
this
;
return
*
this
;
}
}
~
RTLoggerStream
();
inline
~
RTLoggerStream
()
{
if
(
ok_
)
{
os_
<<
std
::
ends
;
logger_
->
frontReady
();
}
}
inline
bool
isNull
()
{
return
!
ok_
;
}
private:
private:
const
bool
ok_
;
RealTimeLogger
*
logger_
;
RealTimeLogger
*
logger_
;
std
::
ostream
&
os_
;
std
::
ostream
&
os_
;
};
};
...
@@ -119,6 +125,11 @@ public:
...
@@ -119,6 +125,11 @@ public:
/// The message is considered finished when the object is destroyed.
/// The message is considered finished when the object is destroyed.
RTLoggerStream
front
();
RTLoggerStream
front
();
/// Return an empty stream object.
RTLoggerStream
emptyStream
()
{
return
RTLoggerStream
(
NULL
,
oss_
);
}
inline
void
frontReady
()
{
inline
void
frontReady
()
{
backIdx_
=
(
backIdx_
+
1
)
%
buffer_
.
size
();
backIdx_
=
(
backIdx_
+
1
)
%
buffer_
.
size
();
wmutex
.
unlock
();
wmutex
.
unlock
();
...
...
src/debug/real-time-logger.cpp
View file @
bcb3ca77
...
@@ -59,12 +59,6 @@ RTLoggerStream RealTimeLogger::front() {
...
@@ -59,12 +59,6 @@ RTLoggerStream RealTimeLogger::front() {
return
RTLoggerStream
(
this
,
oss_
);
return
RTLoggerStream
(
this
,
oss_
);
}
}
RTLoggerStream
::~
RTLoggerStream
()
{
os_
<<
std
::
ends
;
if
(
logger_
!=
NULL
)
logger_
->
frontReady
();
}
struct
RealTimeLogger
::
thread
{
struct
RealTimeLogger
::
thread
{
bool
requestShutdown_
;
bool
requestShutdown_
;
int
threadPolicy_
;
int
threadPolicy_
;
...
...
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