File: pipe.h

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 (110 lines) | stat: -rw-r--r-- 2,162 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
 * SPDX-FileCopyrightText: All Contributors to the PyTango project
 *
 * SPDX-License-Identifier: LGPL-3.0-or-later
 */

#pragma once

#include <boost/python.hpp>
#include <tango/tango.h>
#include "exception.h"
#include "pytgutils.h"
#include "server/device_impl.h"

namespace PyTango
{
namespace Pipe
{

class _Pipe
{
  public:
    _Pipe() { }

    virtual ~_Pipe() { }

    void read(Tango::DeviceImpl *, Tango::Pipe &);
    void write(Tango::DeviceImpl *dev, Tango::WPipe &);
    bool is_allowed(Tango::DeviceImpl *, Tango::PipeReqType);

    void set_allowed_name(const std::string &name)
    {
        py_allowed_name = name;
    }

    void set_read_name(const std::string &name)
    {
        read_name = name;
    }

    void set_write_name(const std::string &name)
    {
        write_name = name;
    }

    bool _is_method(Tango::DeviceImpl *, const std::string &);

  private:
    std::string py_allowed_name;
    std::string read_name;
    std::string write_name;
};

class PyPipe : public Tango::Pipe, public _Pipe
{
  public:
    PyPipe(const std::string &_name,
           const Tango::DispLevel level,
           const Tango::PipeWriteType write = Tango::PIPE_READ) :
        Tango::Pipe(_name, level, write)
    {
    }

    ~PyPipe() { }

    virtual void read(Tango::DeviceImpl *dev)
    {
        _Pipe::read(dev, *this);
    }

    virtual bool is_allowed(Tango::DeviceImpl *dev, Tango::PipeReqType rt)
    {
        return _Pipe::is_allowed(dev, rt);
    }
};

class PyWPipe : public Tango::WPipe, public _Pipe
{
  public:
    PyWPipe(const std::string &_name, const Tango::DispLevel level) :
        Tango::WPipe(_name, level)
    {
    }

    ~PyWPipe() { }

    virtual void read(Tango::DeviceImpl *dev)
    {
        _Pipe::read(dev, *this);
    }

    virtual void write(Tango::DeviceImpl *dev)
    {
        _Pipe::write(dev, *this);
    }

    virtual bool is_allowed(Tango::DeviceImpl *dev, Tango::PipeReqType rt)
    {
        return _Pipe::is_allowed(dev, rt);
    }
};

} // namespace Pipe
} // namespace PyTango

namespace PyDevicePipe
{
void set_value(Tango::DevicePipeBlob &, bopy::object &);

} // namespace PyDevicePipe