equal
deleted
inserted
replaced
1 /* -*- Mode:NS3; -*- */ |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* |
2 /* |
3 * Copyright (c) 2006 INRIA |
3 * Copyright (c) 2006 INRIA |
4 * All rights reserved. |
4 * All rights reserved. |
5 * |
5 * |
6 * This program is free software; you can redistribute it and/or modify |
6 * This program is free software; you can redistribute it and/or modify |
32 * it is forwarded to the stored std::ostream output |
32 * it is forwarded to the stored std::ostream output |
33 * stream (if there is one). |
33 * stream (if there is one). |
34 */ |
34 */ |
35 class StreamTracer { |
35 class StreamTracer { |
36 public: |
36 public: |
37 StreamTracer () |
37 StreamTracer () |
38 : m_os (0) {} |
38 : m_os (0) {} |
39 template <typename T> |
39 template <typename T> |
40 StreamTracer &operator << (T const&v) { |
40 StreamTracer &operator << (T const&v) { |
41 if (m_os != 0) |
41 if (m_os != 0) |
42 { |
42 { |
43 (*m_os) << v; |
43 (*m_os) << v; |
44 } |
44 } |
45 return *this; |
45 return *this; |
46 } |
46 } |
47 template <typename T> |
47 template <typename T> |
48 StreamTracer &operator << (T &v) { |
48 StreamTracer &operator << (T &v) { |
49 if (m_os != 0) |
49 if (m_os != 0) |
50 { |
50 { |
51 (*m_os) << v; |
51 (*m_os) << v; |
52 } |
52 } |
53 return *this; |
53 return *this; |
54 } |
54 } |
55 StreamTracer &operator << (std::ostream &(*v) (std::ostream &)) { |
55 StreamTracer &operator << (std::ostream &(*v) (std::ostream &)) { |
56 if (m_os != 0) |
56 if (m_os != 0) |
57 { |
57 { |
58 (*m_os) << v; |
58 (*m_os) << v; |
59 } |
59 } |
60 return *this; |
60 return *this; |
61 } |
61 } |
62 |
62 |
63 /** |
63 /** |
64 * \param os the output stream to store |
64 * \param os the output stream to store |
65 */ |
65 */ |
66 void SetStream (std::ostream * os) { |
66 void SetStream (std::ostream * os) { |
67 m_os = os; |
67 m_os = os; |
68 } |
68 } |
69 private: |
69 private: |
70 std::ostream *m_os; |
70 std::ostream *m_os; |
71 }; |
71 }; |
72 |
72 |
73 }; // namespace ns3 |
73 }; // namespace ns3 |
74 |
74 |
75 |
75 |