Main Table of Contents


Table of Contents

class PtLockSpec
PtLockSpec: class summary
PtLockSpec::PtLockSpec()
PtLockSpec::~PtLockSpec()
PtLockSpec::Decode()
PtLockSpec::DeepMode()
PtLockSpec::Encode()
PtLockSpec::LockType()
PtLockSpec::Mode()
PtLockSpec::RetryNum()
PtLockSpec::operator = ()

class PtLockSpec


Intro
PtLockSpec: class summary
PtLockSpec::PtLockSpec()
PtLockSpec::~PtLockSpec()
PtLockSpec::Decode()
PtLockSpec::DeepMode()
PtLockSpec::Encode()
PtLockSpec::LockType()
PtLockSpec::Mode()
PtLockSpec::RetryNum()
PtLockSpec::operator = ()

A PtLockSpec is a lock specification; that is, it contains the parameters used to specify a lock. All methods that set locks or free locks take a PtLockSpec as a parameter.

Please see the chapter "Locking" for a complete set of the methods which use a PtLockSpec and for examples of setting and freeing locks.


PtLockSpec: class summary


Intro

Files to include Class declaration Base class
poet.hxx ptmode.hxx none

Member functions:

constructor PtLockSpec();
destructor ~PtLockSpec();
operator = PtLockSpec& operator = (PtLockSpec& );
Decode void Decode(PtLockEncode);
DeepMode inline PtDepthMode& DeepMode();
Encode int Encode(PtLockEncode& );
LockType inline PtLockType LockType();
Mode inline PtLockMode& Mode();
RetryNum inline unsigned short& RetryNum();

PtLockSpec::PtLockSpec()


Intro

Declarations:

PtLockSpec::PtLockSpec()
PtLockSpec::PtLockSpec(PtLockMode, PtDepthMode)
PtLockSpec::PtLockSpec(PtLockSpec& )

Each of these is discussed separately below.

Declaration:

PtLockSpec::PtLockSpec()

Description:

Constructor, no parameters specified. The PtLockSpec can not be used until these parameters are given.

Declaration:

PtLockSpec::PtLockSpec(PtLockMode, PtDepthMode)

Description:

Constructor, PtLockMode and PtDepthMode specified.

Declaration:

PtLockSpec::PtLockSpec(PtLockSpec& )

Description:

Copy constructor. This is used when a new PtLockSpec is created using new or on the stack. For instance, you could create three identical PtLockSpecs with the following code:

first PtLockSpec(PtLK_WRITEvWRITE, PtDEEP);
second PtLockSpec(first);
third *PtLockSpec = new PtLockSpec(second);

PtLockSpec::~PtLockSpec()


Intro

Declaration:

PtLockSpec::~PtLockSpec()

Description:

Destructor.


PtLockSpec::Decode()


Intro

Declaration:

void PtLockSpec::Decode(PtLockEncode)

Description:

This function is used internally by POET, and should not be used in your program.


PtLockSpec::DeepMode()


Intro

Declaration:

PtDepthMode& PtLockSpec::DeepMode()

Description:

Returns depth mode. See the chapter "Locking" for a list of valid depth modes.


PtLockSpec::Encode()


Intro

Declaration:

int PtLockSpec::Encode(PtLockEncode& )

Description:

This function is used internally by POET, and should not be used in your program.


PtLockSpec::LockType()


Intro

Syntax:

inline PtLockType PtLockSpec::LockType()

Description:

Returns the lock type to indicate whether the lock is a persistent lock. Lock types may be either of the following:

PtLK_NONPERS The lock is not persistent.
PtLK_PERS The lock is persistent.

Persistent locks are used internally for CheckIn/CheckOut.


PtLockSpec::Mode()


Intro

Declaration:

PtLockMode& PtLockSpec::Mode()

Description:

Returns lock mode. See the chapter "Locking" for a list of valid lock modes.


PtLockSpec::RetryNum()


Intro

Declaration:

inline unsigned short& PtLockSpec::RetryNum()

Description:

This function will not give your program any useful information. POET does not do retries on its locks.


PtLockSpec::operator = ()


Intro

Declarations:

PtLockSpec& PtLockSpec::operator = (PtLockSpec& )
PtLockSpec& PtLockSpec::operator = (PtLockMode mode)
PtLockSpec& PtLockSpec::operator = (PtDepthMode deep)

Each of these is discussed separately below.

Declaration:

PtLockSpec& PtLockSpec::operator = (PtLockSpec& )

Description:

Assignment operator. Sets both lock mode and depth mode to that of the PtLockSpec parameter.

Example:

PtLockSpec first, second, third(PtLK_WRITEvWRITE, PtSHALLOW);
first = second = third;

All three PtLockSpecs now have the parameters specified for third.

Declaration:

PtLockSpec& PtLockSpec::operator = (PtLockMode mode)

Description:

Assignment operator which sets only the lock mode.

Discussion:

Be careful when making multiple assignments in one statement - note the following example:

PtLockSpec first(PtLK_READvWRITE, PtDEEP);
PtLockSpec second(PtLK_READvWRITE, PtNO_ONDEMAND);
PtLockSpec third(PtLK_WRITEvWRITE, PtSHALLOW);
first = second = third = PtDELETEvWRITE;

Assignment operators group right-to-left. Therefore, the last statement in our example could also have been written like this:

(first = (second = (third = PtDELETEvWRITE)));

In the first assignment the lock mode for third is set to PtDELETEvWRITE, which is pretty much what you expect. The second assignment sets second to the new value of third. Because third is a PtLockSpec the operator that will be used has the form:

PtLockSpec & operator = ( PtLockSpec & );

Discussion:

This operator sets both the lock mode and the depth mode. Therefore, the first assignment sets only the lock mode, but the second sets both modes. At the end of the operation, all three PtLockSpecs contain the lock mode PtDELETEvWRITE and the depth mode PtSHALLOW.

Declaration:

PtLockSpec& PtLockSpec::operator = (PtDepthMode deep)

Description:

Assignment operator which sets only the depth mode. See the previous method for an example of the problems that can occur when making multiple assignments in one statement using this operator.

Copyright (c) 1996 POET Software, Inc. All rights reserved. Reproduction in whole or in part in any form or medium without the express permission of POET Software, Inc. is prohibited.