This class is available for the OPUS Blackboard API. The initial OPUS 2.0 release is described here
Constructors:
Opus_env( ) | |
~Opus_env( ) |
Methods:
is_initialized( ) | is object constructed? |
get_app_name( ) | get application name |
is_db_update_allowed( ) | can process update database? |
is_interactive( ) | is process interactive? |
get_polling_time( ) | get polling time |
get_encrypt_passwd( ) | get encrypted passwd |
get_decrypt_passwd( ) | get decrypted passwd |
get_option( ) | get command line option |
get_num_args( ) | get number of args |
get_arg( ) | get command line arg |
get_path_name( ) | get path name |
get_path_item( ) | get path file item |
get_res_item( ) | get resource file item |
get_res_class( ) | get resource file class |
get_env_item( ) | get environment variable |
get_stage_title( ) | get nth stage title |
get_stage_position( ) | get stage position |
set_path( ) | reset path |
load_resource_file( ) | read a process resource file |
poll( ) | poll blackboards |
new_osf( ) | create new OSF |
post_osf( ) | post OSF on blackboard |
erase_osf( ) | delete OSF on blackboard |
replace_osf( ) | replace OSF on blackboard |
find_osf( ) | find OSF |
lock_osf( ) | place lock on OSF |
apply_status( ) | update entry status |
new_pstat( ) | create new PSTAT |
lock_pstat( ) | place lock on PSTAT |
post_pstat( ) | post PSTAT on blackboard |
erase_pstat( ) | delete PSTAT on blackboard |
replace_pstat( ) | replace PSTAT on blackboard |
find_pstat( ) | find PSTAT |
get_appl_pstat( ) | get application's PSTAT |
update_proc_status( ) | update PSTAT status field |
close_event( ) | apply end of event state |
reinit( ) | reinitialize |
new_com_trig( ) | create new Command trigger & Command |
remove_com_trig( ) | delete Command trigger |
find_modifier( ) | locate modifier |
journal_roll_back( ) | attempt to mark journal entries absent |
test_driver( ) | test implementation |
Data Members:
static const std::string IGNORE_EVENT; // modifier name for ignored events static const std::string ODEFDIR; // OPUS definitions directory symbol static const std::string OHOMEDIR; // OPUS home directory symbol static const std::string OOBSDIR; // OPUS observations directory symbol
Description
Opus_env establishes the OPUS environment for an application which includes command line argument parsing and creation of the appropriate blackboard implementations. It also acts as the primary interface to OPUS services. Only one instance of this object can be instantiated per process.
Example
#include <iostream> #include "opus_env.h" #include "opus_lock.h" #include "event.h" #include "halt_event.h" #include "reinit_event.h" #include "file_event.h" #include "osf_event.h" #include "time_event.h" #include "msg.h" #include "opus_exceptions.h" using namespace std; // event handlers void time_event_process(const string&, const Event*, const Opus_env&); void halt_event_process(const string&, const Event*, const Opus_env&); void file_event_process(const string&, const Event*, const Opus_env&); void cmd_event_process(const string&, const Event*, const Opus_env&); void reinit_event_process(const string&, const Event*, const Opus_env&); void osf_event_process(const string&, const Event*, const Opus_env&); // define an object to throw at HALT events class Done { }; // The following example is a simple shell application that uses // the OAPI. It initializes OPUS, then begins polling. Each event // handler prints out the Entry's that triggered it. A HALT event // terminates the application. int main(int argc, char* argv[]) { Msg m; m.set_rpt_level(Msg::ALL); Opus_env opus(argc, argv); if (!opus.is_initialized()) { m << sev(Msg::F) << "Failed to construct Opus_env." << endm; exit(-1); } // register event process callbacks Halt_event::add_callback(halt_event_process); Reinit_event::add_callback(reinit_event_process); File_event::add_callback(file_event_process); Osf_event::add_callback(osf_event_process); Time_event::add_callback(time_event_process); try { while (true) { Event* e = opus.poll(); try { e->process(opus); } catch(Done) { delete e; break; } delete e; } } catch(Opus_exceptions& oe) { m << sev(Msg::F) << type(Msg::SEVERE) << "An OPUS exception was thrown." << endl << oe.which() << endl << oe.str() << endm; return(-1); } catch(...) { m << sev(Msg::F) << type(Msg::SEVERE) << "A non-OAPI exception was thrown." << endm; return(-1); } return(0); } void time_event_process( const string& title, const Event* evt, const Opus_env& opus) { Msg m; m << "Processing Time_event." << endl; } void file_event_process( const string& title, const Event* evt, const Opus_env& opus) { Msg m; m << "Processing File_event. Entry's are: " << endl; for (Event::const_iterator vi = evt->begin(); vi != evt->end(); vi++) m << (*vi)->str() << endl; m << endm; // lock Event Entry's vector<Opus_lock*> locks; evt->lock_list(locks); // should handle any Entry's that failed to lock here-- skipping // for sample code... // close out the event opus.close_event("FILE_SUCCESS", evt); // release locks int i; while(i = locks.size()) { delete locks[--i]; locks.pop_back(); } } void osf_event_process( const string& title, const Event* evt, const Opus_env& opus) { Msg m; m << "Processing Osf_event. Entry's are: " << endl; for (Event::const_iterator vi = evt->begin(); vi != evt->end(); vi++) m << (*vi)->str() << endl; m << endm; // lock Event Entry's vector<Opus_lock*> locks; evt->lock_list(locks); // should handle any Entry's that failed to lock here-- skipping // for sample code... // close out the event opus.close_event("OSF_SUCCESS", evt); // release locks int i; while(i = locks.size()) { delete locks[--i]; locks.pop_back(); } } void halt_event_process( const string& title, const Event* evt, const Opus_env& opus) { Msg m; m << "HALT command received. Terminating." << endm; throw Done; } void reinit_event_process( const string& title, const Event* evt, const Opus_env& opus) { Msg m; m << "REINIT command received." << endm; opus.reinit(); }
See Also:
Opus_env::Opus_env - The Opus_env constructor.
Synopsis
Opus_env::Opus_env(int argc, char* argv[], const bool p_app)
Description
The Opus_env object serves as an interface between the OAPI managed blackboards and resource items, and the OPUS application. This constructor initializes the OPUS environment which includes constructing the necessary blackboards, reading path and process resource files, and parsing command line arguments. Only one Opus_env object can be instantiated per OPUS application-- it must be passed by reference to functions outside the one that declares it as needed.
Two kinds of OPUS processes are supported-- pipeline and non-pipeline applications. Pipeline applications are those that will perform event polling on one or more blackboards through this object. Applications of this type specify true for the last calling argument.
Non-pipeline applications do not perform event polling on blackboards, but do need access to the blackboards, resource files, path files, etc. Specilized methods are avaible to applications of this type which instantiate Opus_env with a last argument of false.
Exceptions Thrown
Example
Opus_env opus(argc, argv); // by default, a pipeline application if (!opus.is_initialized()) exit (EXIT_FAILURE);
Opus_env::~Opus_env - The Opus_env destructor.
Synopsis
Opus_env::~Opus_env()
Description
This method deletes the PSTAT and OSF blackboards, and clears containers containing elements allocated off the heap.
Exceptions Thrown
Opus_env::set_path - Set the path for non-pipeline applications, and optionally read a process resource file.
Synopsis
void Opus_env::set_path( const string& pnm, // I - path file name const string& rnm) // I - optional process name
Description
This method loads the indicated path file and the proper pipeline stage file for applications that are not running in a pipeline. If a process name is supplied, that resource file also is loaded.
Exceptions Thrown
Severe<void*> | - if called by a pipeline application; Severe.arg contains 0 |
No_entry | - if file does not exist |
Corrupt | - if Oresource file is corrupt |
Io_error | - if file error encountered loading file |
Severe<void*> | - if construction of OSF status items fails; Severe.arg contains 0 |
No_entry | - if file does not exist |
Corrupt | - if Oresource file is corrupt |
Io_error | - if file error encountered loading file |
No_entry | - if file does not exist |
Corrupt | - if Oresource file is corrupt |
Io_error | - if file error encountered loading file |
Io_error<int> | - if indicated directory does not exist; Io_error.arg contains the value of errno |
No_entry<string> | - if item not found; No_entry.arg contains the calling argument |
Bad_val<string> | - if an unknown PSTAT blackboard implementation is requested; Bad_val.arg contains the requested item |
Io_error<int> | - if indicated directory does not exist; Io_error.arg contains the value of errno |
No_entry<string> | - if item not found; No_entry.arg contains the calling argument |
Bad_val<string> | - if an unknown OSF blackboard implementation is requested; Bad_val.arg contains the requested item |
No_entry | - if file does not exist |
Corrupt | - if Oresource file is corrupt |
Io_error | - if file error encountered loading file |
Opus_env::load_resource_file - Load the contents of a process resource file.
Synopsis
void Opus_env::load_resource_file( const string& rnm) // I - process name
Description
This method loads the indicated process resource file for applications that are not running in a pipeline. If no path file has been loaded, null.path is loaded.
Exceptions Thrown
Severe<void*> | - if called by a pipeline application; Severe.arg contains 0 |
No_entry | - if file does not exist |
Corrupt | - if Oresource file is corrupt |
Io_error | - if file error encountered loading file |
Severe<void*> | - if construction of OSF status items fails; Severe.arg contains 0 |
No_entry | - if file does not exist |
Corrupt | - if Oresource file is corrupt |
Io_error | - if file error encountered loading file |
No_entry | - if file does not exist |
Corrupt | - if Oresource file is corrupt |
Io_error | - if file error encountered loading file |
Io_error<int> | - if indicated directory does not exist; Io_error.arg contains the value of errno |
No_entry<string> | - if item not found; No_entry.arg contains the calling argument |
Bad_val<string> | - if an unknown PSTAT blackboard implementation is requested; Bad_val.arg contains the requested item |
Io_error<int> | - if indicated directory does not exist; Io_error.arg contains the value of errno |
No_entry<string> | - if item not found; No_entry.arg contains the calling argument |
Bad_val<string> | - if an unknown OSF blackboard implementation is requested; Bad_val.arg contains the requested item |
No_entry | - if file does not exist |
Corrupt | - if Oresource file is corrupt |
Io_error | - if file error encountered loading file |
Opus_env::is_initialized - Query whether the object is initialized.
Synopsis
bool Opus_env::is_initialized() const
Description
This method returns the state of the Opus_env object. An uninitialized object should not be used as it may not be fully constructed.
Returns
true - if object is initializedfalse - if object is not initialized
Exceptions Thrown
Example
Opus_env opus(argc, argv); if (!opus.is_initialized()) exit(EXIT_FAILURE);
Opus_env::get_encrypt_passwd - Get encrypted password passed on command line.
Synopsis
string Opus_env::get_encrypt_passwd() const
Description
This method returns the encrypted password for the process.
Returns
string containing the encrypted password.
Exceptions Thrown
No_entry<void*> | - if no password was used with the process; No_entry.arg contains 0 |
Opus_env::get_decrypt_passwd - Get decrypted version of password.
Synopsis
string Opus_env::get_decrypt_passwd() const
Description
This method decrypts the process password, and returns the result.
Returns
string containing the decrypted password.
Exceptions Thrown
No_entry<void*> | - if no password was used with the process; No_entry.arg contains 0 |
Opus_env::get_app_name - Get the application name.
Synopsis
string Opus_env::get_app_name() const
Description
This method returns the application name as specified on the command line or the executable name if no name was passed in to the process.
Returns
string containing the application name.
Exceptions Thrown
Opus_env::find_osf - Look for an OSF on the OSF Blackboard.
Synopsis
int Opus_env::find_osf( const Osf* condition, // I - OSF to search for vector<Entry*>& results) // I - results vector const
Description
This method conducts a search on the OSF blackboard for the supplied OSF. Any matches are placed in the supplied vector.
Returns
the number of matches found.
Exceptions Thrown
Bad_val<Entry*> | - if first argument is null; Bad_val.arg points to the first argument |
Type<Entry*> | - if first argument is not of type File_osf; Type.arg points to the first argument |
Io_error<const char*> | - if the file search fails; Io_error.arg contains the error message |
Not_ready<Entry*> | - if the OSF blackboard has not been constructed; Not_ready.arg contains the calling argument |
Example
Opus_env opus(argc, argv); if (!opus.is_initialized) exit(EXIT_FAILURE); Osf* osf = opus.new_osf(); // create new OSF osf->search_fill_all(); // fill OSF with search chars Data_id* did = new Data_id("SCI"); osf->set_field(did); // set Data_id Field delete did; vector<Entry*> res; if (opus.find_osf(osf, res)) { // matches found for(int i = 0; i < res.size(); i++) { cout << "Matching entry: " << res[i]->str() << endl; delete res[i]; } } delete osf;
Opus_env::apply_status - Apply a process resource file-defined status to an OSF or file entry, then replace that item on the blackboard.
Synopsis
void Opus_env::apply_status( const Osf* osf, // I - OSF to update const string& stat) // I - status to apply const void Opus_env::apply_status( const File_entry* f, // I - file to update const string& stat) // I - status to apply const
Description
The set of Field modifiers named by the string status as defined by the process resource file is applied to the indicated entry, then that entry is replaced on the appropriate blackboard. A lock must be secured by the caller on the indicated entry before calling this method.
Exceptions Thrown
Not_ready<void*> | - if the OSF blackboard is not instantiated; Not_ready.arg contains 0 |
Bad_val<string> | - if the status does not exist; Bad_val.arg contains the status name [any exception thrown by the replace method on the OSF or files blackboards] |
Opus_env::get_polling_time - Get polling interval.
Synopsis
int Opus_env::get_polling_time() const
Description
This method returns the application polling time in seconds.
Returns
the polling time in seconds.
Exceptions Thrown
Opus_env::is_db_update_allowed - Check if database updates are allowed.
Synopsis
bool Opus_env::is_db_update_allowed() const
Description
This method indicates whether the application can update the database or not as specified by the process resource file or path file.
Returns
true - if the application can update the databasefalse - if the application is not allowed to update the database
Exceptions Thrown
Opus_env::is_interactive - Check if application is running interactively.
Synopsis
bool Opus_env::is_interactive() const
Description
This method returns the run-state of the application. Interactive mode is assumed whenever non-OPUS command line arguments are present.
Returns
true - if the application is running interactivelyfalse - if the application is running non-interactively
Exceptions Thrown
Opus_env::get_option - Get a command line option.
Synopsis
void Opus_env::get_option( const string& opt, // I - option name vector<string>& res) // O - option values const
Description
This method returns the value(s) associated with the non-OPUS command line option specified. Options are command-line arguments of the form:
-option_name option_value
Exceptions Thrown
Example
Opus_env opus(argc, argv); if (!opus.is_initialized()) exit(EXIT_FAILURE); vector<string> values; opus.get_option("-d"), values);
Opus_env::get_num_args - Get the number of command line arguments.
Synopsis
int Opus_env::get_num_args() const
Description
This method returns the number of non-OPUS command line arguments placed on the command line. Unlike options, command line arguments are not paired with an name preceeded by a '-'.
Returns
integer number of arguments
Exceptions Thrown
Opus_env::get_arg - Get a command line argument.
Synopsis
string Opus_env::get_arg( const int i) // I - command line argument number const
Description
This method returns the indicated non-OPUS command line argument. Indexing begins at 0 and does not include the OPUS and non-OPUS options.
Returns
string containing the argument
Exceptions Thrown
No_entry<int> | - if no such argument; No_entry.arg contains the calling argument |
Example
Opus_env opus(argc, argv); if (!opus.is_initialized()) exit(EXIT_FAILURE); string arg(opus.get_arg(3));
Opus_env::get_path_name - Get the name of the path in which the process is running.
Synopsis
string Opus_env::get_path_name() const
Description
This method returns the rootname of the path file in use by the process.
Returns
string containing the path root name.
Exceptions Thrown
Opus_env::get_res_item - Get an item from the process resource file.
Synopsis
string Opus_env::get_res_item( const char* cs) // I - key to look for const string Opus_env::get_res_item( const string& key) // I - key to look for const
Description
This method returns the value associated with the provided key from the process resource file. Any appropriate substitutions with path file entries (see below) also are performed.
Path file values can override process resource file values (only) in the following situations:
Process resource file entries of the form KEYWORD = PATH->KEY take the value VALUE if there is a path file PATH.path containing the entry KEY = VALUE. It is an error to use this mechanism when PATH.path does not exist or KEY = VALUE is not in PATH.path. This type of named indirection WILL NOT occur if the process is run in the null path. The value is obtained from null.path instead.
Process resource file entries of the form KEYWORD = PATH->>KEY follow the same rules as entries of the form KEYWORD = PATH->KEY except when run in the null path, the indirection IS PERFORMED with the named path file.
Returns
string containing the keyword value.
Exceptions Thrown
No_entry | - if matching entry not found |
Not_ready | - if file not loaded |
No_entry | - if no value is found for that key |
Not_ready | - if file not loaded |
Bad_val | - value cannot be expressed as desired type. |
No_entry | - if file does not exist |
Corrupt | - if Oresource file is corrupt |
Io_error | - if file error encountered loading file |
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 |
Severe<string> | - if path file indirection lookup fails; Severe.arg contains the missing path file key |
Example
Opus_env opus(argc, argv); if (!opus.is_initialized()) exit(EXIT_FAILURE); string r(opus.get_res_item("OUTPATH"));
Opus_env::get_res_class - Get a class from the process resource file.
Synopsis
void Opus_env::get_res_class(const char* cs, // I - class key map<string, string>& m) // O - class map const void Opus_env::get_res_class(const string& s, // I - class key map<string, string>& m) // O - class map const
Description
This method populates the map associated with the provided class key from the process resource file. Any substitutions with path file entries also are performed.
Exceptions Thrown
No_entry | - if matching entry not found |
Not_ready | - if file not loaded |
No_entry | - if matching entry not found |
Not_ready | - if file not loaded |
No_entry | - if no value is found for that key |
Not_ready | - if file not loaded |
Bad_val | - value cannot be expressed as desired type. |
No_entry | - if file does not exist |
Corrupt | - if Oresource file is corrupt |
Io_error | - if file error encountered loading file |
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 |
Severe<string> | - if path file indirection lookup fails; Severe.arg contains the missing path file key |
Example
Opus_env opus(argc, argv); if (!opus.is_initialized()) exit(EXIT_FAILURE); map<string, string> c_map; opus.get_res_class("OSF_TRIGGER1.", c_map);
Opus_env::get_env_item - Get an environment variable value.
Synopsis
string Opus_env::get_env_item( const char* cs) // I - key const string Opus_env::get_env_item( const string& key) // I - key const
Description
This method returns the value associated with the provided key from the process' environment.
Returns
string containing the environment variable value.
Exceptions Thrown
No_entry<string> | - if item not found; No_entry.arg contains the calling argument |
Example
Opus_env opus(argc, argv); if (!opus.is_initialized()) exit(EXIT_FAILURE); string e(opus.get_env_item("HOME"));
Opus_env::get_stage_title - Get the stage title for the indicated stage.
Synopsis
string Opus_env::get_stage_title( const int i) // I - stage number const
Description
This method returns the stage title for the indicated stage number. The stages are numbered starting from one.
Returns
string containing the stage title.
Exceptions Thrown
Not_ready<int> | - if process is running interactively; Not_ready.arg contains the calling argument |
Bad_val | - if stage number is out of range |
Not_ready | - if stage file is not loaded |
No_entry | - if stage title for the stage number |
Opus_env::get_stage_position - Get the stage position for the indicated title.
Synopsis
int Opus_env::get_stage_position( const string& s) // I - stage title const
Description
This method returns the stage position for the indicated stage title. The stages are numbered starting from one.
Returns
integer stage position.
Exceptions Thrown
Not_ready<string> | - if process running interactively; Not_ready.arg contains the calling argument |
Bad_val | - if the stage title does not exist |
Not_ready | - if stage file is not loaded |
Opus_env::poll - Begin polling blackboards.
Synopsis
Event* Opus_env::poll()
Description
If the process is running non-interactively, this method polls for matches to all defined trigger conditions. The method does not return until an event occurs.
If the process is running interactively, each non-OPUS command line argument is placed in a File_entry, then a File_event is triggered with those File_entries.
Returns
A pointer to the Event associated with a trigger condition beingmet on one of the blackboards.
Exceptions Thrown
Not_ready<void*> | - if no triggers are defined; Not_ready.arg contains 0 |
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 |
Bad_val<int> | - if either argument is null; Bad_val.arg indicates which arg is bad (0 or 1) |
Type<const Entry*> | - if either argument is not of type File_pstat; Type.arg points to the bad argument |
Io_error<const char*> | - if the file rename attempt fails; Io_error.arg contains the error message |
Bad_val<Entry*> | - if first argument is null; Bad_val.arg points to the first argument |
Type<Entry*> | - if first argument is not of type File_pstat; Type.arg points to the first argument |
Io_error<const char*> | - if the file search fails; Io_error.arg contains the error message |
Ambiguous<vector<string>*> | - if more than one PSTAT is found; Ambiguous.arg points to a vector allocated off the heap containing the list of matching PSTAT files |
No_entry<void*> | - if no PSTAT file is found; No_entry.arg points to null |
Bad_val<Entry*> | - if argument is null; Bad_val.arg points to the calling argument |
Type<Entry*> | - if argument is not of type File_pstat; Type.arg points to the calling argument |
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 |
Bad_val<Field*> | - if the argument is null; Bad_val.arg points to the calling argument |
Bad_val<Field*> | - if the calling argument is NULL; Bad_val.arg contains the calling argument |
Type<Field*> | - if the calling argument is not of type Proc_stat; Type.arg contains the calling argument |
Not_ready<Field*> | - if the OSF blackboard has not been constructed; Not_ready.arg contains the calling argument |
Example
Opus_env opus(argc, argv); if (!opus.is_initialized()) exit(EXIT_FAILURE); while(true) { Event* e = opus.poll(); e->process(opus); delete e; }
Opus_env::new_osf - Create a new OSF.
Synopsis
Osf* Opus_env::new_osf() const
Description
This method creates a new OSF by calling the new_osf method of the current OSF blackboard. The Time_stamp field will be filled with the current system time.
Returns
A pointer to the new Osf object.
Exceptions Thrown
Not_ready<void*> | - if OSF blackboard has not been constructed; Not_ready.arg contains 0 |
Opus_env::post_osf - Post an OSF on the OSF blackboard.
Synopsis
void Opus_env::post_osf( const Osf* osf) // I - OSF to post const
Description
This method posts a copy of the OSF on the OSF blackboard.
Exceptions Thrown
Bad_val<Entry*> | - if argument is null; Bad_val.arg points to the calling argument |
Type<Entry*> | - if argument is not of type File_osf; Type.arg points to the calling argument |
Already<Entry*> | - if the OSF file already exists; Already.arg points to the calling argument |
Io_error<int> | - if a file creation error occurs; Io_error.arg contains the value of errno |
Not_ready<Entry*> | - if the OSF blackboard has not been constructed; Not_ready.arg contains the calling argument |
Opus_env::erase_osf - Erase an OSF on the OSF blackboard.
Synopsis
void Opus_env::erase_osf( const Osf* osf) // I - OSF to erase const
Description
This method removes the OSF from the OSF blackboard.
Exceptions Thrown
Bad_val<Entry*> | - if the argument is null; Bad_val.arg points to the calling argument |
Type<Entry*> | - if argument is not of type File_osf; Type.arg points to the calling argument |
Bad_val<Entry*> | - if first argument is null; Bad_val.arg points to the first argument |
Type<Entry*> | - if first argument is not of type File_osf; Type.arg points to the first argument |
Io_error<const char*> | - if the file search fails; Io_error.arg contains the error message |
Ambiguous<vector<Entry*>*> | - if more than one OSF file is found on disk; Ambiguous.arg points to a vector allocated off the heap containing all matching entries, each allocated off the heap |
Io_error<int> | - if the delete operation fails; Io_error.arg contains the value of errno |
No_entry<Entry*> | - if no OSF file is found; No_entry.arg points to the calling argument |
Not_ready<Entry*> | - if OSF blackboard has not been constructed; Not_ready.arg contains the calling argument |
Opus_env::replace_osf - Replaces an OSF on the OSF blackboard with another.
Synopsis
void Opus_env::replace_osf( const Osf* old_osf, // I - OSF to replace const Osf* new_osf) // I - replacement OSF const
Description
This method calls the replace method on the underlying OSF blackboard.
Exceptions Thrown
Not_ready<void*> | - if OSF blackboard has not been constructed; Not_ready.arg contains zero |
Opus_env::lock_osf - Lock an OSF on the OSF blackboard.
Synopsis
Osf_lock* Opus_env::lock_osf( const Osf* osf) // I - OSF to lock const
Description
This method calls the lock_entry method on the OSF blackboard for the OSF.
Returns
a pointer to an Osf_lock object.
Exceptions Thrown
Bad_val<Osf*> | - if argument is NUll; Bad_val.arg contains the calling argument |
Bad_val<Entry*> | - if argument is null; Bad_val.arg points to the calling argument |
Type<Entry*> | - if argument is not of type File_osf; Type.arg points to the calling argument |
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 |
Bad_val<Entry*> | - if argument is null; Bad_val.arg points to the calling argument |
Type<Entry*> | - if argument is not of type File_pstat; Type.arg points to the calling argument |
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 |
Not_ready<Entry*> | - if the blackboard has not been constructed; Not_ready.arg contains the calling argument |
No_entry<Entry*> | - if the entry is not found on the blackboard; No_entry.arg contains the calling argument |
Ambiguous<vector<string>*> | - if more than one entry is found; Ambiguous.arg points to a vector of matching entry strings |
Opus_env::lock_pstat - Lock a PSTAT on the PSTAT blackboard.
Synopsis
Pstat_lock* Opus_env::lock_pstat( const Pstat* pstat) // I - PSTAT to lock const
Description
This method calls the lock_entry method on the OSF blackboard for the OSF.
Returns
a pointer to a Pstat_lock object.
Exceptions Thrown
Bad_val<Pstat*> | - if argument is NUll; Bad_val.arg contains the calling argument |
Bad_val<Entry*> | - if argument is null; Bad_val.arg points to the calling argument |
Type<Entry*> | - if argument is not of type File_osf; Type.arg points to the calling argument |
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 |
Bad_val<Entry*> | - if argument is null; Bad_val.arg points to the calling argument |
Type<Entry*> | - if argument is not of type File_pstat; Type.arg points to the calling argument |
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 |
Not_ready<Entry*> | - if the blackboard has not been constructed; Not_ready.arg contains the calling argument |
No_entry<Entry*> | - if the entry is not found on the blackboard; No_entry.arg contains the calling argument |
Ambiguous<vector<string>*> | - if more than one entry is found; Ambiguous.arg points to a vector of matching entry strings |
Opus_env::new_pstat - Create a new Pstat object.
Synopsis
Pstat* Opus_env::new_pstat() const
Description
This method creates a new Pstat object by calling the new_pstat method of the PSTAT blackboard. The Pid and Node fields will contain the application's values for these objects.
Returns
A pointer to the new Pstat object.
Exceptions Thrown
Not_ready<void*> | - if PSTAT blackboard has not been constructed; Not_ready.arg contains 0 |
Opus_env::post_pstat - Post a PSTAT on the PSTAT blackboard.
Synopsis
void Opus_env::post_pstat( const Pstat* pstat) // I - PSTAT to post const
Description
This method posts a copy of the PSTAT on the PSTAT blackboard.
Exceptions Thrown
Bad_val<Entry*> | - if argument is null; Bad_val.arg points to the calling argument |
Type<Entry*> | - if argument is not of type File_osf; Type.arg points to the calling argument |
Already<Entry*> | - if the OSF file already exists; Already.arg points to the calling argument |
Io_error<int> | - if a file creation error occurs; Io_error.arg contains the value of errno |
Not_ready<Entry*> | - if PSTAT blackboard has not been constructed; Not_ready.arg contains the calling argument |
Opus_env::erase_pstat - Erase a PSTAT on the PSTAT blackboard.
Synopsis
void Opus_env::erase_pstat( const Pstat* pstat) // I - PSTAT to erase const
Description
This method removes the indicated PSTAT from the PSTAT blackboard. This method only can be called by non-pipeline processes.
Exceptions Thrown
Bad_val<Entry*> | - if the argument is null; Bad_val.arg points to the calling argument |
Type<Entry*> | - if argument is not of type File_osf; Type.arg points to the calling argument |
Bad_val<Entry*> | - if first argument is null; Bad_val.arg points to the first argument |
Type<Entry*> | - if first argument is not of type File_pstat; Type.arg points to the first argument |
Io_error<const char*> | - if the file search fails; Io_error.arg contains the error message |
Ambiguous<vector<Entry*>*> | - if more than one PSTAT file is found on disk; Ambiguous.arg points to a vector allocated off the heap containing all matching entries, each allocated off the heap |
Io_error<int> | - if the delete operation fails; Io_error.arg contains the value of errno |
No_entry<Entry*> | - if no PSTAT file is found; No_entry.arg points to the calling argument |
Not_ready<Entry*> | - if the PSTAT blackboard has not been constructed; Not_ready.arg contains the calling argument |
Severe<void*> | - if called by a pipeline application; Severe.arg contains 0 |
Opus_env::replace_pstat - Replaces a PSTAT on the PSTAT blackboard with another.
Synopsis
void Opus_env::replace_pstat( const Pstat* old_pstat, // I - PSTAT to replace const Pstat* new_pstat) // I - replacement const
Description
This method calls the replace method on the underlying PSTAT blackboard. This method only can be called by non-pipeline processes.
Exceptions Thrown
Not_ready<void*> | - if the PSTAT blackboard has not been constructed; Not_ready.arg contains 0 |
Severe<void*> | - if called by a pipeline application; Severe.arg contains 0 |
Opus_env::find_pstat - Look for a PSTAT on the PSTAT Blackboard.
Synopsis
int Opus_env::find_pstat( const Pstat* condition, // I - PSTAT to search for vector<Entry*>& results) // I - results vector const
Description
This method conducts a search on the PSTAT blackboard for the supplied PSTAT. Any matches are placed in the supplied vector.
Returns
the number of matches found.
Exceptions Thrown
Bad_val<Entry*> | - if first argument is null; Bad_val.arg points to the first argument |
Type<Entry*> | - if first argument is not of type File_pstat; Type.arg points to the first argument |
Io_error<const char*> | - if the file search fails; Io_error.arg contains the error message |
Not_ready<Entry*> | - if PSTAT blackboard has not been constructed; Not_ready.arg contains the calling argument |
Opus_env::get_appl_pstat - Get a copy of the process' PSTAT
Synopsis
Pstat* Opus_env::get_appl_pstat() const
Description
This method fetches a copy of the process' PSTAT as it currently exists on the PSTAT blackboard. The object returned to the client is allocated off the heap and should be deleted by the caller when it is no longer needed.
Returns
A pointer to the new Pstat object.
Exceptions Thrown
Bad_val<Entry*> | - if first argument is null; Bad_val.arg points to the first argument |
Type<Entry*> | - if first argument is not of type File_pstat; Type.arg points to the first argument |
Io_error<const char*> | - if the file search fails; Io_error.arg contains the error message |
Ambiguous<vector<string>*> | - if more than one PSTAT is found; Ambiguous.arg points to a vector allocated off the heap containing the list of matching PSTAT files |
No_entry<void*> | - if no PSTAT file is found; No_entry.arg points to null |
Not_ready<void*> | - if the PSTAT blackboard has not been constructed; Not_ready.arg contains 0 |
Opus_env::update_proc_status - Update the status field of the indicated PSTAT.
Synopsis
void Opus_env::update_proc_status( const Field* ps, // I - status to apply const Pstat* pstat) // I - PSTAT to update const
Description
This method updates the STATUS field for the indicated PSTAT (or the application's PSTAT if the pointer is zero) with the contents of the supplied Proc_stat object.
Exceptions Thrown
Bad_val<int> | - if either argument is null; Bad_val.arg indicates which arg is bad (0 or 1) |
Type<const Entry*> | - if either argument is not of type File_pstat; Type.arg points to the bad argument |
Io_error<const char*> | - if the file rename attempt fails; Io_error.arg contains the error message |
Bad_val<Entry*> | - if first argument is null; Bad_val.arg points to the first argument |
Type<Entry*> | - if first argument is not of type File_pstat; Type.arg points to the first argument |
Io_error<const char*> | - if the file search fails; Io_error.arg contains the error message |
Ambiguous<vector<string>*> | - if more than one PSTAT is found; Ambiguous.arg points to a vector allocated off the heap containing the list of matching PSTAT files |
No_entry<void*> | - if no PSTAT file is found; No_entry.arg points to null |
Bad_val<Entry*> | - if argument is null; Bad_val.arg points to the calling argument |
Type<Entry*> | - if argument is not of type File_pstat; Type.arg points to the calling argument |
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 |
Bad_val<Field*> | - if the argument is null; Bad_val.arg points to the calling argument |
Bad_val<Field*> | - if the calling argument is NULL; Bad_val.arg contains the calling argument |
Type<Field*> | - if the calling argument is not of type Proc_stat; Type.arg contains the calling argument |
Not_ready<Field*> | - if the OSF blackboard has not been constructed; Not_ready.arg contains the calling argument |
Example
Opus_env opus(argc, argv); if (!opus.is_initialized()) exit(EXIT_FAILURE); Proc_stat* ps = new Proc_stat(Proc_stat::IDLE); opus.update_proc_status(ps); delete ps;
Opus_env::close_event - Close out event processing.
Synopsis
void Opus_env::close_event( const string& mod, // I - modifier to apply Event* e) // I - event to close const void Opus_env::close_event( const string& mod, // I - modifier to apply Event* e, // I - event to close Event::iterator ei) // I - entry to update const void Opus_env::close_event( const string& mod, // I - modifier to apply Event* e, // I - event to close Event::iterator start, // I - first entry to close Event::iterator end) // I - one past last entry const // to close
Description
This method closes out processing of an event by applying the named modifier to the event entries on the appropriate blackboard. In interactive mode, the argument index is incremented.
Exceptions Thrown
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 |
Example
int main(int argc, char* argv[]) { Opus_env(argc, argv); if (!opus.is_initialized()) exit(EXIT_FAILURE); Osf_event::add_callback(proc_osf_evt); while(true) { Event* e = opus.poll(); e->process(opus); delete e; } } void proc_osf_evt( const string& title, Event* evt, const Opus_env& opus) { bool status; Opus_lock* lock; Event::iterator ei = evt->begin(); while (ei != evt->end()) { status = process_entry_ok(*ei); lock = evt->lock_entry(*ei); if (status) opus.close_event("OSF_SUCCESS", evt, ei, ++ei); else opus.close_event("OSF_FAILURE", evt, ei, ++ei); delete lock; } }
Opus_env::reinit - Reinitialize OPUS.
Synopsis
void Opus_env::reinit()
Description
This method reinitializes the object by purging its private data members, reloading the process resource and path files, and recontructing the appropriate blackboards.
Exceptions Thrown
Example
opus.reinit(); if (!opus.is_initialized()) { cout << "Reinitialization failed!" << endl; exit(EXIT_FAILURE); }
Opus_env::new_com_trig - Create new command and trigger for the command blackboard.
Synopsis
void Opus_env::new_com_trig( const string& s, // I - command label // I - command address bool (*fp)(const vector<string>&), const vector<string>& a, const double& r)
Description
This method creates a new Command object on the command blackboard along with a corresponding Trigger object. The requested rank must not conflict with any exsiting trigger ranks.
Exceptions Thrown
Bad_val<double> | - if command of supplied rank already exists; Bad_val.arg contains the rank |
Bad_val<Entry*> | - if argument is null; Bad_val.arg points to the calling argument |
Type<Entry*> | - if argument is not of type Command; Type.arg points to the calling argument |
Already<Entry*> | - if Command with same Com_label already exists; Already.arg points to the calling argument |
Example
bool foo(const vector<string>&); // function prototype Opus_env opus(argc, argv); if (!opus.is_initialized()) exit(EXIT_FAILURE); vector<string> args; args.push_back("argument 1"); opus.new_com_trig("FOO_COMMAND", foo, args, 10.0);
Opus_env::remove_com_trig - Remove a command from the command blackboard as well as its trigger.
Synopsis
void Opus_env::remove_com_trig( const string& s) // I - command name
Description
This method removes a Command object previously created with the new_com_trig method from the command blackboard. The Trigger for that command also is removed.
Exceptions Thrown
No_entry<string> | - if no such command/trigger found; No_entry.arg contains the calling argument |
Example
bool foo(const vector<string>&); // function prototype Opus_env opus(argc, argv); if (!opus.is_initialized()) exit(EXIT_FAILURE); vector<string> args; args.push_back("argument 1"); opus.new_com_trig("FOO_COMMAND", foo, args, 10.0); opus.remove_com_trig("FOO_COMMAND");
Opus_env::find_modifier - Locate a modifier by name
Synopsis
void Opus_env::find_modifier( const string& mod, // I - modifier to locate vector<Field*>& res) // O - results const
Description
This method searches the modifier map looking to match the supplied modifier name. If found, copies of the modifiers are pushed onto the vector argument. The user should delete each of the modifiers when they are no longer needed.
Exceptions Thrown
No_entry<string> | - if modifier is not found; No_entry.arg contains the calling argument |
Opus_env::journal_roll_back - Update event entries stored in an event journal.
Synopsis
void Opus_env::journal_roll_back( const Pstat* p) // I - PSTAT of process // whose journal to // access
Description
Given the PSTAT for a process, this method attempts to local an Event_journal object for the process. If found, the entries and field modifiers are read from the journal, then an attempt is made to close the event using the appropriate event status. In the case of a journal containing OSF's, the OSF_ABSENT status defined in the journal is applied to each of the entries in the journal, then the entries are updated on the OSF blackboard. For journals containing file entries, the FILE_ABSENT status is applied. This method may be used only by non-pipeline applications.
Exceptions Thrown
Severe<void*> | - if called by a pipeline application; Severe.arg contains 0 |
Bad_val<void*> | - if the calling argument is null; Bad_val.arg contains 0 |
Opus_env::test_driver - Run Blackboard test drivers.
Synopsis
bool Opus_env::test_driver()
Description
This methods calls each of the Blackboard test drivers and stores the result.
Returns
true - if all test drivers passed;false - if any test driver fails
Exceptions Thrown
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