[OPUS]

File_pstat - A file name-based implementation of a Pstat object.


Availability:

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

Constructors:
File_pstat( )
~File_pstat( )

Methods:
clone( ) returns a copy of this object
operator==( ) overrides the base class implementation, adding wildcard support
str( ) overrides the base class implementation to format the output as a file name
search_mask( ) fills non-unique fields with search characters
search_fill_all( ) fills all field with search characters
assign( ) parses the file name into PSTAT fields

Description

This implementation of a Pstat object is used with File_pstat_bb blackboards that store their entries as file names on the file system. In general, clients of the OAPI do not instantiate objects of this class directly.

Derived from

Pstat

Example

  
    #include <iostream>
    #include "file_pstat_bb.h"
    #include "file_pstat.h"
    #include "pid.h"
    #include "node.h"
    #include "opus_lock.h"
  
    using namespace std;
  
    // The following example uses the File PSTAT Blackboard to find
    // an application's PSTAT on disk, then delete it.
    int main(int argc, char* argv[])
    {
                                              // constructor takes
                                              // OPUS_HOME_DIR path
       File_pstat_bb* pbb = new File_pstat_bb("/home/opus/pstats/");
       Pstat* fpstat      = pbb->new_pstat(); // padded except for Pid &
                                              // Node fields
  
       Pid* pid = new Pid(123);               // replace PID in PSTAT
       fpstat->set_field(pid);
       delete pid;
  
       Node* node = new Node("foo");          // replace NODE in PSTAT
       fpstat->set_field(node);
       delete node;
  
       fpstat->search_fill();                 // place search characters in
                                              // remaining fields
  
       vector<Entry*> res;
       if (pbb->search(fpstat, res)) {        // search for PSTAT
          Opus_lock* lck = 0;
          try {                               // attempt lock on PSTAT
             lck = pbb->lock_entry(res[0]);
             pbb->erase(res[0]);              // delete it
             cout << "Deleted PSTAT: " << fpstat->str() << endl;
          }
          catch(...) {
             cout << "Failed to delete PSTAT: " << res[0]->str()
                  << endl;
          }
          delete lck;                         // release & delete
          delete res[0];
       } else {
          cout << "Could not find PSTAT: " << fpstat->str() << endl;
       }
       delete fpstat;
       delete pbb;
       return(0);
    }
  

See Also:


File_pstat::File_pstat - The File_pstat constructor.

Synopsis


File_pstat::File_pstat() : templt(Bb_params_db::get_template("PSTAT"))

File_pstat::File_pstat(
                       const string& s) // I - file name containing PSTAT

File_pstat::File_pstat(
                       const char* fname) // I - file name containing PSTAT

File_pstat::File_pstat(
                       const File_pstat& fo) // I - File_pstat object to
                                             //     initialize from

Description

The constructor parses the file name argument, if provided, into PSTAT fields.

Exceptions Thrown

Bad_val<string> - if the file name fails to parse; Bad_val.arg contains a copy of the calling argument


File_pstat::~File_pstat - The File_pstat destructor.

Synopsis


File_pstat::~File_pstat()

Description

This method destroys the object.

Exceptions Thrown

none


File_pstat::clone - Create a copy of this object.

Synopsis


Entry* File_pstat::clone() const

Description

A new File_pstat object is constructed off the heap and initialized with the contents of this object, then returned to the caller. The client should delete the new object when it is no longer needed.

Returns

    A pointer to a new File_pstat object initialized with this object.

Exceptions Thrown

none


File_pstat::operator== - Compare the File_pstat object with another

Synopsis


bool File_pstat::operator==(
                            const Entry* e) // I - object to compare to
                            const

Description

This method overrides the base class implementation (which simply calls operator== for each field) to support filling of a field with wildcard characters. Two File_pstat objects are equal if the non-wildcarded portions of each 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 File_pstat objects are identical

false - if the File_pstat objects differ

Exceptions Thrown

Type<Entry*> - if the argument is not of type File_pstat; Type.arg points to the calling argument


File_pstat::str - Get the file name stored in the object.

Synopsis


string File_pstat::str() const

Description

This method overrides the base class implementation to format the field values in the PSTAT file name template.

Returns

    string file name containing the filled-in PSTAT template

Exceptions Thrown

none


File_pstat::search_fill_all - Fill each field with search characters.

Synopsis


void File_pstat::search_fill_all()

Description

This method fills each PSTAT field with single character wildcards.

Exceptions Thrown

none


File_pstat::search_mask - Fill non-unique fields with search characters.

Synopsis


void File_pstat::search_mask()

Description

This method fills each field except the Pid and the Node fields with single character wildcards.

Exceptions Thrown

none


File_pstat::assign - Parse a file name into PSTAT fields and assign them to this object.

Synopsis


void File_pstat::assign(
                        const string& s) // I - file name to parse

Description

This method extracts each field's value from the file name assuming that the field's ID indicates the starting position of that field in the file name string, then assigns it to the appropriate Field object.

Exceptions Thrown

Bad_val<string> - if the file name fails to parse; Bad_val.arg contains a copy of the calling argument


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