HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UN_Wire.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_Wire.h ( UN Library, C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __UN_Wire_h__
13 #define __UN_Wire_h__
14 
15 #include "UN_API.h"
16 #include "UN_Handle.h"
17 
18 class UN_Graph;
19 class UN_Port;
20 
21 
22 // ============================================================================
23 /// A light-weight handle for a wire that connects two ports together.
24 ///
25 /// The actual wire data (UN_WireData) is owned and managed by UN_GraphData,
26 /// and UN_Wire serves as a handle for the client to refer to that data.
27 
28 class UN_API UN_Wire : public UN_Handle
29 {
30 public:
31  /// Convenience constructor for the wire handle.
32  UN_Wire( UN_GraphData *graph_data,
33  UN_WireIndex wire_index,
34  UN_WireID wire_id );
35 
36  /// @{ Default constructors and assignment operators.
37  UN_Wire();
38  ~UN_Wire();
39  UN_Wire( const UN_Wire& other );
40  UN_Wire( UN_Wire&& other );
41  UN_Wire & operator=( const UN_Wire& other );
42  UN_Wire & operator=( UN_Wire&& other );
43  /// @}
44 
45  /// @{ Returns true if this is a valid wire; false otherwise.
46  bool isValid() const;
47  explicit operator bool() const
48  { return isValid(); }
49  /// @}
50 
51  /// @{ Comparison operators
52  bool operator==( const UN_Wire &other ) const
53  { return UN_Handle::operator==( other ); }
54  bool operator!=( const UN_Wire &other ) const
55  { return UN_Handle::operator!=( other ); }
56  /// @}
57 
58 
59  /// Returns the owner graph of this wire.
60  UN_Graph graph() const;
61 
62  /// Returns the source port of this wire.
63  /// (ie, port that produces and sends the data).
64  UN_Port sourcePort() const;
65 
66  /// Returns the destination port of this wire.
67  /// (ie, port that receives and consumes the data).
68  UN_Port destinationPort() const;
69 
70 
71  /// Returns the wire data index this handle refers to.
73  { return UN_WireIndex( dataIndex() ); }
74 
75  /// Returns the unique ID of the wire data this handle refers to.
76  UN_WireID wireID() const
77  { return UN_WireID( dataID() ); }
78 };
79 
80 #endif
81 
UN_DataID dataID() const
The unique ID of a data object during the lifespan of the owner graph.
Definition: UN_Handle.h:74
A wire ID.
Definition: UN_Types.h:285
#define UN_API
Definition: UN_API.h:11
bool operator==(const UN_Handle &other) const
Comparison operators.
Definition: UN_Handle.h:53
UN_DataIndex dataIndex() const
Definition: UN_Handle.h:70
UN_WireID wireID() const
Returns the unique ID of the wire data this handle refers to.
Definition: UN_Wire.h:76
bool operator!=(const UN_Handle &other) const
Comparison operators.
Definition: UN_Handle.h:60
UN_Handle & operator=(const UN_Handle &)=default
Default destructor, constructors and assignment operators.
bool operator!=(const UN_Wire &other) const
Comparison operators.
Definition: UN_Wire.h:54
UN_WireIndex wireIndex() const
Returns the wire data index this handle refers to.
Definition: UN_Wire.h:72
bool operator==(const UN_Wire &other) const
Comparison operators.
Definition: UN_Wire.h:52