Teamcenter C++ API Reference  2312
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
Teamcenter::AcquireLock Class Reference

Manages a lock on an object. More...

#include <AcquireLock.hxx>

Public Member Functions

 AcquireLock ()
 
 AcquireLock (tag_t object)
 
void forget ()
 
bool isLocked () const
 
bool isLockedByMe () const
 
void lock (tag_t object)
 
virtual void unlock ()
 
virtual ~AcquireLock ()
 

Protected Attributes

bool m_bLockedPrior
 
tag_t m_lockedObj
 

Private Member Functions

 AcquireLock (const AcquireLock &other)
 
AcquireLockoperator= (const AcquireLock &other)
 

Detailed Description

Manages a lock on an object.

It obtains a write lock on an object.
This is required if the caller wish to save a modified version of the object or delete it.

It is a convenient C++ class wrapper to AOM_refresh.

Use this class where you would use AOM_refresh( tag, TRUE ).
It will ensure that the object will be unlocked when you go out of scope. So you do not have to remember to do an unlock on the object.

Use as follows:

try
{
AcquireLock lock( mytag );
// This will throw IFail Exception on failure to lock.
// Make sure caller has this nested in a high level try/catch block.
// Do the process and forget about unlocking the object, as it will automatically be done.
}
catch(const IFail&)
{
}

Definition at line 48 of file AcquireLock.hxx.

Constructor & Destructor Documentation

Teamcenter::AcquireLock::AcquireLock ( )

Constructor that does not lock any object.
The lock() method needs to be invoked to complete the lock on a given object.

Teamcenter::AcquireLock::AcquireLock ( tag_t  object)

Constructs the instance and locks the object.

Parameters
object(I) The object to lock.
virtual Teamcenter::AcquireLock::~AcquireLock ( )
virtual

Destructor.
Unlocks any locked object.

Teamcenter::AcquireLock::AcquireLock ( const AcquireLock other)
private

Copy constructor.

Member Function Documentation

void Teamcenter::AcquireLock::forget ( )

Skips the refresh of the objects, which means that the changes to the in-memory representation of the object will remain when the AcquireLock instance goes out of the C++ scope.

bool Teamcenter::AcquireLock::isLocked ( ) const

Returns the locking state of the underlying POM object.

bool Teamcenter::AcquireLock::isLockedByMe ( ) const

Determines if the underlying POM object has been locked by this instance.

void Teamcenter::AcquireLock::lock ( tag_t  object)

Locks the object.

Parameters
object(I) The object to lock.
AcquireLock& Teamcenter::AcquireLock::operator= ( const AcquireLock other)
private

Assignment operator.

virtual void Teamcenter::AcquireLock::unlock ( )
virtual

Unlocks any locked object.

Member Data Documentation

bool Teamcenter::AcquireLock::m_bLockedPrior
protected

The status of the object lock prior to being locked by this instance.

Definition at line 116 of file AcquireLock.hxx.

tag_t Teamcenter::AcquireLock::m_lockedObj
protected

The locked object

Definition at line 113 of file AcquireLock.hxx.


The documentation for this class was generated from the following file: