vrpn  07.33
Virtual Reality Peripheral Network
vrpn_SendTextMessageStreamProxy.h
Go to the documentation of this file.
1 
25 // Copyright Iowa State University 2011.
26 // Distributed under the Boost Software License, Version 1.0.
27 // (See accompanying file LICENSE_1_0.txt or copy at
28 // http://www.boost.org/LICENSE_1_0.txt)
29 
30 #pragma once
31 
32 // Internal Includes
33 #include "vrpn_BaseClass.h"
34 
35 // Library/third-party includes
36 // - none
37 
38 // Standard includes
39 #include <sstream>
40 
42 private:
46 
48  std::ostringstream _s;
49 
52  operator=(vrpn_SendTextMessageStreamProxy const&);
53 
54 public:
56  template <typename T>
59  T const& firstData)
60  : _call(call)
61  {
62  _s << firstData;
63  }
64 
69  std::string const& firstData)
70  : _call(call)
71  , _s(firstData)
72  {
73  }
74 
78  : _call(other._call)
79  , _s(other._s.str())
80  {
81  }
82 
85  ~vrpn_SendTextMessageStreamProxy() { _call(_s.str().c_str()); }
86 
93  template <typename T> std::ostream& operator<<(T const& other)
94  {
95  _s << other;
96  return _s;
97  }
98 };
99 
108 template <typename T>
111  T const& firstData)
112 {
113  return vrpn_SendTextMessageStreamProxy(call, firstData);
114 }
operator<<
vrpn_SendTextMessageStreamProxy operator<<(vrpn_BaseClassUnique::SendTextMessageBoundCall const &call, T const &firstData)
Templated operator << that takes a vrpn_BaseClassUnique::SendTextMessageBoundCall on the left,...
Definition: vrpn_SendTextMessageStreamProxy.h:110
vrpn_BaseClass.h
vrpn_SendTextMessageStreamProxy::~vrpn_SendTextMessageStreamProxy
~vrpn_SendTextMessageStreamProxy()
Destructor performs the send_text_message call with all contents streamed into it.
Definition: vrpn_SendTextMessageStreamProxy.h:85
vrpn_BaseClassUnique::SendTextMessageBoundCall
Definition: vrpn_BaseClass.h:196
vrpn_SendTextMessageStreamProxy
Definition: vrpn_SendTextMessageStreamProxy.h:41
vrpn_SendTextMessageStreamProxy::vrpn_SendTextMessageStreamProxy
vrpn_SendTextMessageStreamProxy(vrpn_BaseClassUnique::SendTextMessageBoundCall const &call, T const &firstData)
Templated constructor taking anything streamable.
Definition: vrpn_SendTextMessageStreamProxy.h:57
vrpn_SendTextMessageStreamProxy::vrpn_SendTextMessageStreamProxy
vrpn_SendTextMessageStreamProxy(vrpn_SendTextMessageStreamProxy const &other)
Copy constructor - required for return by value (?)
Definition: vrpn_SendTextMessageStreamProxy.h:76
vrpn_SendTextMessageStreamProxy::vrpn_SendTextMessageStreamProxy
vrpn_SendTextMessageStreamProxy(vrpn_BaseClassUnique::SendTextMessageBoundCall const &call, std::string const &firstData)
Constructor taking a std::string, since we can use the ostringstream's std::string constructor in thi...
Definition: vrpn_SendTextMessageStreamProxy.h:67
vrpn_SendTextMessageStreamProxy::operator<<
std::ostream & operator<<(T const &other)
Template operator<<, used for the second item streamed into the results of a BoundCall-returning send...
Definition: vrpn_SendTextMessageStreamProxy.h:93