OSVR Framework (Internal Development Docs)  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
PathElementTools.h
Go to the documentation of this file.
1 
11 // Copyright 2014 Sensics, Inc.
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 //
17 // http://www.apache.org/licenses/LICENSE-2.0
18 //
19 // Unless required by applicable law or agreed to in writing, software
20 // distributed under the License is distributed on an "AS IS" BASIS,
21 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 // See the License for the specific language governing permissions and
23 // limitations under the License.
24 
25 #ifndef INCLUDED_PathElementTools_h_GUID_9246E2D5_1598_409F_BD30_1817FA2C1FB2
26 #define INCLUDED_PathElementTools_h_GUID_9246E2D5_1598_409F_BD30_1817FA2C1FB2
27 
28 // Internal Includes
29 #include <osvr/Common/Export.h>
31 
32 // Library/third-party includes
33 // - none
34 
35 // Standard includes
36 #include <stddef.h>
37 
38 namespace osvr {
39 namespace common {
40 
41 #ifndef OSVR_DOXYGEN_EXTERNAL
42  namespace detail {
44  AliasPriority priority;
45  };
46  template <typename T>
47  T &&operator<<(T &&os, AliasPriorityWrapper const &wrapper) {
48  switch (wrapper.priority) {
49  case ALIASPRIORITY_MINIMUM:
50  os << "Minimum (" << int(ALIASPRIORITY_MINIMUM) << ")";
51  break;
52 
53  case ALIASPRIORITY_AUTOMATIC:
54  os << "Automatic (" << int(ALIASPRIORITY_AUTOMATIC) << ")";
55  break;
56  case ALIASPRIORITY_SEMANTICROUTE:
57  os << "Semantic Route (" << int(ALIASPRIORITY_SEMANTICROUTE)
58  << ")";
59  break;
60  case ALIASPRIORITY_MANUAL:
61  os << "Manual/Max (" << int(ALIASPRIORITY_MANUAL) << ")";
62  break;
63  default:
64  os << int(ALIASPRIORITY_MANUAL);
65  break;
66  }
67  return os;
68  }
69  } // namespace detail
70 #endif
71 
74  inline detail::AliasPriorityWrapper outputPriority(AliasPriority priority) {
75  return detail::AliasPriorityWrapper{priority};
76  }
77 
78  namespace elements {
84  OSVR_COMMON_EXPORT const char *getTypeName(PathElement const &elt);
85 
87  template <typename ElementType> inline const char *getTypeName() {
88  return getTypeName(ElementType());
89  }
90 
95  void ifNullReplaceWith(PathElement &dest, PathElement const &src);
96 
98  bool isNull(PathElement const &elt);
99 
101  OSVR_COMMON_EXPORT size_t getMaxTypeNameLength();
102  } // namespace elements
103  using elements::getTypeName;
104 } // namespace common
105 } // namespace osvr
106 #endif // INCLUDED_PathElementTools_h_GUID_9246E2D5_1598_409F_BD30_1817FA2C1FB2
detail::AliasPriorityWrapper outputPriority(AliasPriority priority)
Helper method to output a priority in a formatted way to a stream.
size_t getMaxTypeNameLength()
Gets the length of the longest type name.
const char * getTypeName(PathElement const &elt)
Gets a string that indicates the type of path element. Do not use this for conditionals/comparisons u...
bool isNull(PathElement const &elt)
Returns true if the path element provided is a NullElement.
Namespace for the various element types that may constitute a node in the path tree.
void ifNullReplaceWith(PathElement &dest, PathElement const &src)
If dest is a NullElement, replace it with the provided src element.
Automatically-generated export header - do not edit!
boost::variant< NullElement, AliasElement, SensorElement, InterfaceElement, DeviceElement, PluginElement, StringElement > PathElement
The variant type containing a particular kind of path element.