5 #ifndef DYNAMIC_GRAPH_LOGGER_REAL_TIME_DEF_H 6 #define DYNAMIC_GRAPH_LOGGER_REAL_TIME_DEF_H 7 #include <boost/shared_ptr.hpp> 8 #include <boost/thread/mutex.hpp> 9 #include <dynamic-graph/config.hh> 23 virtual void write(
const char *c) = 0;
34 virtual void write(
const char *c) { os_ << c; }
48 class RTLoggerStream {
51 : ok_(logger != NULL), logger_(logger), os_(os) {}
57 inline RTLoggerStream &
operator<<(std::ostream &(*pf)(std::ostream &)) {
62 inline ~RTLoggerStream();
64 inline bool isNull() {
return !ok_; }
100 static void destroy();
109 outputs_.push_back(os);
119 RTLoggerStream front();
122 RTLoggerStream
emptyStream() {
return RTLoggerStream(NULL, oss_); }
125 backIdx_ = (backIdx_ + 1) % buffer_.size();
129 inline bool empty()
const {
return frontIdx_ == backIdx_; }
132 return ((backIdx_ + 1) % buffer_.size()) == frontIdx_;
135 inline std::size_t
size()
const {
136 if (frontIdx_ <= backIdx_)
137 return backIdx_ - frontIdx_;
139 return backIdx_ + buffer_.size() - frontIdx_;
170 RTLoggerStream::~RTLoggerStream() {
173 logger_->frontReady();
RTLoggerStream emptyStream()
Return an empty stream object.
virtual void write(const char *c)=0
std::size_t frontIdx_
Index of the next value to be read.
void clearOutputStreams()
std::vector< Data * > buffer_
std::size_t getBufferSize()
boost::shared_ptr< LoggerStream > LoggerStreamPtr_t
std::vector< LoggerStreamPtr_t > outputs_
Main class of the real-time logger.
Stream for the real-time logger.
LoggerIOStream(std::ostream &os)
DYNAMIC_GRAPH_DLLAPI std::ostream & operator<<(std::ostream &os, const dynamicgraph::Entity &ent)
virtual ~LoggerIOStream()
virtual void write(const char *c)
void addOutputStream(const LoggerStreamPtr_t &os)
boost::mutex wmutex
The writer mutex.
static RealTimeLogger * instance_