Component Base

As with ports, much of the work in implementing the component interface is already done. In order to create a component, it is only necessary to create a class derived from ComponentBase and implement a few virtual functions.
virtual void init()
This method is called immediately after component construction, and is intended for any setup that must be done before any remote methods are invoked. For example, LSA components use init() to create html files that will be filled in as the component executes.
virtual RETVAL handleInput(int request)
handleInput is where you tell the component what to do when it receives input on a port. The value of request will be either Request::CONFIG or Request::EXECUTE. Request::CONFIG indicates that data is available on a knob port (i.e. a port that was constructed with Request::CONFIG in it's second parameter). Request::EXECUTE indicates that we should try to process the data on the input ports (this is normally caused by the CAT telling the component to execute). The value returned from handleInput will be the value that the CAT receives. Typically, if there is an error, then RETVAL::ERROR is returned, and RETVAL::OK is returned to indicate success. Before returning, handleInput should add to executePorts any ports that it wrote to (these are the ports that the CAT will obtain when it queries the component with getExecutePorts).
Component::Component()
The constructor for the new component is responsible for initializing the component. This is where the name and readme are specified for the component (using the setReadme and setName methods). The ports are constructed and initialized (their names and readmes are set), and each port is added to the appropriate list (addInputPort and addOutputPort). Note that 'event' is an event queue define in ComponentBase, and should be the first argument to InputPort constructors. Furthermore, addExemplar() should be called for each port type so that incoming data can be recognized.
ComponentCreator
Every component must have an associated class derived from ComponentCreator. It is this class that the library uses to construct the component. For all components, this class will be of the same form:
class MakeComponent : public ComponentCreator {
public:
  ComponentBase* create { return new Component(); }
};
Then, in a source file, it is necessary to initialize ComponentBase::componentCreator with a pointer to an output of this type:
ComponentCreator* ComponentBase::componentCreator = new MakeComponent();


[ IU CS ] [ Extreme! Computing ] [ CAT ] [ HPC++ CAT ]
dastern@extreme.indiana.edu

Last updated: Tue Jan 26 15:54:56 1999