File: api_util.cpp

package info (click to toggle)
pytango 10.0.2-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 10,216 kB
  • sloc: python: 28,206; cpp: 16,380; sql: 255; sh: 82; makefile: 43
file content (62 lines) | stat: -rw-r--r-- 1,960 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
 * SPDX-FileCopyrightText: All Contributors to the PyTango project
 *
 * SPDX-License-Identifier: LGPL-3.0-or-later
 */

#include "precompiled_header.hpp"
#include <tango/tango.h>
#include "pyutils.h"

namespace PyApiUtil
{
inline bopy::object get_env_var(const char *name)
{
    std::string value;
    if(Tango::ApiUtil::get_env_var(name, value) == 0)
    {
        return bopy::str(value);
    }
    return bopy::object();
}

inline void get_asynch_replies1(Tango::ApiUtil &self)
{
    AutoPythonAllowThreads guard;
    self.get_asynch_replies();
}

inline void get_asynch_replies2(Tango::ApiUtil &self, long timeout)
{
    AutoPythonAllowThreads guard;
    self.get_asynch_replies(timeout);
}
}; // namespace PyApiUtil

void export_api_util()
{
    bopy::class_<Tango::ApiUtil, boost::noncopyable>("ApiUtil", bopy::no_init)

        .def("instance", &Tango::ApiUtil::instance, bopy::return_value_policy<bopy::reference_existing_object>())
        .staticmethod("instance")

        .def("pending_asynch_call", &Tango::ApiUtil::pending_asynch_call)

        .def("get_asynch_replies", &PyApiUtil::get_asynch_replies1)
        .def("get_asynch_replies", &PyApiUtil::get_asynch_replies2)

        .def("set_asynch_cb_sub_model", &Tango::ApiUtil::set_asynch_cb_sub_model)
        .def("get_asynch_cb_sub_model", &Tango::ApiUtil::get_asynch_cb_sub_model)

        .def("get_env_var", &PyApiUtil::get_env_var)
        .staticmethod("get_env_var")

        .def("is_notifd_event_consumer_created", &Tango::ApiUtil::is_notifd_event_consumer_created)
        .def("is_zmq_event_consumer_created", &Tango::ApiUtil::is_zmq_event_consumer_created)
        .def("get_user_connect_timeout", &Tango::ApiUtil::get_user_connect_timeout)

        .def("in_server", (bool(Tango::ApiUtil::*)()) & Tango::ApiUtil::in_server)
        .def("get_ip_from_if", &Tango::ApiUtil::get_ip_from_if)
        .def("cleanup", &Tango::ApiUtil::cleanup)
        .staticmethod("cleanup");
}