OSVR Framework (Internal Development Docs)  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
CreateContext.cpp
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 // Internal Includes
27 #include "PureClientContext.h"
28 #include "AnalysisClientContext.h"
29 #include <osvr/Util/Verbosity.h>
30 
31 // Library/third-party includes
32 // - none
33 
34 // Standard includes
35 #include <cstring>
36 
37 namespace osvr {
38 namespace client {
39  common::ClientContext *createContext(const char appId[],
40  const char host[]) {
41  common::ClientContext *ret = nullptr;
42  if (!appId || std::strlen(appId) == 0) {
43  OSVR_DEV_VERBOSE("Could not create client context - null or empty "
44  "appId provided!");
45  return ret;
46  }
47  ret = common::makeContext<PureClientContext>(appId, host);
48  return ret;
49  }
50 
51  common::ClientContext *
52  createAnalysisClientContext(const char appId[], const char host[],
53  vrpn_ConnectionPtr const &conn) {
54  common::ClientContext *ret = nullptr;
55  if (!appId || !appId[0]) {
56  OSVR_DEV_VERBOSE("Could not create analysis client context - null "
57  "or empty appId provided!");
58  return ret;
59  }
60 
61  if (!host || !host[0]) {
62  OSVR_DEV_VERBOSE("Could not create analysis client context - null "
63  "or empty host provided!");
64  return ret;
65  }
66 
67  if (!conn) {
68  OSVR_DEV_VERBOSE("Could not create analysis client context - null "
69  "connection provided!");
70  return ret;
71  }
72 
73  ret = common::makeContext<AnalysisClientContext>(appId, host, conn);
74  return ret;
75  }
76 
77 } // namespace client
78 } // namespace osvr
Internal, configured header file for verbosity macros.