//=========================================================================
// Summary  : */
// Filename : TaskInterface.h
// Author   : Tom O'Reilly                                                  */
// Project  : */
// Revision : 1
// Created  : 2000/08/19
// Modified : 2000/08/19
//=========================================================================
// Description :
//=========================================================================
#ifndef _TASKCLIENT_H
#define _TASKCLIENT_H

#include "SharedObjectClient.h"
#include "ExternalMessage.h"


/*
CLASS
TaskInterface

DESCRIPTION
Each Task class has a corresponding TaskInterface, which allows other
applications to access the Task. The client application simply creates
an instance of TaskInterface subclass, and invokes its public methods
to access the Task. Client can also use TaskInterface to "subscribe"
to events defined by the Task, and will be notified by the TaskServer
when the events occur.

AUTHOR
Tom O'Reilly
*/
class TaskInterface : public SharedObjectClient {

  friend class Supervisor;
  friend class ExternalComms;

public:

  TaskInterface(const char *name, int foo, const char *serverName,
		int serverConnectTimeout = 2);
//AMM
//  TaskInterface(const char *name, const char *serverName,
//		int serverConnectTimeout = 2);

  TaskInterface(const char *name);

  ~TaskInterface();


  ///////////////////////////////////////////////////////////////////
  // Subscribe to specified server event
  void subscribe(EventCode eventCode, pid_t remoteProxyPid = -1)
    throw (Error);


  ///////////////////////////////////////////////////////////////////
  // Wait for a subscribed-to event, and return its code
  EventCode waitForEvent();

protected:

  ///////////////////////////////////////////////////////////////////
  // Graceful shutdown and termination of Task
  void shutdown();

  ////////////////////////////////////////////////////////////////////
  // Reset Task
  void reset();

  ////////////////////////////////////////////////////////////////////
  // Decode ExternalMethodMessage, send it to server, then re-encode it
  virtual void sendExternalMsg(ExternalMethodMessage *message);
};

#endif
