OSVR Framework (Internal Development Docs)  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
PluginSpecificRegistrationContext.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
28 #include <osvr/Util/Log.h>
29 
30 // Library/third-party includes
31 // - none
32 
33 // Standard includes
34 // - none
35 
36 namespace osvr {
37 namespace pluginhost {
38 
40 
42  PluginSpecificRegistrationContext::create(std::string const &name) {
43  PluginRegPtr pluginReg =
44  make_shared<PluginSpecificRegistrationContextImpl>(name);
45  return pluginReg;
46  }
47 
50  return *static_cast<PluginSpecificRegistrationContext *>(ctx);
51  }
52 
55  return static_cast<OSVR_PluginRegContext>(this);
56  }
57 
58  const std::string &PluginSpecificRegistrationContext::getName() const {
59  return m_name;
60  }
61 
63  std::string const &name)
64  : m_name(name), m_logger(util::log::make_logger(name)) {}
65 
66  void PluginSpecificRegistrationContext::log(util::log::LogLevel severity,
67  const char *message) {
68  m_logger->log(severity, message);
69  }
70 
71 } // namespace pluginhost
72 } // namespace osvr
Class providing the external interface of a registration context backing a single plugin...
const std::string & getName() const
Accessor for plugin name.
Header for basic internal log reference. To actually log to the produced loggers, include
PluginSpecificRegistrationContext(std::string const &name)
Constructor for derived class use only.
void log(util::log::LogLevel severity, const char *message)
Log a message to the plugin-specific channel.
OSVR_PluginRegContext extractOpaquePointer()
Extracts the opaque pointer for this interface to send to C.
OSVR_EXTERN_C_BEGIN typedef void * OSVR_PluginRegContext
A context pointer passed in to your plugin's entry point and other locations of control flow transfer...
shared_ptr< PluginSpecificRegistrationContextImpl > PluginRegPtr
Pointer with ownership semantics for cleanup of plugins.
Definition: PluginRegPtr.h:33
static PluginRegPtr create(std::string const &name)
Factory function that creates a plugin-specific registration context. Ownership is transferred to the...
static PluginSpecificRegistrationContext & get(OSVR_PluginRegContext ctx)
Retrieve this interface from an OSVR_PluginRegContext opaque pointer.