Exemplo n.º 1
0
/***********************************************************************
 * Comparison registration handling
 **********************************************************************/
static void handleHashFcnPluginEvent(const Pothos::Plugin &plugin, const std::string &event)
{
    poco_debug_f2(Poco::Logger::get("Pothos.Object.handleHashFcnPluginEvent"), "plugin %s, event %s", plugin.toString(), event);
    POTHOS_EXCEPTION_TRY
    {
        //validate the plugin -- if we want to handle it -- check the signature:
        if (plugin.getObject().type() != typeid(Pothos::Callable)) return;
        const auto &call = plugin.getObject().extract<Pothos::Callable>();
        if (call.type(-1) != typeid(size_t)) return;
        if (call.getNumArgs() != 1) return;

        Poco::RWLock::ScopedWriteLock lock(getMapMutex());
        if (event == "add")
        {
            getHashFcnMap()[call.type(0).hash_code()] = plugin;
        }
        if (event == "remove")
        {
            getHashFcnMap()[call.type(0).hash_code()] = Pothos::Plugin();
        }
    }
    POTHOS_EXCEPTION_CATCH(const Pothos::Exception &ex)
    {
        poco_error_f3(Poco::Logger::get("Pothos.Object.handleHashFcnPluginEvent"),
            "exception %s, plugin %s, event %s", ex.displayText(), plugin.toString(), event);
    }
Exemplo n.º 2
0
static void handlePythonPluginEvent(const Pothos::Plugin &plugin, const std::string &event)
{
    if (event == "remove" and plugin.getPath() == Pothos::PluginPath("/proxy_helpers/python/pyobject_to_proxy"))
    {
        myPythonProxyEnv.reset();
        myPyObjectToProxyFcn = PyObjectToProxyFcn();
        Pothos::PluginRegistry::remove("/proxy/converters/python/proxy_to_pyproxy");
    }
    if (event == "remove" and plugin.getPath() == Pothos::PluginPath("/proxy_helpers/python/proxy_to_pyobject"))
    {
        myPythonProxyEnv.reset();
        myProxyToPyObjectFcn = ProxyToPyObjectFcn();
        Pothos::PluginRegistry::remove("/proxy/converters/python/pyproxy_to_proxy");
    }
}
Exemplo n.º 3
0
static void callPluginEventHandler(const Pothos::Object &handler, const Pothos::Plugin &plugin, const std::string &event)
{
    if (not canObjectHandleEvent(handler)) return;
    POTHOS_EXCEPTION_TRY
    {
        handler.extract<Pothos::Callable>().callVoid(plugin, event);
    }
    POTHOS_EXCEPTION_CATCH(const Pothos::Exception &ex)
    {
        poco_error_f3(Poco::Logger::get("Pothos.PluginRegistry.handlePluginEvent"),
        "exception %s, plugin %s, event %s", ex.displayText(), plugin.toString(), event);
    }