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_; }
68 RealTimeLogger *logger_;
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();