/**
 * @file NotifyExt.idl
 *
 * @brief Additional interfaces for QoS properties to Notify.
 *
 * $Id: NotifyExt.idl 81416 2008-04-24 10:26:10Z johnnyw $
 *
 * @author Pradeep Gore <pradeep@oomworks.com>
 */

#ifndef _NOTIFY_EXT_IDL_
#define _NOTIFY_EXT_IDL_

#include "CosNotifyChannelAdmin.idl"

#pragma prefix ""

/**
 * @namespace NotifyExt
 *
 * @brief Notify Extensions.
 */
module NotifyExt
{
  // Priority defs. same as RTCORBA
  typedef short Priority;
  const Priority minPriority = 0;
  const Priority maxPriority = 32767;

  enum PriorityModel
  {
    CLIENT_PROPAGATED,
    SERVER_DECLARED
  };

  /*
   * ThreadPool QoS property,
   */
  const string ThreadPool = "ThreadPool";

  // ThreadPoolParams : same as RTCORBA::create_threadpool
  struct ThreadPoolParams
  {
    PriorityModel priority_model;
    Priority server_priority;

    unsigned long stacksize;
    unsigned long static_threads;
    unsigned long dynamic_threads;
    Priority default_priority;
    boolean allow_request_buffering;
    unsigned long max_buffered_requests;
    unsigned long max_request_buffer_size;
  };

  /*
   * ThreadPoolLanes QoS property,
   */
  const string ThreadPoolLanes = "ThreadPoolLanes";

  struct ThreadPoolLane
  {
    PriorityModel priority_model;
    Priority server_priority;

    Priority lane_priority;
    unsigned long static_threads;
    unsigned long dynamic_threads;
  };

  typedef sequence <ThreadPoolLane> ThreadPoolLanes_List;

  struct ThreadPoolLanesParams
    {
      PriorityModel priority_model;
      Priority server_priority;

      unsigned long stacksize;
      ThreadPoolLanes_List lanes;
      boolean allow_borrowing;
      boolean allow_request_buffering;
      unsigned long max_buffered_requests;
      unsigned long max_request_buffer_size;
  };

  /**
   * \brief An interface which gets registered with a ReconnectionRegistry.
   *
   * A supplier or consumer must implement this interface in order to
   * allow the Notification Service to attempt to reconnect to it after
   * a failure.  The supplier or consumer must register its instance of
   * this interface with the ReconnectionRegistry.
   */
  interface ReconnectionCallback
  {
    /// Perform operations to reconnect to the Notification Service
    /// after a failure.
    void reconnect (in Object new_connection);

    /// Check to see if the ReconnectionCallba ck is alive
    boolean is_alive ();
  };

  /**
   * \brief An interface that handles registration of suppliers and consumers.
   *
   * This registry should be implemented by an EventChannelFactory and
   * will call the appropriate reconnect methods for all ReconnectionCallback
   * objects registered with it.
   */
  interface ReconnectionRegistry
  {
    typedef long ReconnectionID;
    ReconnectionID register_callback(in ReconnectionCallback reconection);

    void unregister_callback (in ReconnectionID id);

    /// Check to see if the ReconnectionRegistry is alive
    boolean is_alive ();
  };

  /**
   * Extend the EventChannelFactory to have a shutdown method
   * and a Reconnection Registry
   */
  interface EventChannelFactory
    : CosNotifyChannelAdmin::EventChannelFactory
    , ReconnectionRegistry
  {
    void destroy ();
    /// save topology: for diagnostic and testing purposes
    /// Normal topology save is automatic when connectivity persistence
    /// is configured.
    void save_topology();
  };

  interface ConsumerAdmin : CosNotifyChannelAdmin::ConsumerAdmin
  {
    // Create a new push-style proxy supplier
    /**
     * @param ctype The event format that the ProxyConsumer should
     *   support
     * @param proxy_id The ID assigned to the new proxy supplier
     * @param initial_qos Configure the initial QoS properties of the
     *   new Proxy.
     * @return The new ProxySupplier
     * @throws AdminLimitExceeded if a limit in this admin is reached,
     *   such as the maximum number of proxies.
     * @throws CosNotification::UnsupportedQoS if the requested QoS
     *   properties cannot be satisfied or are invalid
     */
    CosNotifyChannelAdmin::ProxySupplier obtain_notification_push_supplier_with_qos (in CosNotifyChannelAdmin::ClientType ctype,
                                                                                     out CosNotifyChannelAdmin::ProxyID proxy_id,
                                                                                     in CosNotification::QoSProperties initial_qos)
      raises (CosNotifyChannelAdmin::AdminLimitExceeded,
              CosNotification::UnsupportedQoS);
  };

  interface SupplierAdmin : CosNotifyChannelAdmin::SupplierAdmin
  {
    // Create a new push-style proxy supplier
    /**
     * @param ctype The event format that the ProxyConsumer should
     *   support
     * @param proxy_id The ID assigned to the new proxy supplier
     * @param initial_qos Configure the initial QoS properties of the
     *   new Proxy.
     * @return The new ProxyConsumer
     * @throws AdminLimitExceeded if a limit in this admin is reached,
     *   such as the maximum number of proxies.
     * @throws CosNotification::UnsupportedQoS if the requested QoS
     *   properties cannot be satisfied or are invalid
     */
    CosNotifyChannelAdmin::ProxyConsumer obtain_notification_push_consumer_with_qos (in CosNotifyChannelAdmin::ClientType ctype,
                                                                                     out CosNotifyChannelAdmin::ProxyID proxy_id,
                                                                                     in CosNotification::QoSProperties initial_qos)
      raises (CosNotifyChannelAdmin::AdminLimitExceeded,
              CosNotification::UnsupportedQoS);
  };
};

#endif /* _NOTIFY_EXT_IDL_ */
