29 #include <vrpn_Connection.h>
36 VRPNConnectionCollection::VRPNConnectionCollection()
37 : m_connMap(make_shared<ConnectionMap>()) {}
39 vrpn_ConnectionPtr VRPNConnectionCollection::getConnection(
40 common::elements::DeviceElement
const &elt) {
41 return getConnection(elt.getDeviceName(), elt.getServer());
45 VRPNConnectionCollection::addConnection(vrpn_ConnectionPtr conn,
46 std::string
const &host) {
47 auto &connMap = *m_connMap;
48 auto existing = connMap.find(host);
49 if (existing != end(connMap)) {
50 return existing->second;
53 BOOST_ASSERT(!empty());
58 VRPNConnectionCollection::getConnection(std::string
const &device,
59 std::string
const &host) {
60 auto &connMap = *m_connMap;
61 auto existing = connMap.find(host);
62 if (existing != end(connMap)) {
63 return existing->second;
65 auto fullName = device +
"@" + host;
67 vrpn_ConnectionPtr newConn(
68 vrpn_get_connection_by_name(fullName.c_str(),
nullptr,
nullptr,
69 nullptr,
nullptr,
nullptr,
true));
70 connMap[host] = newConn;
71 newConn->removeReference();
72 BOOST_ASSERT(!empty());
76 void VRPNConnectionCollection::updateAll() {
77 for (
auto &connPair : *m_connMap) {
78 connPair.second->mainloop();