The interaction with the application programmer will typically consist only of:
The ObjectController has the following "internal" functions as well:
At present, these internal functions are ordered up solely through events received over the Glish bus. We intend to allow unix command line control in the future. The events which are presently understood are:
ObjectController Glish Protocol | ||||
---|---|---|---|---|
Event (In) | Value | Event (Out)> | Value | |
run | The run event is used to invoke ("run") a member function in a distributed object. The object must already exist. | A record, which must contain the sequence part of the ObjectID in field _sequence, and the method name in _method. The other fields of the record are the input arguments for the method. | run_result | The same record with the output arguments filled in. |
done/b> | The done event is used to destruct an object which exists in the current server. | An ObjectID record. | done_result, an integer giving the number of remaining live objects, or error if something has gone awry. | The same record with the output arguments filled in. |
run_async | Like run, except from the users point of view the method is running asynchronously. | Like run, with an additional _jobid field. | run_result_async | The same as for run_result, except _jobid is reflected back as well. |
create | Create an object of some class. | A record. _type is the classname, _creator is the constructor "name" (it can be ommitted if the default constructor is the only one) | create_result | A record containing the ObjectID mapped to _sequence, _pid, _time and _host. |
trace | Turn on (off) tracing information for debugging purposes. Also sets the global logging filter to DEBUGGING (NORMAL). | A Bool. | None | None |
any | After the controller discovers any error (e.g. exception), it will return an error event. The value is a string with the error message. | any | error | String (error message) |
choice | This event is in response to a get_choice event. | The users choice (String) | get_choice | [description=String, choices=StringVector] |
progress_result | This is in response to a get_progress event. | A progress ID (integer). | get_progress | [min=double,max=double,title=string,subtitle=string, minlabel=string, maxlabel=string, estimate=bool] |
#include <aips/Tasking.h> #include <your includes go here> int main(int argc, char **argv) { ObjectController controller(argc, argv); controller.addMaker("squarer", new StandardObjectFactory<class1>); controller.addMaker("squarer", new StandardObjectFactory<class2>); controller.loop(); return 0; }In the above example, this executable serves two classes, class1 and class2. For more details read note #197.
Times are in millisec.
This function is called by the standard function. It relinquished locks requested on Tables by other processes.
Times are in millisec.
Initialize from the command line arguments. Also sets the global LogSink to post messages to Glish, where they will typically end up in a GUI.
If globalSink is set, use if for the global sink, otherwise use a GlishLogSink. The sink must come from the heap if it is set.
The default constructor will automatically clear Table locks when idle, however you can avoid this behaviour for servers with no tables (i.e. avoid lining against tables) or other idle needs. If no idle loop is needed, just set idleFunc to zero.
Besides freeing up local resources, if Glish is no longer connected to the process, sets the global LogSink to only pass SEVERE messages, since the messages are just being dumped to stdout.
Add a maker (factory). Note that after calling addMaker, the controller is responsible for deleting the pointer. You must not delete it yourself. Besides the constructor, this is probably the only function you will call.
If you want to, you can add a new object directory. This is typically done by an object that wants to add another object to the controller. The controller takes over responsibility for deleting the pointer, which must have been allocated with new. The pointer is set to zero to reduce the chances of it being accidentally deleted.
Create an object of the given type and constructor. inputRecord must have come from new, and will be deleted by this function. If creation fails the returned ObjectID will be null and errorMsg will be set. Normally, application programmers will not call this function.
Get the specified object. Returns a null pointer if it does not exist. Do not delete the returned pointer! The object controller will do it for you. Note that the entire object id must match, not just the sequence number, which is all that is used by runMethod.
Normally, application programmers will not call this function.
Return list of methods in this object
Normally, application programmers will not call this function.
Destroy the given object if possible (i.e. if it exists). Returns the number of remaining active objects.
Do we have a GUI available ? Usually False if environment variable DISPLAY is not set.
Posts an "error" event containing errorMessage. Normally, application programmers will not call this function.
Run object methods until we're done Normally, application programmers will not call this function.
Check or change the tracing status. Besides the controllers own messages, Trace==True also puts the global log sink at DEBUG level. False turns it back to NORMAL Normally, application programmers will not call this function.
Use the catalog viewer to view a file
Attempt to make a plotter. If a plotter with the given name already exists we return True (so that a plotter can be shared).
Send plot commands in the form created by PGPlotterGlish
If isInteractive() and connected to Glish, get a choice from the user. IF !isInteractive(), always return the first choice, so it should be the default. For example, if you are asking whether or not the user wants to overwrite a file, the default should be "no". If choices is zero length, always return the empty string.
If isInteractive() and connected to Glish, get a choice from the user. If !isInteractive(), always return False, else check to see if the user has told this object to stop.
Send our controlling process an event named memory with the value of our memory use in MB.
Carry out the nitty-gritty details of handling the particular events. Normally these methods will only be called from loop(), but they can be called explicitly if desired for testing or other purposes. Normally, application programmers will not call this function.
Under very rare conditions you might want to change the global logsink after creation. You can do so with this function. The default (=0) is to attach the global logsink to Glish (i.e. the normal logging function).
Get a factory by name.
Disallow copying and assignment