// -*- C++ -*-

//=============================================================================
/**
 *  @file   Fault_Detector.h
 *
 *  Fault_Detector.h,v 1.3 2004/02/04 20:20:21 parsons Exp
 *
 *  @author Huang-Ming Huang <hh1@cse.wustl.edu>
 */
//=============================================================================

#ifndef FAULT_DETECTOR_H
#define FAULT_DETECTOR_H

#include "ace/Task.h"
#include "ace/Reactor.h"

#include "orbsvcs/orbsvcs/FTRT_GroupManagerC.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

class TAO_FTEC_Fault_Listener;

class Fault_Detector
{
public:
  virtual ~Fault_Detector();

  static Fault_Detector* instance();

  int init(int argc, ACE_TCHAR** argv);
  void stop();
  void set_listener(TAO_FTEC_Fault_Listener*);
  const FTRT::Location& my_location() const;
  virtual int connect(const FTRT::Location& location)=0;

private:
  virtual int init_acceptor()=0;
  virtual int parse_conf(int argc, ACE_TCHAR** argv);

protected:

  class ReactorTask : public ACE_Task_Base
  {
  public:
    // ctor
    ReactorTask();
    virtual int svc (void);
    ACE_Reactor reactor_;
  };

  FTRT::Location location_;
  ReactorTask reactor_task_;
  TAO_FTEC_Fault_Listener* listener_;
};

#endif //FAULT_DETECTOR_H
