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 }
All types of client/server/peer objects in VRPN should be derived from the vrpn_BaseClass type descri...
std::ostream & operator<<(T const &other)
Template operator<<, used for the second item streamed into the results of a BoundCall-returning send...
vrpn_SendTextMessageStreamProxy operator<<(vrpn_BaseClassUnique::SendTextMessageBoundCall const &call, T const &firstData)
Templated operator << that takes a vrpn_BaseClassUnique::SendTextMessageBoundCall on the left...
~vrpn_SendTextMessageStreamProxy()
Destructor performs the send_text_message call with all contents streamed into it.
vrpn_SendTextMessageStreamProxy(vrpn_BaseClassUnique::SendTextMessageBoundCall const &call, T const &firstData)
Templated constructor taking anything streamable.
vrpn_SendTextMessageStreamProxy(vrpn_BaseClassUnique::SendTextMessageBoundCall const &call, std::string const &firstData)
Constructor taking a std::string, since we can use the ostringstream&#39;s std::string constructor in thi...
vrpn_SendTextMessageStreamProxy(vrpn_SendTextMessageStreamProxy const &other)
Copy constructor - required for return by value (?)