OSVR-Core
RouteContainer.h
Go to the documentation of this file.
1 
11 // Copyright 2015 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_RouteContainer_h_GUID_EA5F3FB5_13E4_4299_5B39_1C986BC8E784
26 #define INCLUDED_RouteContainer_h_GUID_EA5F3FB5_13E4_4299_5B39_1C986BC8E784
27 
28 // Internal Includes
29 #include <osvr/Common/Export.h>
30 
31 // Library/third-party includes
32 // - none
33 
34 // Standard includes
35 #include <vector>
36 #include <string>
37 
38 namespace osvr {
39 namespace common {
41  public:
43  OSVR_COMMON_EXPORT RouteContainer();
44 
46  OSVR_COMMON_EXPORT explicit RouteContainer(std::string const &routes);
47 
51  OSVR_COMMON_EXPORT bool addRoute(std::string const &routingDirective);
52 
55  OSVR_COMMON_EXPORT std::string getRoutes(bool styled = false) const;
56 
59  OSVR_COMMON_EXPORT std::string
60  getSource(std::string const &destination) const;
61 
62  OSVR_COMMON_EXPORT std::string getSourceAt(size_t i) const;
63 
64  OSVR_COMMON_EXPORT std::string getDestinationAt(size_t i) const;
65 
69  OSVR_COMMON_EXPORT std::string
70  getRouteForDestination(std::string const &destination) const;
71 
73  std::size_t size() const { return m_routingDirectives.size(); }
74 
75  std::vector<std::string> const &getRouteList() const {
76  return m_routingDirectives;
77  }
78 
81  OSVR_COMMON_EXPORT static std::string
82  getDestinationFromString(std::string const &route);
85  OSVR_COMMON_EXPORT static std::string
86  getSourceFromString(std::string const &route);
87 
88  private:
93  bool m_addRoute(std::string const &destination,
94  std::string const &directive);
95  std::vector<std::string> m_routingDirectives;
96  };
97 } // namespace common
98 } // namespace osvr
99 #endif // INCLUDED_RouteContainer_h_GUID_EA5F3FB5_13E4_4299_5B39_1C986BC8E784
static OSVR_COMMON_EXPORT std::string getDestinationFromString(std::string const &route)
Gets the destination of a route, given the route in string format.
Definition: RouteContainer.cpp:135
static OSVR_COMMON_EXPORT std::string getSourceFromString(std::string const &route)
Gets the source of a route, given the route in string format.
Definition: RouteContainer.cpp:138
Handles spatial transformations.
Definition: SerializationTraitExample_Complicated.h:40
OSVR_COMMON_EXPORT RouteContainer()
Empty constructor.
Definition: RouteContainer.cpp:68
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
OSVR_COMMON_EXPORT std::string getRouteForDestination(std::string const &destination) const
Get the full routing JSON string for a given destination path.
Definition: RouteContainer.cpp:120
std::size_t size() const
Gets the number of directives.
Definition: RouteContainer.h:73
OSVR_COMMON_EXPORT std::string getRoutes(bool styled=false) const
Get a JSON array of all routing directives.
Definition: RouteContainer.cpp:89
OSVR_COMMON_EXPORT std::string getSource(std::string const &destination) const
Get the source JSON string for a given destination path.
Definition: RouteContainer.cpp:101
Definition: RouteContainer.h:40
OSVR_COMMON_EXPORT bool addRoute(std::string const &routingDirective)
Register a JSON string as a routing directive.
Definition: RouteContainer.cpp:84