HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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_Array.h>
17 
18 // These constants come in handy when a client is storing OP_Node ids and
19 // then polling for a node using OP_Node::lookupNode(id), and they need to
20 // specify that their stored id is currently invalid, i.e. if the
21 // corresponding node was deleted. This can obviously also be used for
22 // other things
23 #define OP_INVALID_ITEM_ID -999
24 #define OP_INVALID_NODE_ID OP_INVALID_ITEM_ID
25 
26 class OP_NetworkBoxItem;
27 
29 {
30  OP_ITEMTYPE_NODE = 0x00000001, // OP_Node
31  OP_ITEMTYPE_INDIRECT = 0x00000002, // OP_SubnetIndirectInput
32  OP_ITEMTYPE_NETWORKBOX = 0x00000004, // OP_NetworkBox
33  OP_ITEMTYPE_POSTIT_NOTE = 0x00000008, // OP_PostIt
34  OP_ITEMTYPE_DOT = 0x00000010, // OP_Dot
35 
36  OP_ITEMTYPE_INVALID = 0x00000000,
37  OP_ITEMTYPE_ALL = 0xFFFFFFFF,
39 };
40 
41 /// This mask is used as a type to encompass all possible combinations of
42 /// OP_ItemType.
43 typedef unsigned int OP_ItemTypeMask;
44 
46 {
47 public:
48  OP_ItemId();
49  OP_ItemId(OP_ItemType item_type, int64 item_id);
50  OP_ItemId(const OP_NetworkBoxItem &item);
51  OP_ItemId(const OP_NetworkBoxItem *item);
52 
53  bool operator==(const OP_ItemId &other) const
54  { return myItemType == other.myItemType &&
55  myItemId == other.myItemId; }
56  bool operator!=(const OP_ItemId &other) const
57  { return myItemType != other.myItemType ||
58  myItemId != other.myItemId; }
59 
60  bool isValid() const
61  { return myItemType != OP_ITEMTYPE_INVALID &&
62  myItemId != OP_INVALID_ITEM_ID; }
63 
66 };
67 
68 inline uint64 hash_value(const OP_ItemId &id)
69 { return SYSwang_inthash64(id.myItemType) ^ SYSwang_inthash64(id.myItemId); }
70 
72 
73 #endif
74 
#define OP_INVALID_ITEM_ID
Definition: OP_ItemId.h:23
uint64 hash_value(const OP_ItemId &id)
Definition: OP_ItemId.h:68
unsigned long long uint64
Definition: SYS_Types.h:117
OP_ItemType
Definition: OP_ItemId.h:28
int64 myItemId
Definition: OP_ItemId.h:65
bool isValid() const
Definition: OP_ItemId.h:60
OP_ItemType myItemType
Definition: OP_ItemId.h:64
UT_Array< OP_ItemId > OP_ItemIdList
Definition: OP_ItemId.h:71
long long int64
Definition: SYS_Types.h:116
unsigned int OP_ItemTypeMask
Definition: OP_ItemId.h:43
#define OP_API
Definition: OP_API.h:10
bool operator==(const OP_ItemId &other) const
Definition: OP_ItemId.h:53
bool operator!=(const OP_ItemId &other) const
Definition: OP_ItemId.h:56