File: attribute_proxy.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 (95 lines) | stat: -rw-r--r-- 3,427 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
 * SPDX-FileCopyrightText: All Contributors to the PyTango project
 *
 * SPDX-License-Identifier: LGPL-3.0-or-later
 */

#include "precompiled_header.hpp"
#include "defs.h"
#include "pytgutils.h"

extern const char *param_must_be_seq;
extern const char *unreachable_code;
extern const char *non_string_seq;

namespace PyAttributeProxy
{
struct PickleSuite : bopy::pickle_suite
{
    static bopy::tuple getinitargs(Tango::AttributeProxy &self)
    {
        Tango::DeviceProxy *dev = self.get_device_proxy();

        std::string ret = dev->get_db_host() + ":" + dev->get_db_port() + "/" + dev->dev_name() + "/" + self.name();
        return bopy::make_tuple(ret);
    }
};

static boost::shared_ptr<Tango::AttributeProxy> makeAttributeProxy1(const std::string &name)
{
    AutoPythonAllowThreads guard;
    return boost::shared_ptr<Tango::AttributeProxy>(new Tango::AttributeProxy(name.c_str()), DeleterWithoutGIL());
}

static boost::shared_ptr<Tango::AttributeProxy> makeAttributeProxy2(const Tango::DeviceProxy *dev,
                                                                    const std::string &name)
{
    AutoPythonAllowThreads guard;
    return boost::shared_ptr<Tango::AttributeProxy>(new Tango::AttributeProxy(dev, name.c_str()), DeleterWithoutGIL());
}
} // namespace PyAttributeProxy

void export_attribute_proxy()
{
    bopy::class_<Tango::AttributeProxy> AttributeProxy("__AttributeProxy", bopy::init<const Tango::AttributeProxy &>());

    AttributeProxy.def("__init__", bopy::make_constructor(PyAttributeProxy::makeAttributeProxy1))
        .def("__init__", bopy::make_constructor(PyAttributeProxy::makeAttributeProxy2))

        //
        // Pickle
        //
        .def_pickle(PyAttributeProxy::PickleSuite())

        //
        // general methods
        //

        .def("name", &Tango::AttributeProxy::name, (arg_("self")))

        .def("get_device_proxy",
             &Tango::AttributeProxy::get_device_proxy,
             (arg_("self")),
             bopy::return_internal_reference<1>())

        //
        // property methods
        //
        .def("_get_property",
             (void(Tango::AttributeProxy::*)(const std::string &, Tango::DbData &)) &
                 Tango::AttributeProxy::get_property,
             (arg_("self"), arg_("propname"), arg_("propdata")))

        .def("_get_property",
             (void(Tango::AttributeProxy::*)(const std::vector<std::string> &, Tango::DbData &)) &
                 Tango::AttributeProxy::get_property,
             (arg_("self"), arg_("propnames"), arg_("propdata")))

        .def("_get_property",
             (void(Tango::AttributeProxy::*)(Tango::DbData &)) & Tango::AttributeProxy::get_property,
             (arg_("self"), arg_("propdata")))

        .def("_put_property", &Tango::AttributeProxy::put_property, (arg_("self"), arg_("propdata")))

        .def("_delete_property",
             (void(Tango::AttributeProxy::*)(const std::string &)) & Tango::AttributeProxy::delete_property,
             (arg_("self"), arg_("propname")))

        .def("_delete_property",
             (void(Tango::AttributeProxy::*)(const StdStringVector &)) & Tango::AttributeProxy::delete_property,
             (arg_("self"), arg_("propnames")))

        .def("_delete_property",
             (void(Tango::AttributeProxy::*)(const Tango::DbData &)) & Tango::AttributeProxy::delete_property,
             (arg_("self"), arg_("propdata")));
}