HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
XUSD_DataLock.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Side Effects Software Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #ifndef __XUSD_DataLock_h__
19 #define __XUSD_DataLock_h__
20 
21 #include "HUSD_API.h"
22 #include <OP/OP_ItemId.h>
23 #include <UT/UT_IntrusivePtr.h>
24 #include <UT/UT_Lock.h>
25 #include <UT/UT_String.h>
26 #include <UT/UT_StringHolder.h>
27 #include <pxr/pxr.h>
28 
30 
31 class XUSD_DataLock : public UT_IntrusiveRefCounter<XUSD_DataLock>
32 {
33 public:
35  : myLockCount(0),
36  myLockedNodeId(OP_INVALID_ITEM_ID),
37  myLastLockedNodeId(OP_INVALID_ITEM_ID),
38  myWriteLock(false),
39  myLayerLock(false)
40  {
41  }
43  { }
44 
45  bool isLocked() const
46  { return myLockCount > 0; }
47  bool isReadLocked() const
48  { return myLockCount > 0 && !myWriteLock; }
49  bool isWriteLocked() const
50  { return myLockCount > 0 && myWriteLock; }
51  bool isLayerLocked() const
52  { return myLockCount > 0 && myLayerLock; }
53  int getLockedNodeId() const
54  { return myLockedNodeId; }
55  int getLastLockedNodeId() const
56  { return myLastLockedNodeId; }
57 
58 private:
59  UT_Lock myMutex;
60  int myLockCount;
61  int myLockedNodeId;
62  int myLastLockedNodeId;
63  bool myWriteLock;
64  bool myLayerLock;
65 
66  friend class ::HUSD_DataHandle;
67 };
68 
70 
71 #endif
72 
bool isReadLocked() const
Definition: XUSD_DataLock.h:47
#define OP_INVALID_ITEM_ID
Definition: OP_ItemId.h:23
bool isLocked() const
Definition: XUSD_DataLock.h:45
int getLockedNodeId() const
Definition: XUSD_DataLock.h:53
A reference counter base class for use with UT_IntrusivePtr.
bool isWriteLocked() const
Definition: XUSD_DataLock.h:49
int getLastLockedNodeId() const
Definition: XUSD_DataLock.h:55
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
bool isLayerLocked() const
Definition: XUSD_DataLock.h:51