Logo ROOT  
Reference Guide
TGLLockable.h
Go to the documentation of this file.
1// @(#)root/gl:$Id$
2// Author: Matevz Tadel, Feb 2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TGLLockable_H
13#define ROOT_TGLLockable_H
14
15#include <Rtypes.h>
16
18{
19public:
20 enum ELock { kUnlocked, // Unlocked
21 kDrawLock, // Locked for draw, cannot select or modify
22 kSelectLock, // Locked for select, cannot modify (draw part of select)
23 kModifyLock // Locked for modify, cannot draw or select
24 };
25
26private:
27 TGLLockable(const TGLLockable&); // Not implemented
28 TGLLockable& operator=(const TGLLockable&); // Not implemented
29
30protected:
31 // Locking - can take/release via const handle
32 mutable ELock fLock; // Lock state.
33
34 // Ensures unlocking in view of exceptions.
36 {
37 private:
38 TUnlocker(const TUnlocker&); // Not implemented
39 TUnlocker& operator=(const TUnlocker&); // Not implemented
40
42
43 public:
46 {
47 if (fLockable->IsLocked())
49 }
50 };
51
52public:
54 virtual ~TGLLockable() {}
55
56 virtual const char* LockIdStr() const { return "<unknown>"; }
57
58 Bool_t TakeLock(ELock lock) const;
59 Bool_t ReleaseLock(ELock lock) const;
60 Bool_t IsLocked() const { return (fLock != kUnlocked); }
61 ELock CurrentLock() const { return fLock; }
62
64
65 static const char * LockName(ELock lock);
66 static Bool_t LockValid(ELock lock);
67
68 ClassDef(TGLLockable, 0); // Lock for viewers and scenes.
69}; // endclass TGLLockable
70
71#endif
bool Bool_t
Definition: RtypesCore.h:59
#define ClassDef(name, id)
Definition: Rtypes.h:326
TUnlocker(const TGLLockable *l)
Definition: TGLLockable.h:44
TUnlocker & operator=(const TUnlocker &)
TUnlocker(const TUnlocker &)
const TGLLockable * fLockable
Definition: TGLLockable.h:41
Simple locking interface used by viewer and scene.
Definition: TGLLockable.h:18
virtual ~TGLLockable()
Definition: TGLLockable.h:54
ELock fLock
Definition: TGLLockable.h:32
TGLLockable & operator=(const TGLLockable &)
Bool_t TakeLock(ELock lock) const
Lock the object in mode 'lock'.
Definition: TGLLockable.cxx:32
TGLLockable(const TGLLockable &)
ELock CurrentLock() const
Definition: TGLLockable.h:61
Bool_t ReleaseLock(ELock lock) const
Release current lock, make sure it the same as the 'lock' argument.
Definition: TGLLockable.cxx:51
static const char * LockName(ELock lock)
Return name-string for given lock-type.
Definition: TGLLockable.cxx:69
virtual const char * LockIdStr() const
Definition: TGLLockable.h:56
static Bool_t LockValid(ELock lock)
Test if lock is a valid type to take/release.
Definition: TGLLockable.cxx:85
Bool_t IsLocked() const
Definition: TGLLockable.h:60
Bool_t IsDrawOrSelectLock() const
Definition: TGLLockable.h:63
auto * l
Definition: textangle.C:4