OSVR-Core
AliasProcessor.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_AliasProcessor_h_GUID_9C10FB5E_F8B9_44BB_BCF4_9E50FFBFA1C9
26 #define INCLUDED_AliasProcessor_h_GUID_9C10FB5E_F8B9_44BB_BCF4_9E50FFBFA1C9
27 
28 // Internal Includes
29 #include <osvr/Common/Export.h>
32 
33 // Library/third-party includes
34 #include <json/value.h>
35 
36 // Standard includes
37 // - none
38 
39 namespace osvr {
40 namespace common {
41  namespace detail {
44  bool permitRelativePath = false;
45  bool permitRelativeSource = false;
46  bool permitWildcard = false;
47  AliasPriority defaultPriority = ALIASPRIORITY_AUTOMATIC;
48  };
49  } // namespace detail
50 
55  OSVR_COMMON_EXPORT Json::Value convertRouteToAlias(Json::Value const &val);
56 
62  OSVR_COMMON_EXPORT Json::Value
63  createJSONAlias(std::string const &path, Json::Value const &destination);
64 
68  OSVR_COMMON_EXPORT Json::Value
69  applyPriorityToAlias(Json::Value const &alias, AliasPriority priority);
70 
83  public:
89  AliasProcessor &enableRelativePath() {
90  m_opts.permitRelativePath = true;
91  return *this;
92  }
93 
96  m_opts.permitRelativeSource = true;
97  return *this;
98  }
99 
102  m_opts.permitWildcard = true;
103  return *this;
104  }
105 
107  AliasProcessor &setDefaultPriority(AliasPriority prio) {
108  m_opts.defaultPriority = prio;
109  return *this;
110  }
112 
123  OSVR_COMMON_EXPORT bool process(PathNode &node, Json::Value const &val);
125  private:
127  };
128 } // namespace common
129 } // namespace osvr
130 #endif // INCLUDED_AliasProcessor_h_GUID_9C10FB5E_F8B9_44BB_BCF4_9E50FFBFA1C9
A short-lived class for setting up options then processing alias directives to apply to a path tree...
Definition: AliasProcessor.h:82
Handles spatial transformations.
Definition: SerializationTraitExample_Complicated.h:40
A node in a generic tree, which can contain an object by value.
Definition: TreeNode.h:72
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
Options struct for internal usage by AliasProcessor.
Definition: AliasProcessor.h:43
OSVR_COMMON_EXPORT Json::Value convertRouteToAlias(Json::Value const &val)
Given a single JSON object, if it&#39;s an old-fashioned "routing directive", convert it to a normal "ali...
Definition: AliasProcessor.cpp:220
Definition: newuoa.h:1888
OSVR_COMMON_EXPORT Json::Value applyPriorityToAlias(Json::Value const &alias, AliasPriority priority)
Given a JSON object describing one or more aliases, set the priority of the alias(es).
Definition: AliasProcessor.cpp:235
AliasProcessor & enableWildcard()
Turn on permitWildcard in a chained method.
Definition: AliasProcessor.h:101
AliasProcessor & enableRelativeSource()
Turn on permitRelativeSource in a chained method.
Definition: AliasProcessor.h:95
AliasProcessor & setDefaultPriority(AliasPriority prio)
Set defaultPriority in a chained method.
Definition: AliasProcessor.h:107
Header forward-declaring the types in PathElementTypes.h and including the PathElement typedef...
OSVR_COMMON_EXPORT Json::Value createJSONAlias(std::string const &path, Json::Value const &destination)
Given a path and a destination, combine them into a JSON alias description.
Definition: AliasProcessor.cpp:206