SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Port.h
Go to the documentation of this file.
1 /*
2  For more information, please see: http://software.sci.utah.edu
3 
4  The MIT License
5 
6  Copyright (c) 2012 Scientific Computing and Imaging Institute,
7  University of Utah.
8 
9  License for the specific language governing rights and limitations under
10  Permission is hereby granted, free of charge, to any person obtaining a
11  copy of this software and associated documentation files (the "Software"),
12  to deal in the Software without restriction, including without limitation
13  the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  and/or sell copies of the Software, and to permit persons to whom the
15  Software is furnished to do so, subject to the following conditions:
16 
17  The above copyright notice and this permission notice shall be included
18  in all copies or substantial portions of the Software.
19 
20  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  DEALINGS IN THE SOFTWARE.
27 */
28 
29 /// @todo Documentation Dataflow/Network/Port.h
30 
31 
32 #ifndef DATAFLOW_NETWORK_PORT_H
33 #define DATAFLOW_NETWORK_PORT_H
34 
35 #include <string>
36 #include <vector>
37 #include <boost/noncopyable.hpp>
38 #include <boost/signals2/signal.hpp>
41 #include <Dataflow/Network/share.h>
42 
43 namespace SCIRun {
44 namespace Dataflow {
45 namespace Networks {
46 
47 class SCISHARE Port : virtual public PortInterface, boost::noncopyable
48 {
49 public:
51  {
53  std::string type_name, port_name;
54  bool isDynamic_;
55  ConstructionParams(const PortId& id, const std::string& type, bool isDynamic)
56  : id_(id), type_name(type), port_name(id.name), isDynamic_(isDynamic) {}
57  };
58  Port(ModuleInterface* module, const ConstructionParams& params);
59  virtual ~Port();
60 
61  size_t nconnections() const;
62  const Connection* connection(size_t) const;
63 
64  virtual PortId id() const { return id_; }
65  std::string get_typename() const { return typeName_; }
66  std::string get_colorname() const { return colorName_; }
67  std::string get_portname() const { return portName_; }
68 
69  virtual void attach(Connection* conn);
70  virtual void detach(Connection* conn);
71 
72  virtual ModuleId getUnderlyingModuleId() const;
73  virtual size_t getIndex() const;
74  virtual void setIndex(size_t index);
75 
76  /// @todo:
77  // light interface
78 
79 protected:
81  std::vector<Connection*> connections_;
82  size_t index_;
84 
85  const std::string typeName_;
86  const std::string portName_;
87  const std::string colorName_;
88 };
89 
90 #ifdef WIN32
91 #pragma warning (push)
92 #pragma warning (disable : 4250)
93 #endif
94 
95 /// @todo: discuss this interface design
96 class SCISHARE InputPort : public Port, public InputPortInterface
97 {
98 public:
100  virtual ~InputPort();
101  virtual void attach(Connection* conn);
102  virtual DatatypeSinkInterfaceHandle sink() const;
103  virtual Core::Datatypes::DatatypeHandleOption getData() const;
104  virtual bool isInput() const { return true; } //boo
105  virtual bool isDynamic() const { return isDynamic_; }
106  virtual InputPortInterface* clone() const;
107  virtual bool hasChanged() const;
108  virtual boost::signals2::connection connectDataOnPortHasChanged(const DataOnPortHasChangedSignalType::slot_type& subscriber);
109 private:
111  bool isDynamic_;
112 };
113 
114 
116 {
117 public:
119  virtual ~OutputPort();
120  virtual void sendData(Core::Datatypes::DatatypeHandle data);
121  virtual bool isInput() const { return false; } //boo
122  virtual bool isDynamic() const { return false; } /// @todo: design dynamic output ports
123 private:
125 };
126 
127 #ifdef WIN32
128 #pragma warning (pop)
129 #endif
130 
131 }}}
132 
133 #endif
boost::optional< DatatypeHandle > DatatypeHandleOption
Definition: DatatypeFwd.h:47
std::string get_colorname() const
Definition: Port.h:66
Definition: ModuleInterface.h:81
PortId id_
Definition: Port.h:83
#define SCISHARE
Definition: share.h:39
Definition: PortInterface.h:62
const std::string colorName_
Definition: Port.h:87
const char * name[]
Definition: BoostGraphExampleTests.cc:87
virtual bool isInput() const
Definition: Port.h:121
std::string type_name
Definition: Port.h:53
Definition: ModuleDescription.h:77
dictionary data
Definition: eabLatVolData.py:11
boost::shared_ptr< DatatypeSourceInterface > DatatypeSourceInterfaceHandle
Definition: NetworkFwd.h:83
const std::string portName_
Definition: Port.h:86
ModuleInterface * module_
Definition: Port.h:80
std::string get_portname() const
Definition: Port.h:67
boost::shared_ptr< DatatypeSinkInterface > DatatypeSinkInterfaceHandle
Definition: NetworkFwd.h:82
const std::string typeName_
Definition: Port.h:85
size_t index_
Definition: Port.h:82
virtual bool isDynamic() const
Definition: Port.h:122
virtual bool isInput() const
Definition: Port.h:104
ConstructionParams(const PortId &id, const std::string &type, bool isDynamic)
Definition: Port.h:55
std::vector< Connection * > connections_
Definition: Port.h:81
Definition: ModuleDescription.h:45
virtual PortId id() const
Definition: Port.h:64
boost::shared_ptr< Datatype > DatatypeHandle
Definition: DatatypeFwd.h:44
std::string get_typename() const
Definition: Port.h:65
virtual bool isDynamic() const
Definition: Port.h:105
Definition: Connection.h:42