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  myWriteLock(false),
38  myLayerLock(false)
39  {
40  }
42  { }
43 
44  bool isLocked() const
45  { return myLockCount > 0; }
46  bool isReadLocked() const
47  { return myLockCount > 0 && !myWriteLock; }
48  bool isWriteLocked() const
49  { return myLockCount > 0 && myWriteLock; }
50  bool isLayerLocked() const
51  { return myLockCount > 0 && myLayerLock; }
52  int getLockedNodeId() const
53  { return myLockedNodeId; }
54 
55 private:
56  UT_Lock myMutex;
57  int myLockCount;
58  int myLockedNodeId;
59  bool myWriteLock;
60  bool myLayerLock;
61 
62  friend class ::HUSD_DataHandle;
63 };
64 
66 
67 #endif
68 
bool isReadLocked() const
Definition: XUSD_DataLock.h:46
#define OP_INVALID_ITEM_ID
Definition: OP_ItemId.h:23
bool isLocked() const
Definition: XUSD_DataLock.h:44
int getLockedNodeId() const
Definition: XUSD_DataLock.h:52
A reference counter base class for use with UT_IntrusivePtr.
bool isWriteLocked() const
Definition: XUSD_DataLock.h:48
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1346
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:83
bool isLayerLocked() const
Definition: XUSD_DataLock.h:50