35ac34e2c6738a1abef2300efd74ae7da06d8f52
[debian/gnuradio] / mblock / src / lib / mb_port.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2006 Free Software Foundation, Inc.
4  * 
5  * This file is part of GNU Radio
6  * 
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  * 
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 #ifndef INCLUDED_MB_PORT_H
22 #define INCLUDED_MB_PORT_H
23
24 #include <mb_common.h>
25
26 /*!
27  * \brief Public port characteristics
28  */
29 class mb_port : boost::noncopyable
30 {
31 public:
32
33   //! port classification
34   enum port_type_t {
35     EXTERNAL,   //< Externally visible
36     RELAY,      //< Externally visible but really connected to a sub-component
37     INTERNAL    //< Visible to self only
38   };
39
40 private:
41   friend class mb_mblock_impl;
42
43   mb_port_detail_sptr   d_detail;
44   std::string           d_port_name;
45   pmt_t                 d_protocol_class;
46   bool                  d_conjugated;
47   port_type_t           d_port_type;
48
49   // private constructor
50   mb_port(const std::string &port_name,
51                 const std::string &protocol_class_name,
52                 bool conjugated,
53                 mb_port::port_type_t port_type);
54
55
56 public:
57   std::string   port_name() const { return d_port_name; }
58   pmt_t         protocol_class() const { return d_protocol_class; }
59   bool          conjugated() const { return d_conjugated; }
60   port_type_t   port_type() const { return d_port_type; }
61
62   pmt_t         incoming_message_set() const;
63   pmt_t         outgoing_message_set() const;
64
65   ~mb_port();
66
67   /*!
68    * \brief send a message
69    *
70    * \param signal      the event name
71    * \param data        optional data
72    * \param metadata    optional metadata
73    * \param priority    the urgency at which the message is sent
74    */
75   void
76   send(pmt_t signal,
77        pmt_t data = PMT_NIL,
78        pmt_t metadata = PMT_NIL,
79        mb_pri_t priority = MB_PRI_DEFAULT);
80
81 };
82
83 #endif /* INCLUDED_MB_PORT_H */