Skip to content

Commit

Permalink
Migrated RegistryInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Jul 20, 2017
1 parent f615e89 commit a12f3e0
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions plugins/script/interfaces/RegistryInterface.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef _REGISTRY_INTERFACE_H_
#define _REGISTRY_INTERFACE_H_
#pragma once

#include "iregistry.h"
#include "iscript.h"
#include <boost/python.hpp>
#include <pybind11/pybind11.h>

namespace script {
namespace script
{

/**
* greebo: This class provides the script interface for the GlobalRegistry module.
Expand All @@ -14,28 +14,27 @@ class RegistryInterface :
public IScriptInterface
{
public:
std::string get(const std::string& key) {
std::string get(const std::string& key)
{
return GlobalRegistry().get(key);
}

void set(const std::string& key, const std::string& value) {
void set(const std::string& key, const std::string& value)
{
GlobalRegistry().set(key, value);
}

// IScriptInterface implementation
void registerInterface(boost::python::object& nspace) {
void registerInterface(py::module& scope, py::dict& globals) override
{
// Add the module declaration to the given python namespace
nspace["GlobalRegistry"] = boost::python::class_<RegistryInterface>("GlobalRegistry")
.def("get", &RegistryInterface::get)
.def("set", &RegistryInterface::set)
;
py::class_<RegistryInterface> registry(scope, "Registry");
registry.def("get", &RegistryInterface::get);
registry.def("set", &RegistryInterface::set);

// Now point the Python variable "GlobalRegistry" to this instance
nspace["GlobalRegistry"] = boost::python::ptr(this);
globals["GlobalRegistry"] = this;
}
};
typedef std::shared_ptr<RegistryInterface> RegistryInterfacePtr;

} // namespace script

#endif /* _REGISTRY_INTERFACE_H_ */

0 comments on commit a12f3e0

Please sign in to comment.