/* -*- IDL -*- */
//=============================================================================
/**
 *  @file    FT_TestReplica.idl
 *
 *  This file defines an interface used to test Fault Tolerant CORBA.
 *
 *  @author Dale Wilson <wilson_d@ociweb.com>
 */
//=============================================================================
//
#ifndef FT_TESTREPLICA_IDL
#define FT_TESTREPLICA_IDL

#include "orbsvcs/FT_Replica.idl"

module FT_TEST
{
  /**
   * A FT_TEST::Replica provides a test target for a FT::FaultDetector
   * It is Updateable (and therefore Checkpointable)
   * and PullMonitorable
   * It declares a simple counter that can be set, incremented, and read
   * via method calls.  The counter is also exposed as a property.
   */
  interface TestReplica : ::FT::Updateable, ::FT::PullMonitorable, ::PortableGroup::TAO_UpdateObjectGroup
  {
    /**
     *  set the counter to an specific value.
     * @param value is the number to be set.
     */
    void set(in long value);

    /**
     * add delta to the counter.
     * @param delta is the number to be added: (delta may be positive, negative or zero).
     * @returns the new value of the counter.
     */
    long increment(in long delta);

    /**
     * retrieve the current counter.
     * @returns the value of the counter.
     */
    long get();


    /**
     * enumerate the points at which
     * the test replica might be convinced to die.
     */
    enum Bane
    {
      NOT_YET,              // normal state, also used to revoke a previous request
      RIGHT_NOW,            // fault immediately during the die() call
      WHILE_IDLE,           // fault while not processing a request
                        // FT_TestReplica interface:
      BEFORE_STATE_CHANGE,  // after receiving request
      BEFORE_REPLICATION,   // after state change
      BEFORE_REPLY,         // after state replication
                        // FT::PullMonitorable interface:
      DURING_IS_ALIVE,
      DENY_IS_ALIVE,
                        // FT::Updatable interface:
      DURING_GET_UPDATE,
      BEFORE_SET_UPDATE,
      AFTER_SET_UPDATE,
                        // FT::Checkpointable interface:
      DURING_GET_STATE,
      BEFORE_SET_STATE,
      AFTER_SET_STATE,
                        // Reserved
      CLEAN_EXIT            // reserved for use by shutdown
    };


    /**
     * die a horrid death.
     * @param when is an arbitrary code to indicate how and when to die.
     */
    void die(in Bane when);


    /**
     * die a clean death.
     */
    oneway void shutdown();

    /**
     * provide direct access to the counter.
     * Suports the same functionality as set and get.
     * Can you say "Encapsulization???" this is a test, remember.
     */
    attribute long counter;
  };

  interface ReplicaFactory : ::PortableGroup::GenericFactory, ::FT::PullMonitorable
  {
    /**
     * die a clean death.
     */
    oneway void shutdown();
  };

  ///////////////////////
  // roles for unit tests
  // A TestReplica can act as a...

//  typedef TestReplica Hobbit;
//  typedef TestReplica Elf;
//  typedef TestReplica Human;

};

#endif // for #ifndef FT_TESTREPLICA_IDL
