This class is available for the OPUS Blackboard API. The initial OPUS 2.0 release is described here
Constructors:
Com_arg( ) | |
~Com_arg( ) |
Methods:
clone( ) | returns a copy of this object |
Description
Functions associated with a Command object may have any number of string calling arguments. This Command field is a container for those calling arguments. One Com_arg field is added to a Command object for each calling argument required by the function it represents.
Derived from
Example
#include <vector> #include <string> #include <iostream> #include "command.h" #include "command_bb.h" using namespace std; // The following function demonstrates a global function to be // placed on the Command Blackboard by an OAPI client. This simple // example dumps its arguments to cout, then returns true. bool foo(vector<string>& args) { for (int i = 0; i < args.size(); i++) cout << args[i] << endl; return(true); } // The following driver posts a command on the Command Blackboard, // then does a search for it which results in its execution. int main(int argc, char* argv[]) { string label("Foo Command"); // give the command a name string arg("/tmp"); // a command argument Command* com; com = new Command(label, foo); // create new Command that points // to foo() com->add_arg(arg); // add a single calling argument Command_bb com_bb; com_bb.post(com); // post Command on blackboard delete com; // no longer needed com = new Command(label); // create Command for search vector<string> results; // results vector // search returns size of results // vector if (com_bb.search(condition, results)) { cout << "Command execution returns true." << endl; delete results[0]; // delete search result } else { cout << "Command not found or returned false." << endl; } delete condition; // no longer needed return(0); }
See Also:
Com_arg::Com_arg - The Com_arg constructor.
Synopsis
Com_arg::Com_arg( const string& s) // I - calling argument string Com_arg::Com_arg( const Com_arg& ca) // I - object to initialize from
Description
This method constructs a Com_arg object and records the string calling argument. Null strings are permitted, and the maximum argument length is 256 characters.
Exceptions Thrown
Com_arg::~Com_arg - The Com_arg destructor.
Synopsis
Com_arg::~Com_arg()
Description
This method destroys the object.
Exceptions Thrown
Com_arg::clone - Create a copy of this object.
Synopsis
Field* Com_arg::clone() const
Description
This method creates a new Com_arg object, initialized by this object, off the heap and returns a pointer to the new object to the caller. The client should delete the new object when it is no longer needed.
Returns
A pointer to a new Com_arg object initialized by this object.
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