[OPUS]

File_osf - A file name-based implementation of an Osf object.


Availability:

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

Constructors:
File_osf( )
~File_osf( )

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 fields with search characters
assign( ) parses the file name into OSF fields

Description

This implementation of an Osf object is used with File_osf_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

Osf

Example

  
    #include <iostream>
    #include "file_osf_bb.h"
    #include "file_osf.h"
    #include "dataset.h"
    #include "data_id.h"
    #include "time_stamp.h"
    #include "opus_lock.h"
  
    using namespace std;
  
    // The following example uses the File OSF Blackboard to find
    // an OSF on disk, then delete it.
    int main(int argc, char* argv[])
    {
       File_osf_bb* obb = new File_osf_bb("/home/opus/sci_osfs/");
       Osf* fosf        = obb->new_osf();       // padded except
                                                // for time stamp
  
       fosf->search_fill_all();                 // place search characters
                                                // in all fields
  
       Dataset* dat = new Dataset("N12345678"); // set DATASET field
       fosf->set_field(dat);
       delete dat;
       Data_id* did = new Data_id("SCI");       // set DATA_ID field
       fosf->set_field(did);
       delete did;
  
       vector<Entry*> res;
       if (obb->search(fosf, res)) {            // search for OSF
          Opus_lock* lck = 0;
          try {                                 // attempt lock on OSF
             lck = obb->lock_entry(res[0]);
             obb->erase(res[0]);                // delete it
             cout << "Deleted OSF: " << fosf->str() << endl;
          }
          catch(...) {
             cout << "Failed to delete OSF: " << res[0]->str()
                  << endl;
          }
          delete lck;                           // release & delete
          delete res[0];
       } else {
          cout << "Could not find OSF: " << fosf->str() << endl;
       }
       delete fosf;
       delete obb;
       return(0);
    }
  

See Also:


File_osf::File_osf - The File_osf constructor.

Synopsis


File_osf::File_osf() : templt(Bb_params_db::get_template("OSF"))

File_osf::File_osf(
                   const string& s) // I - file name containing OSF

File_osf::File_osf(
                   const char* fname) // I - file name containing OSF

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

Description

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

Exceptions Thrown

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


File_osf::~File_osf - The File_osf destructor.

Synopsis


File_osf::~File_osf()

Description

This method destroys the object.

Exceptions Thrown

none


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

Synopsis


Entry* File_osf::clone() const

Description

A new File_osf 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_osf object initialized with this object.

Exceptions Thrown

none


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

Synopsis


bool File_osf::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_osf objects are equal if the non-wildcarded portions of each are identical.

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

Returns

    true  - if the File_osf objects are identical

false - if the File_osf objects differ

Exceptions Thrown

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


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

Synopsis


string File_osf::str() const

Description

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

Returns

    string file name containing the filled-in OSF template

Exceptions Thrown

none


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

Synopsis


void File_osf::search_fill_all()

Description

This method fills each OSF field with single character wildcards.

Exceptions Thrown

none


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

Synopsis


void File_osf::search_mask()

Description

This method fills each field except the Time_stamp and Dataset fields with single character wildcards.

Exceptions Thrown

none


File_osf::assign - Parse a file name into OSF fields and assign them to this object.

Synopsis


void File_osf::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