/**
  * File: MapStringSet.idl
  * Content: CORBA specification of a map containing pairs<String, SetMemberInfo>
  * Author: LuisM Pena
  * Date: 17th November 2001
  * Version: 0.29.00
  *
  **/

#ifndef MAP_STRING_SET
#define MAP_STRING_SET

#include "SetMemberInfo.idl"

module sensei
{

  module middleware
  {

    module gmns
    {

      //bringing some declarations into scope ...
      typedef sensei::middleware::domains::SubgroupId SubgroupId;

      exception InvalidSetMemberInfo{};

      /***********************************************************************/
      /************************* MAP STRING SET OBSERVER *********************/
      /***********************************************************************/

      interface MapStringSetObservable;

      /**
       * Interface to be implemented by observers of the state of the MapStringSet
       */
      interface MapStringSetObserver
      {
        void clearDone(in MapStringSetObservable observable);
        void putDone(in MapStringSetObservable observable, in string groupName, in SetMemberInfo set);
        void removeDone(in MapStringSetObservable observable, in string groupName, in SetMemberInfo set);
      };

      /***********************************************************************/
      /************************* MAP STRING SET OBSERVABLE *******************/
      /***********************************************************************/

      interface MapStringSetObservable
      {
        void addObserver(in MapStringSetObserver observer);
        boolean removeObserver(in MapStringSetObserver observer);
      };

      /***********************************************************************/
      /************************* MAP STRING SET ******************************/
      /***********************************************************************/

      typedef sequence<string> stringList;
      /**
        * This interfaces defines a map with reduced operations.
        * And it is mean to contain just pairs with key=strings and value=SetGroupHandler
        **/
      interface MapStringSet : ExtendedCheckpointable, MapStringSetObservable
      {
        /**
         * Associates the specified value with the specified key in this map.
         * If the map previously contained a mapping for this key, the old value is replaced
         */
        SetMemberInfo put(in string groupName, in SetMemberInfo set)
          raises (InvalidSetMemberInfo, sensei::middleware::domains::MemberStateException);

        /**
          * Removes the specified element from this set if it is present.
          * @returns previous value associated with specified key, or null if there was no mapping for key
          **/
        SetMemberInfo remove(in string groupName) raises (sensei::middleware::domains::MemberStateException);

        /**
          * Returns the associated value, given the key
          **/
        SetMemberInfo get(in string groupName) raises (sensei::middleware::domains::MemberStateException);

        /**
         * Returns the keys of the set
         */
        stringList getKeys() raises (sensei::middleware::domains::MemberStateException);
      };

      /***********************************************************************/
      /************************* MAP STRING PUT MESSAGE **********************/
      /***********************************************************************/

      valuetype MapStringSetPutMessage : DomainMessage
      {
        public string key;
        public SubgroupId value; //it's sent the subgroup, not the replicated object itself
      };

      /***********************************************************************/
      /************************* MAP STRING REMOVE MESSAGE *******************/
      /***********************************************************************/

      valuetype MapStringSetRemoveMessage : DomainMessage
      {
        public string key;
      };

      /***********************************************************************/
      /************************* MAP STATE **********************************/
      /***********************************************************************/

      struct MapStringSetEntry
      {
        string key;
        SubgroupId value;
      };
      valuetype MapStringSetState : State
      {
        public sequence<MapStringSetEntry> groups;
      };

    };
  };
};

#endif