/************************************************************************/
/* Copyright 1998 MBARI							*/
/************************************************************************/
#ifndef _SUBPROGRAMS_H
#define _SUBPROGRAMS_H

#include <SList.h>

/*
CLASS 
SubPrograms

DESCRIPTION
Manage execution and termination of child programs 

AUTHOR
Tom O'Reilly
*/
class SubPrograms
{
  public:
  SubPrograms(const char *name);
  ~SubPrograms();
  
  ///////////////////////////////////////////////////////////////////
  // Add a child program to the table
  void add(const char *name, 
	   int pid, 
	   void (*exitCallback)(int status));

  ///////////////////////////////////////////////////////////////////
  // Activate exitCallback of terminated child program
  int exitProcess(int pid, int status);
  
  protected:

  struct Entry
  {
    Entry(const char *name, int pid, void (*exitCallback)(int status)); 
    ~Entry();
    
    const char *_name;
    int _pid;
    void (*_exitCallback)(int status);
  };
  
  SList <Entry *> _entryList;
};

#endif
