HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OP_ItemId.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: OP_ItemId.h (OP Library, C++)
7  *
8  * COMMENTS: Simple encapsulation of the two values needed to uniquely
9  * identify any OP_NetworkBoxItem in a Houdini session.
10  */
11 
12 #ifndef __OP_ItemId__
13 #define __OP_ItemId__
14 
15 #include "OP_API.h"
16 #include <UT/UT_Set.h>
17 #include <UT/UT_Array.h>
18 
19 #define OP_INVALID_ITEM_ID -999
20 
21 class OP_NetworkBoxItem;
22 
24 {
25  OP_ITEMTYPE_NODE = 0x00000001, // OP_Node
26  OP_ITEMTYPE_INDIRECT = 0x00000002, // OP_SubnetIndirectInput
27  OP_ITEMTYPE_NETWORKBOX = 0x00000004, // OP_NetworkBox
28  OP_ITEMTYPE_POSTIT_NOTE = 0x00000008, // OP_PostIt
29  OP_ITEMTYPE_DOT = 0x00000010, // OP_Dot
30 
31  OP_ITEMTYPE_INVALID = 0x00000000,
32  OP_ITEMTYPE_ALL = 0xFFFFFFFF,
34 };
35 
36 /// This mask is used as a type to encompass all possible combinations of
37 /// OP_ItemType.
38 typedef unsigned int OP_ItemTypeMask;
39 
41 {
42 public:
43  OP_ItemId();
44  OP_ItemId(OP_ItemType item_type, int64 item_id);
45  OP_ItemId(const OP_NetworkBoxItem &item);
46  OP_ItemId(const OP_NetworkBoxItem *item);
47 
48  bool operator==(const OP_ItemId &other) const
49  { return myItemType == other.myItemType &&
50  myItemId == other.myItemId; }
51  bool operator!=(const OP_ItemId &other) const
52  { return myItemType != other.myItemType ||
53  myItemId != other.myItemId; }
54 
55  bool isValid() const
56  { return myItemType != OP_ITEMTYPE_INVALID &&
57  myItemId != OP_INVALID_ITEM_ID; }
58 
61 };
62 
63 inline uint64 hash_value(const OP_ItemId &id)
64 { return SYSwang_inthash64(id.myItemType) ^ SYSwang_inthash64(id.myItemId); }
65 
68 
69 #endif
70 
#define OP_INVALID_ITEM_ID
Definition: OP_ItemId.h:19
uint64 hash_value(const OP_ItemId &id)
Definition: OP_ItemId.h:63
OP_ItemType
Definition: OP_ItemId.h:23
long long int64
Definition: SYS_Types.h:100
unsigned long long uint64
Definition: SYS_Types.h:101
int64 myItemId
Definition: OP_ItemId.h:60
bool isValid() const
Definition: OP_ItemId.h:55
OP_ItemType myItemType
Definition: OP_ItemId.h:59
UT_Array< OP_ItemId > OP_ItemIdList
Definition: OP_ItemId.h:66
UT_Set< OP_ItemId > OP_ItemIdSet
Definition: OP_ItemId.h:67
unsigned int OP_ItemTypeMask
Definition: OP_ItemId.h:38
#define OP_API
Definition: OP_API.h:10
bool operator==(const OP_ItemId &other) const
Definition: OP_ItemId.h:48
bool operator!=(const OP_ItemId &other) const
Definition: OP_ItemId.h:51