48 template <
typename T>
struct apply {
49 typedef ElementBase<T> base_type;
50 static_assert(std::is_base_of<base_type, T>::value,
51 "A given element type T must inherit from "
52 "ElementBase<T> (the CRTP)!");
58 typedef boost::mpl::transform<PathElement::types, CRTPChecker>::type
63 AliasPriority priority)
64 : m_source(source), m_priority(priority) {}
89 static inline std::string
90 attachPortToServerIfNoneSpecified(std::string
const &server,
int port) {
94 size_t lastColon = server.find_last_of(
':');
95 if (lastColon != std::string::npos) {
96 bool nonDigit =
false;
97 for (
size_t i = lastColon + 1; i < server.size(); i++) {
98 if (!isdigit(server[i])) {
102 if (!nonDigit) {
return server; }
105 if (server.find(
":") != std::string::npos &&
106 server.find(
"tcp://") == std::string::npos) {
113 std::ostringstream os;
121 DeviceElement::createVRPNDeviceElement(std::string
const &deviceName,
122 std::string
const &server) {
124 ret.m_devName = deviceName;
127 attachPortToServerIfNoneSpecified(server, util::DefaultVRPNPort);
134 std::string
const &server,
137 ret.m_devName = deviceName;
140 ret.m_server = server;
142 case util::UseDefaultPort:
144 ret.m_server = attachPortToServerIfNoneSpecified(
149 ret.m_server = attachPortToServerIfNoneSpecified(server, port);
155 std::string &DeviceElement::getDeviceName() {
return m_devName; }
156 std::string
const &DeviceElement::getDeviceName()
const {
160 std::string &DeviceElement::getServer() {
return m_server; }
161 std::string
const &DeviceElement::getServer()
const {
return m_server; }
163 std::string DeviceElement::getFullDeviceName()
const {
164 return getDeviceName() +
"@" + getServer();
166 Json::Value &DeviceElement::getDescriptor() {
return m_descriptor; }
167 Json::Value
const &DeviceElement::getDescriptor()
const {
The element type corresponding to a path alias, with a priority level for sorting out whether automat...
AliasPriority & priority()
Get/set whether this alias was automatically set (and thus subject to being override by explicit rout...
std::string & getSource()
Get the source of data for this alias.
typename F::template apply< Args...> apply
Apply an alias class.
static DeviceElement createDeviceElement(std::string const &deviceName, std::string const &server, int port=util::UseDefaultPort)
The element type corresponding to a device, which implements 0 or more interfaces.
Namespace for the various element types that may constitute a node in the path tree.
Header with default port numbers for OSVR and VRPN. These constants are specified as enums...
AliasElement()
default constructor
std::string & getString()
Get/set (if non const) the stored string.
void setSource(std::string const &source)
Sets the source of this alias.
StringElement()
Default constructor.