59a508c92e9d62e539af651c9dbd53a37da43fee
[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 Abstract 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
42   std::string           d_port_name;
43   pmt_t                 d_protocol_class;
44   bool                  d_conjugated;
45   port_type_t           d_port_type;
46
47 protected:
48   mb_mblock            *d_mblock;  // mblock we're defined in
49
50   // protected constructor
51   mb_port(mb_mblock *mblock,
52           const std::string &port_name,
53           const std::string &protocol_class_name,
54           bool conjugated,
55           mb_port::port_type_t port_type);
56
57 public:
58   std::string   port_name() const { return d_port_name; }
59   pmt_t         protocol_class() const { return d_protocol_class; }
60   bool          conjugated() const { return d_conjugated; }
61   port_type_t   port_type() const { return d_port_type; }
62
63   pmt_t         incoming_message_set() const;
64   pmt_t         outgoing_message_set() const;
65
66   virtual ~mb_port();
67
68   /*!
69    * \brief send a message
70    *
71    * \param signal      the event name
72    * \param data        optional data
73    * \param metadata    optional metadata
74    * \param priority    the urgency at which the message is sent
75    */
76   virtual void
77   send(pmt_t signal,
78        pmt_t data = PMT_NIL,
79        pmt_t metadata = PMT_NIL,
80        mb_pri_t priority = MB_PRI_DEFAULT) = 0;
81 };
82
83 #endif /* INCLUDED_MB_PORT_H */