//File: CosPropertyService.idl
//The only module of the Property Service

#ifndef _COS_PROPERTY_SERVICE_IDL_
#define _COS_PROPERTY_SERVICE_IDL_
#pragma prefix "omg.org"

#include <orb.idl>

module CosPropertyService
{
   /*****************************************************/
   /*  Data Types                                       */
   /*****************************************************/

   typedef string PropertyName;
   struct Property {
      PropertyName property_name;
      any property_value;
   };

   enum PropertyModeType {
      normal,
      read_only,
      fixed_normal,
      fixed_readonly,
      undefined
   };

   struct PropertyDef {
      PropertyName property_name;
      any property_value;
      PropertyModeType property_mode;
   };

   struct PropertyMode {
      PropertyName property_name;
      PropertyModeType property_mode;
   };

   typedef sequence<PropertyName> PropertyNames;
   typedef sequence<Property> Properties;
   typedef sequence<PropertyDef> PropertyDefs;
   typedef sequence<PropertyMode> PropertyModes;
   typedef sequence<CORBA::TypeCode> PropertyTypes;

   interface PropertyNamesIterator;
   interface PropertiesIterator;
   interface PropertySetFactory;
   interface PropertySetDef;
   interface PropertySet;

   /*****************************************************/
   /*  Exceptions                                       */
   /*****************************************************/
   exception ConstraintNotSupported{};
   exception InvalidPropertyName {};
   exception ConflictingProperty {};
   exception PropertyNotFound {};
   exception UnsupportedTypeCode {};
   exception UnsupportedProperty {};
   exception UnsupportedMode {};
   exception FixedProperty {};
   exception ReadOnlyProperty {};

   enum ExceptionReason {
      invalid_property_name,
      conflicting_property,
      property_not_found,
      unsupported_type_code,
      unsupported_property,
      unsupported_mode,
      fixed_property,
      read_only_property
   };

   struct PropertyException {
      ExceptionReason reason;
      PropertyName failing_property_name;
   };

   typedef sequence<PropertyException> PropertyExceptions;

   exception MultipleExceptions {
      PropertyExceptions exceptions;
   };

   /*****************************************************/
   /*  Interface Definitions                            */
   /*****************************************************/
   interface PropertySetFactory
   {
      PropertySet create_propertyset();
      PropertySet create_constrained_propertyset(
         in PropertyTypes allowed_property_types,
         in Properties  allowed_properties)
         raises(ConstraintNotSupported);
      PropertySet create_initial_propertyset(
         in Properties  initial_properties)
         raises(MultipleExceptions);
   };

   /*---------------------------------------------------*/
   interface PropertySetDefFactory
   {
      PropertySetDef create_propertysetdef();
      PropertySetDef create_constrained_propertysetdef(
         in PropertyTypes allowed_property_types,
         in PropertyDefs  allowed_property_defs)
         raises(ConstraintNotSupported);
      PropertySetDef create_initial_propertysetdef(
         in PropertyDefs  initial_property_defs)
         raises(MultipleExceptions);
   };

   /*---------------------------------------------------*/
   interface PropertySet
   {
      /* Support for defining and modifying properties */
      void define_property(
         in PropertyName property_name,
         in any property_value)
         raises(  InvalidPropertyName,
                  ConflictingProperty,
                  UnsupportedTypeCode,
                  UnsupportedProperty,
                  ReadOnlyProperty);

      void define_properties(
         in Properties nproperties)
         raises(MultipleExceptions);

      /* Support for Getting Properties and their Names */
      unsigned long get_number_of_properties();

      void get_all_property_names(
         in unsigned long how_many,
         out PropertyNames property_names,
         out PropertyNamesIterator rest);

      any  get_property_value(
         in  PropertyName property_name)
         raises(  PropertyNotFound,
                  InvalidPropertyName);

      boolean get_properties(
         in PropertyNames property_names,
         out Properties nproperties);

      void get_all_properties(
         in unsigned long how_many,
         out Properties nproperties,
         out PropertiesIterator rest);

      /* Support for Deleting Properties              */
      void delete_property(
         in PropertyName property_name)
         raises(  PropertyNotFound,
                  InvalidPropertyName,
                  FixedProperty);

      void delete_properties(
         in PropertyNames property_names)
         raises(MultipleExceptions);

      boolean delete_all_properties();

      /* Support for Existence Check                  */
      boolean is_property_defined(
         in PropertyName property_name)
         raises(InvalidPropertyName);
   };

   /*---------------------------------------------------*/
   interface PropertySetDef:PropertySet
   {
      /* Support for retrieval of PropertySet constraints*/
      void get_allowed_property_types(
         out PropertyTypes property_types);

      void get_allowed_properties(
         out PropertyDefs property_defs);

      /* Support for defining and modifying properties */
      void define_property_with_mode(
         in PropertyName property_name,
         in any property_value,
         in PropertyModeType property_mode)
         raises(  InvalidPropertyName,
                  ConflictingProperty,
                  UnsupportedTypeCode,
                  UnsupportedProperty,
                  UnsupportedMode,
                  ReadOnlyProperty);

      void define_properties_with_modes(
         in PropertyDefs property_defs)
         raises(MultipleExceptions);

      /* Support for Getting and Setting Property Modes */
      PropertyModeType get_property_mode(
         in  PropertyName property_name)
         raises(  PropertyNotFound,
                  InvalidPropertyName);

      boolean get_property_modes(
         in PropertyNames property_names,
         out PropertyModes property_modes);

      void set_property_mode(
         in PropertyName property_name,
         in PropertyModeType property_mode)
         raises(  InvalidPropertyName,
                  PropertyNotFound,
                  UnsupportedMode);

      void set_property_modes(
         in PropertyModes property_modes)
         raises(MultipleExceptions);
   };

   /*---------------------------------------------------*/
   interface PropertyNamesIterator
   {
      void    reset();
      boolean next_one(
         out PropertyName property_name);
      boolean next_n (
         in  unsigned long how_many,
         out PropertyNames property_names);
      void    destroy();
   };

   /*---------------------------------------------------*/
   interface PropertiesIterator
   {
      void    reset();
      boolean next_one(
         out Property aproperty);
      boolean next_n(
         in unsigned long how_many,
         out Properties nproperties);
      void    destroy();
   };
};
#endif /* ifndef _COS_PROPERTY_SERVICE_IDL_ */
