[OPUS]

Osf_event - An event object created in response to an OSF blackboard event.


Availability:

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

Constructors:
Osf_event( )
~Osf_event( )

Methods:
clone( ) returns a copy of this object and sets the event trigger name and triggering entries
add_callback( ) assigns a callback function for this event type
process( ) calls Opus_env::close_event with Opus_env::IGNORE_EVENT if no callback is registered, // otherwise it calls the callback function
pstat_mesg( ) gets the Proc_stat object with which the process' PSTAT status field can be updated to indicate this event has occurred
lock_list( ) overrides the base class to update any changed OSF's

Description

This type of Event object is created for events on the OSF Blackboard. The client must register a callback function (using the static method add_callback) for this event type in order to process it (by default, the process method calls Opus_env::close_event with Opus_env::IGNORE_EVENT). A callback function foo must have a signature and return type of

     void foo(const string&, Event*, const Opus_env&) 
This function will be passed the trigger name as the first argument, a pointer to this event object as the second the first argument, a pointer to this event object as the second argument, and a reference to the process' Opus_env object as the third argument.

Derived from

Event

See Also:


Osf_event::Osf_event - The Osf_event constructor.

Synopsis


Osf_event::Osf_event(
                     Blackboard* bbrd) // I - pointer to OSF 
                                       //     Blackboard

Osf_event::Osf_event(
                     Blackboard* bbrd,        // I - pointer to OSF
                                              //     Blackboard
                     const string& s,         // I - Trigger name
                     const vector<Entry*>& v) // I - triggers

Description

These methods create either a Osf_event object to be used as a factory or in response to an actual event. In the former case, only the blackboard on which this event occurs need be specified-- the object can then be used to create clones whenever a real event occurs. In the case of a real event, the trigger name and the vector of entry objects that are responsible for the event also are specified.

Warning: no checks are made that the correct blackboard type and entry types are used as calling arguments.

Exceptions Thrown

none


Osf_event::~Osf_event - The Osf_event destructor.

Synopsis


Osf_event::~Osf_event()

Description

This method destroys the object.

Exceptions Thrown

none


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

Synopsis


Event* Osf_event::clone() const

Event* Osf_event::clone(
                            const string& s,         // I - Trigger name
                            const vector<Entry*>& v) // I - triggers
                            const

Description

These methods create a new Osf_event object off the heap using the constructor with the same signature. The caller should delete the new object when it is no longer needed.

Returns

    A pointer to the new Osf_event object.

Exceptions Thrown

none


Osf_event::pstat_mesg - Get Proc_stat object for updating the application's PSTAT status field.

Synopsis


Proc_stat* Osf_event::pstat_mesg() const

Description

This method returns a Proc_stat object containing the DATASET name of the first triggering entry. The caller should delete the Proc_stat object when it is no longer needed.

Returns

    A pointer to the Proc_stat object containing the DATASET name of

the first triggering entry in the event.

Exceptions Thrown

none


Osf_event::add_callback - Register the callback funtion for event processing.

Synopsis


void Osf_event::add_callback(
                             void (*pf)(const string&, // I - callback
                                        Event*, const Opus_env&))

Description

This method takes a function pointer that will serve as a callback function for all events of this type. The callback function foo must have a signature and return type of

     void foo(const string&, Event*, const Opus_env&) 
This method is static and specifies a callback function for all File_event objects until it is replaced.

Exceptions Thrown

none


Osf_event::process - Process this event.

Synopsis


void Osf_event::process(
                        const Opus_env& oenv) // I - Opus_env object

Description

This method calls the callback function if it has been set with the set_callback method. Otherwise, Opus_env::close_event is called with Opus_env::IGNORE_EVENT. The callback function will be passed the trigger name as the first argument, a pointer to this event object as the second argument, and a reference to the process' Opus_env object as the third argument.

Exceptions Thrown

[any exceptions thrown by the callback function]
Bad_val<Event*> - if the Event argument is NULL; Bad_val.arg contains the calling argument
Bad_val<string> - if the status is not found; Bad_val.arg contains the calling argument
Exec<vector<Event::iterator>> - if a failure occurs for any entry; Exec.arg contains a vector of iterators that point to the failed items


Osf_event::lock_list - Lock each Entry object in the event.

Synopsis


void Osf_event::lock_list(
                          vector<Opus_lock*>& locks, // O - OSF locks
                          iterator first,            // I - first OSF
                          iterator xlast)            // I - one past last
                                                     //     OSF

Description

This method overrides the base class implementation so that the list of OSF entries can be updated with the current blackboard values (which might have changed since when the event was triggered).

If any locks fail to be acquired, the corresponding Opus_lock* will be 0 and the OSF entry in the triggers list will be unchanged.

Exceptions Thrown

none


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