[OPUS]

Absolute_time_bb - A blackboard whose entries are absolute, wall-clock times.


Availability:

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

Constructors:
Absolute_time_bb( )
~Absolute_time_bb( )

Methods:
post( ) no-op
erase( ) no-op
replace( ) no-op
search( ) checks if the time in the search condition is in the past or the future
lock_entry( ) no-op
str( ) gets blackboard name
new_time( ) creates a new Time_entry object that contains an Absolute_time field
test_driver( ) runs the test driver

Description

This blackboard object is an abstraction of the system clock. That is, the entries stored on the blackboard are clock ticks at one second resolution. It is not possible to manipulate entries on this blackboard. Instead, a Time_entry object containing an Absolute_time field is sent as the "search condition" to the search method. If the Absolute_time embedded time is in the past, the search method returns as if the search was successful (indeed, that time is on the blackboard since all times past are entries on this blackboard) by returning 1 and by placing a clone of the search condition in the results vector. If the time in the search condition is in the future, the search fails. As such, this object acts like a timer that triggers when the absolute time passed to its search method has been reached.

Derived from

Blackboard

Example

  
    #include <iostream>
    #include <vector>
    #include "absolute_time_bb.h"
    #include "entry.h"
    #include "time_entry.h"
  
    using namespace std;
  
    // The following example uses the Absolute Time Blackboard to
    // determine whether it is past noon yet.
    int main(int argc, char* argv[])
    {
       Absolute_time_bb abb;
       Time_entry* t_ent = abb.new_time("12:00:00"); // place noon
                                                     // today in new
                                                     // time entry
  
       vector<Entry*> results;                       // results vector
       if (abb.search(t_ent, results)) {             // it's past noon
          cout << "It's past noon." << endl;
          delete results[0];                         // delete result
       } else {
          cout << "It's not noon yet." << endl;
       }
       delete t_ent;                                 // delete search
                                                     // condition
       return(0);
    }
  

See Also:


Absolute_time_bb::Absolute_time_bb - The Absolute_time_bb constructor.

Synopsis


Absolute_time_bb::Absolute_time_bb()

Description

This method constructs an instance of the absolute time blackboard.

Exceptions Thrown

none


Absolute_time_bb::~Absolute_time_bb - The Absolute_time_bb destructor.

Synopsis


Absolute_time_bb::~Absolute_time_bb()

Description

This method destroys the object.

Exceptions Thrown

none


Absolute_time_bb::post - none

Synopsis


void Absolute_time_bb::post(
                            const Entry* e)

Description

A diagnostic message is produced indicating that this function is a no-op.

Exceptions Thrown

none


Absolute_time_bb::erase - none

Synopsis


void Absolute_time_bb::erase(
                             const Entry* e)

Description

A diagnostic message is produced indicating that this function is a no-op.

Exceptions Thrown

none


Absolute_time_bb::replace - none

Synopsis


void Absolute_time_bb::replace(
                               const Entry* old_ent,
                               const Entry* new_ent)

Description

A diagnostic message is produced indicating that this function is a no-op.

Exceptions Thrown

none


Absolute_time_bb::search - Compare the current system time with the Time_entry time value.

Synopsis


int Absolute_time_bb::search(
                             const Entry* e,      // I - Time_entry with
                                                  //     Absolute_time 
                             vector<Entry*>& res) // I - results vector
                             const

Description

A comparison is made between the current system time and the time embedded in the first argument's Absolute_time field. If the time is in the past, the first argument is cloned and the copy is pushed onto the vector second argument. This copy is allocated off the heap and should be deleted by the caller once the object is no longer needed. If the time is in the future, nothing is pushed onto the vector second argument.

Returns

    The size of the vector second argument just prior to returning.

Exceptions Thrown

Bad_val<Entry*> - if the first argument is null; Bad_val.arg points to the first argument
Type<Entry*> - if the first argument is not of type Time_entry; Type.arg points to the first argument

Example

  
    Absolute_time_bb abb;
    Time_entry* t_ent = abb.new_time("12:00:00"); // place 12:00 PM
                                                  // today in new
                                                  // time entry
  
    vector<Entry*> results;                       // results vector
    if (abb.search(t_ent, results)) {             // it's past noon
       cout << "It's past noon." << endl;
       delete results[0];                         // delete result
    } else {
       cout << "It's not noon yet." << endl;
    }
    delete t_ent;                                 // delete search
  


Absolute_time_bb::new_time - Create a new Time_entry object containing an Absolute_time field.

Synopsis


Time_entry* Absolute_time_bb::new_time() const

Time_entry* Absolute_time_bb::new_time(
                                       const time_t t) // I - seconds since
                                       const           //     00:00 Jan. 1,
                                                       //     1970

Time_entry* Absolute_time_bb::new_time(
                                       const string& t) // I - string of
                                       const            //     the form
                                                        // YYYY.DDD.HH:MM:SS
                                                        // or HH:MM:SS

Description

This method creates a new Time_entry object containing an Absolute_time field. If a string argument is provided,it must be in the format YYYY.DDD.HH:MM:SS, or HH:MM:SS, where YYYY is the year, DDD is the day of the year [0-365], HH is the hour[0-23], MM is the minute [0-59], and SS is the second[0-61] with which to initialize the Absolute_time field. A time_t value (seconds since the epoch) also can be provided as the field initializer. If no argument is provided, the current time is placed in the Absolute_time object.

Returns

    A pointer to the new Time_entry object.

Exceptions Thrown

none

Example

  
    Absolute_time_bb abb;
    Time_entry* t_ent = abb.new_time("1998.234.13:34:12");
  


Absolute_time_bb::lock_entry - none.

Synopsis


Opus_lock* Absolute_time_bb::lock_entry(
                                        const Entry* e)

Description

Locking of entries on the absolute time blackboard is not meaningful, so this method creates a Null_lock object off the heap and returns a pointer to it instead. The caller should delete the object when it is no longer needed.

Returns

    A pointer to a Null_lock object.

Exceptions Thrown

none


Absolute_time_bb::str - Get the blackboard name.

Synopsis


string Absolute_time_bb::str() const

Description

This method returns a string describing the absolute time blackboard.

Returns

    string containing the blackboard name

Exceptions Thrown

none

Example

  
    Absolute_time_bb abb;
    cout << "The absolute time blackboard name is: " << abb.str() << endl;
  


Absolute_time_bb::test_driver - Test the absolute time blackboard implementation.

Synopsis


bool Absolute_time_bb::test_driver()

Description

This method exercises the absolute time blackboard methods. Diagnostic output is sent to cerr. If all of the tests pass, this method returns true. Otherwise, it returns false. All exceptions generated during the test are caught and reported.

Returns

    true  - if all tests pass

false - if one or more of the tests fail

Exceptions Thrown

none

Example

  
    Absolute_time_bb atbb;
    cout << "Running the Absolute Time Blackboard test driver." << endl;
    if (atbb.test_driver()) cout << "Pass." << endl;
    else                    cout << "Fail." << endl;
    

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