HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UN_WireUtils.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: UN_WireUtils.h ( UN Library, C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __UN_WireUtils_h__
13 #define __UN_WireUtils_h__
14 
15 
16 #include "UN_API.h"
17 #include "UN_GraphData.h"
18 
19 
20 namespace UN_WireUtils
21 {
22  /// Returns true if the wire by the given ID is valid in the given graph.
23  static inline bool
24  isValid( const UN_GraphData *graph_data, UN_WireID wire_id )
25  {
26  return graph_data && graph_data->isValid( wire_id );
27  }
28 
29  /// Returns the source port of this wire.
30  /// Ie, port that produces and sends the data.
31  static inline UN_PortID
32  srcPort( const UN_GraphData *graph_data, UN_WireID wire_id )
33  {
34  return graph_data ? graph_data->srcPort( wire_id ) : UN_PortID();
35  }
36 
37  /// Returns the destination port of this wire.
38  /// Ie, port that receives and consumes the data.
39  static inline UN_PortID
40  dstPort( const UN_GraphData *graph_data, UN_WireID wire_id )
41  {
42  return graph_data ? graph_data->dstPort( wire_id ) : UN_PortID();
43  }
44 
45  /// Returns the source node of this wire.
46  /// Ie, a node that produces and sends the data.
47  static inline UN_NodeID
48  srcNode( const UN_GraphData *graph_data, UN_WireID wire_id )
49  {
50  auto port = graph_data ? graph_data->srcPort( wire_id ) : UN_PortID();
51  return port ? graph_data->node( port ) : UN_NodeID();
52  }
53 
54  /// Returns the destination node of this wire.
55  /// Ie, a node that receives and consumes the data.
56  static inline UN_NodeID
57  dstNode( const UN_GraphData *graph_data, UN_WireID wire_id )
58  {
59  auto port = graph_data ? graph_data->dstPort( wire_id ) : UN_PortID();
60  return port ? graph_data->node( port ) : UN_NodeID();
61  }
62 }
63 
64 #endif
65 
bool isValid(UN_NodeID node) const
Definition: UN_GraphData.h:472
UN_NodeID node(UN_ParmID parm) const
Returns the owner node of the given parameter.
Definition: UN_GraphData.h:335
UN_PortID srcPort(UN_WireID wire) const
Definition: UN_GraphData.h:441
UN_PortID dstPort(UN_WireID wire) const
Definition: UN_GraphData.h:446