HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UNI_Port.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UNI_Port.h ( UNI Library, C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __UNI_Port_h__
13 #define __UNI_Port_h__
14 
15 #include "UNI_API.h"
16 #include "UNI_Item.h"
17 
18 // ============================================================================
19 class UNI_ConstPort : public UNI_ConstItem<UNI_PortID>
20 {
21 public:
22  /// Expose base class constructors.
24 
25  /// Returns the UNI_Node that owns this port.
26  UNI_NodeID node() const
27  {
28  return graph() ? graph()->ownerNode(id()) : UNI_NodeID();
29  }
30 
31  /// Returns what kind of a port this is: input or output.
33  {
34  return graph() ? graph()->portKind(id()) : UNI_PortKind::Invalid;
35  }
36 
37  /// Returns the label for the port.
39  {
40  return graph() ? graph()->label(id()) : UT_StringHolder();
41  }
42 
43  /// Returns the name of the port.
45  {
46  return graph() ? graph()->name(id()) : UT_StringHolder();
47  }
48 
49  /// Return true if the port name can be changed.
50  bool canSetName() const
51  {
52  return graph() ? graph()->canSetName(id()) : false;
53  }
54 
55  /// Returns the name of the data type for the given port.
57  {
58  return graph() ? graph()->typeName(id()) : UT_StringHolder();
59  }
60 
61  /// Returns the name of the UI color for the given port.
62  /// The color name adheres to the UIgetMiscColor() conventions.
64  {
65  return graph() ? graph()->colorName(id()) : UT_StringHolder();
66  }
67 
68  /// Returns the UI shape of the port socket.
70  {
71  return graph() ? graph()->shape(id()) : UNI_PortShape::Default;
72  }
73 
74  /// Return wires that are sources to this port (where this port is the
75  /// destination of the wire).
76  UNI_WireIDList srcWires() const
77  {
78  return graph() ? graph()->srcWires(id()) : UNI_WireIDList();
79  }
80 
81  /// Return wires that are destinations from this port (where this port is
82  /// the source of the wire).
83  UNI_WireIDList dstWires() const
84  {
85  return graph() ? graph()->dstWires(id()) : UNI_WireIDList();
86  }
87 };
88 
89 
90 // ============================================================================
91 class UNI_API UNI_Port : public UNI_Item<UNI_PortID,
92  UNI_SessionPortID,
93  UNI_ConstPort>
94 {
95 public:
96  /// Expose base class constructors.
97  using UNI_Item::UNI_Item;
98 
99  /// Set the name of a port, if allowed.
100  void setName(const UT_StringHolder &name);
101 
102  /// Connect a new source to this port (which is the destination).
103  UNI_WireID addSrc(UNI_PortID src);
104 
105  /// Ensures the node signatures and port types are up-to-date for
106  /// all the nodes downstream of the given port.
107  /// If @p update_port is true, the given port is updated too.
108  void updateDownstreamPortTypes( bool update_port ) const;
109 };
110 
111 #endif
virtual UNI_WireIDList srcWires(UNI_PortID port_id) const =0
Return the wires that connect to a given port.
virtual UNI_PortKind portKind(UNI_PortID port_id) const =0
Returns what kind of a port this is: input or output.
UNI_NodeID node() const
Returns the UNI_Node that owns this port.
Definition: UNI_Port.h:26
virtual UT_StringHolder colorName(UNI_PortID port_id) const =0
UNI_PortKind portKind() const
Returns what kind of a port this is: input or output.
Definition: UNI_Port.h:32
virtual UNI_WireIDList dstWires(UNI_PortID port_id) const =0
Return the wires that connect to a given port.
#define UNI_API
Definition: UNI_API.h:11
UT_StringHolder colorName() const
Definition: UNI_Port.h:63
UNI_WireIDList dstWires() const
Definition: UNI_Port.h:83
virtual UNI_PortShape shape(UNI_PortID port_id) const =0
Returns the visual shape of the port in the UI.
virtual UT_StringHolder name() const =0
UNI_PortKind
Specifies the port kind, ie, wheter it is an input or an output port.
Definition: UNI_Include.h:21
GLuint const GLchar * name
Definition: glcorearb.h:786
virtual UNI_NodeID ownerNode(UNI_PortID port_id) const =0
bool canSetName() const
Return true if the port name can be changed.
Definition: UNI_Port.h:50
UNI_PortShape shape() const
Returns the UI shape of the port socket.
Definition: UNI_Port.h:69
UNI_WireIDList srcWires() const
Definition: UNI_Port.h:76
UNI_Item()=default
Constructor.
UT_StringHolder label() const
Returns the label for the port.
Definition: UNI_Port.h:38
UNI_PortShape
Specifies the visual shape of the port in the UI.
Definition: UNI_Include.h:29
virtual UT_StringHolder typeName(UNI_NodeID node_id) const =0
The type name of the node.
UT_StringHolder typeName() const
Returns the name of the data type for the given port.
Definition: UNI_Port.h:56
const UNI_Graph * graph() const
Returns the graph inside which the node lives.
Definition: UNI_Item.h:44
virtual bool canSetName(UNI_PortID port_id) const =0
Some graphs support setting port names.
UT_StringHolder name() const
Returns the name of the port.
Definition: UNI_Port.h:44
UNI_ConstItem()=default
Constructor.
virtual UT_StringHolder label(UNI_PortID port_id) const =0
The label of the port. Some ports can be renamed.
GLenum src
Definition: glcorearb.h:1793