[OPUS]

File_osf_lock - Opus_lock object for file name-based OSF's.


Availability:

This class is available for the OPUS Blackboard API. The initial OPUS 2.0 release is described here

Constructors:
File_osf_lock( )
~File_osf_lock( )

Methods:
assign( ) sets the target file
lock( ) locks the target file
release( ) releases the lock
operator==( ) tests locks for equality
get_target( ) gets copy of locked OSF file as a File_osf object

Description

This class manages lock files for OSF entries that are stored on the file system. A masked version of the target file name is stored in a subdirectory of the OSF blackboard directory and serves as the lock. The mask pads all fields except the unique, identifying fields in each entry (the Dataset and Time_stamp fields). Because the mask does not contain all of the information in the target OSF file name, a copy of the locked file name at the time the lock is obtained is maintained by this object for reference.

Derived from

Osf_lock, private Opus_lock_file

See Also:


File_osf_lock::File_osf_lock - The File_osf_lock object constructor.

Synopsis


File_osf_lock::File_osf_lock() : locked_ent(0)

File_osf_lock::File_osf_lock(
                             const File_osf* ent,   // I - OSF file to lock
                             const string& dir)     // I - directory
                                                    //     containing the
                                                    //     OSF files

Description

The constructor creates an Opus_lock_file object for the indicated OSF file, if supplied.

Exceptions Thrown

Bad_val<string> - if the string does not appear to be a directory specification or invalid characters are present; Bad_val.arg contains the calling argument
Io_error<int> - if a problem occurs determining the current working directory; Io_error.arg contains the value of errno
Bad_val<string> - if the string contains invalid characters; Bad_val.arg contains the calling argument
Bad_val<string> - if the extension prefix is not present or invalid characters are present; Bad_val.arg contains the calling argument
Bad_val<string> - if dangle prefix is not present or invalid characters are present; Bad_val.arg contains the calling argument
Io_error<int> - if an IO error occurs creation of the lock directory; Io_error.arg contains the value of errno
Bad_val<Entry*> - if the first argument is null; Bad_val.arg points to the first argument


File_osf_lock::~File_osf_lock - The File_osf_lock object destructor.

Synopsis


File_osf_lock::~File_osf_lock()

Description

The destructor destroys the object and deletes its internal copy of the target File_osf object.

Exceptions Thrown

none


File_osf_lock::lock - Attempt to lock the OSF file.

Synopsis


void File_osf_lock::lock()

Description

An attempt is made to lock the target file up to three times.

Exceptions Thrown

Locked<string> - if the target file is locked already; Locked.arg contains the target name
Io_error<int> - if an IO error occurs during the lock attempt; Io_error.arg contains the value of errno
Bad_val<string> - if the stretch cannot be resolved; Bad_val.arg contains the stretched file name
Bad_val<vector<string>> - if the calling arguments are incorrect; Bad_val.arg is a vector containing the calling arguments
Io_error<int> - if the disk space check fails; Io_error.arg contains the value of errno
Bad_val<vector<string>> - if calling arguments are incorrect; Bad_val.arg is a vector containing the calling arguments
Exec<int> - if the subprocess spawn attempt fails; Exec.arg contains the return status from the spawn attemp
Bad_val<string> - if the string does not appear to be a directory specification or invalid characters are present; Bad_val.arg contains the calling argument
Io_error<int> - if a problem occurs determining the current working directory; Io_error.arg contains the value of errno
Bad_val<string> - if the string contains invalid characters; Bad_val.arg contains the calling argument
Bad_val<string> - if the extension prefix is not present or invalid characters are present; Bad_val.arg contains the calling argument
Bad_val<string> - if dangle prefix is not present or invalid characters are present; Bad_val.arg contains the calling argument
Io_error<int> - if an IO error occurs creation of the lock directory; Io_error.arg contains the value of errno


File_osf_lock::release - Release lock on OSF file.

Synopsis


void File_osf_lock::release()

Description

This method deletes the lock file, if one is present and the file is locked.

Exceptions Thrown

Io_error<int> - if an IO error occurs during delete; Io_error.arg contains the value of errno


File_osf_lock::operator== - Compare the File_osf_lock object with another.

Synopsis


bool File_osf_lock::operator==(
                               const Opus_lock* ol) // I - lock to compare
                                                    //     to
                               const

Description

This operator compares the object with the File_osf_lock object argument. Two File_osf_lock objects are equal if the lock file names are identical.

***Note that a pointer (not a reference) to the object with which the comparison is to be made is required.

Returns

    true  - if the locks are identical

false - if the locks are not identical

Exceptions Thrown

none


File_osf_lock::get_target - Get a copy of the target OSF file as a File_osf object.

Synopsis


Osf* File_osf_lock::get_target() const

Description

A copy of the locked File_osf object is fetched off disk (if necessary) and a copy is constructed off the heap and returned to the caller. The target must be locked prior to calling this method. The client should delete the new object when it is no longer needed.

Returns

    The File_osf object that is the target of this lock.

Exceptions Thrown

Io_error<const char*> - if an I/O occurs while locating the OSF; Io_error.arg contains the I/O error message
Not_ready<void*> - if the target has not been locked; Not_ready.arg points to null.


OPUS API index · STScI Home Page · Search · Topics · Index

Copyright © 1997-2000 The Association of Universities for Research in Astronomy, Inc. All Rights Reserved.


For more information, contact opushelp@stsci.edu

Last modified: 25 April 2000