OrocosComponentLibrary  2.9.0
CategoryStream.hpp
1 #ifndef CATEGORY_STREAM_HPP
2 #define CATEGORY_STREAM_HPP 1
3 
4 #include <ocl/OCL.hpp>
5 #include <log4cpp/Priority.hh>
6 #include <rtt/rt_string.hpp>
7 
8 namespace OCL {
9 namespace logging {
10 
11 class OCL_API Category;
12 
19 class OCL_API CategoryStream
20 {
21 public:
22 
29  CategoryStream(Category* rt_category, log4cpp::Priority::Value priority);
30 
36  CategoryStream(const CategoryStream & rhs);
37 
42  virtual ~CategoryStream();
43 
48  void flush();
49 
55  template<typename T> CategoryStream& operator<<(const T& t)
56  {
57  if (_priority != log4cpp::Priority::NOTSET)
58  {
59  (oss) << t;
60  }
61  return *this;
62  }
63 
64 private:
65 
66  Category* _category;
67  log4cpp::Priority::Value _priority;
68  RTT::rt_ostringstream oss;
69 
70 };
71 
72 
73 } // namespace logging
74 } // namespace OCL
75 
76 #endif // CATEGORY_STREAM_HPP
This is a utility class which you can use to stream messages into a category object.
The Orocos Component Library.
Definition: Component.hpp:43
CategoryStream & operator<<(const T &t)
Stream in arbitrary types and objects.
A real-time capable category.
Definition: Category.hpp:25