<?xml version="1.0" encoding="utf-8"?>
<xsd:schema targetNamespace="http://www.dre.vanderbilt.edu/ServerResources"
            xmlns:CIAO="http://www.dre.vanderbilt.edu/ServerResources"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            attributeFormDefault="unqualified">

  <xsd:element name="ServerResources" type="CIAO:ServerResourcesDef">
    <xsd:annotation>
      <xsd:documentation>
        Root element for defining all the resources used by a DeploymentPlan.  
        A CIAO:ServerResources document should reside in a separate file.  
        A DeploymentPlan can refer to one or more CIAO:ServerResources file names
        using the "infoProperty" tag.  
      </xsd:documentation>
    </xsd:annotation>
  </xsd:element>

  <xsd:complexType name="ServerResourcesDef">
    <xsd:sequence>
      <xsd:element name="cmdline" type="CIAO:ServerCmdlineOptions" minOccurs="0"/>
      <xsd:element name="svcconf" type="CIAO:ACESvcConf" minOccurs="0"/>
      <xsd:element name="orbConfigs" type="CIAO:ORBConfigs" />
    </xsd:sequence>
    <xsd:attribute name="id" type="xsd:ID"/>
  </xsd:complexType>


<!-- =============================================================== -->

  <xsd:complexType name="ServerCmdlineOptions">
    <xsd:annotation>
      <xsd:documentation>
        Just a list of argv's that should be appended to the command
        line used to start up the NodeApplication.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:sequence>
      <xsd:element name="arg" type="xsd:string" maxOccurs="unbounded"/>
    </xsd:sequence>
  </xsd:complexType>

<!-- ================================================================ -->

  <xsd:complexType name="ACESvcConf">
    <xsd:annotation>
      <xsd:documentation>
        Contains either a pointer to a svc.conf file, or the actual
        content of the svc.conf file required to configure the
        NodeApplication.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:choice>
      <!-- Specify the URI of a svc.conf file. -->
      <xsd:element name="uri" type="xsd:string"/>

      <!-- If we agree to use only XML based svc.conf "file", we will
           support inlined svcconf entries here.  If that will be the
           case, we still need to convert ACE_Svc_Conf DTD to schema. -->
      <!--
        <xsd:element name="inline" type="ACE_Svc_Conf"/>
        -->
    </xsd:choice>
  </xsd:complexType>

<!-- ========================================================================= -->

  <xsd:complexType name="ORBConfigs">
    <xsd:annotation>
      <xsd:documentation>
        Contains the shared resources the component ORB must support
        and all available policySets that components installed under
        the ORB can request.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:sequence>
      <xsd:element name="resources" type="CIAO:ORBResources" 
                                    minOccurs="0"/>
      <xsd:element name="policySet" type="CIAO:PolicySet"
                                    maxOccurs="unbounded"/>
    </xsd:sequence>
  </xsd:complexType>

<!-- ========================================================================= -->

  <xsd:complexType name="ORBResources">
    <xsd:choice maxOccurs="unbounded">
      <xsd:element name="threadpool" type="CIAO:ThreadpoolDef"/>
      <xsd:element name="threadpoolWithLanes" type="CIAO:ThreadpoolWithLanesDef"/>
      <xsd:element name="connectionBands" type="CIAO:ConnectionBandsDef"/>
      <!-- Other ORB-wide resources that must be allocated by the ORB -->
    </xsd:choice>
  </xsd:complexType>

  <xsd:simpleType name="Priority">
    <xsd:restriction base="xsd:int">
      <xsd:minInclusive value="0"/>
      <xsd:maxInclusive value="32767"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:complexType name="ThreadpoolDef">
    <xsd:sequence>
      <xsd:element name="stacksize" type="xsd:unsignedLong"/>
      <xsd:element name="static_threads" type="xsd:unsignedLong"/>
      <xsd:element name="dynamic_threads" type="xsd:unsignedLong"/>
      <xsd:element name="default_priority" type="CIAO:Priority"/>
      <xsd:element name="allow_request_buffering" type="xsd:boolean"/>
      <xsd:element name="max_buffered_requests" type="xsd:unsignedLong"/>
      <xsd:element name="max_request_buffered_size" type="xsd:unsignedLong"/>
    </xsd:sequence>
    <xsd:attribute name="id" type="xsd:ID"/>
  </xsd:complexType>

  <xsd:complexType name="ThreadpoolWithLanesDef">
    <xsd:sequence>
      <xsd:element name="threadpoolLane" type="CIAO:ThreadpoolLaneDef" 
                   maxOccurs="unbounded"/>
      <xsd:element name="stacksize" type="xsd:unsignedLong" />
      <xsd:element name="allow_borrowing" type="xsd:boolean"/>
      <xsd:element name="allow_request_buffering" type="xsd:boolean"/>
      <xsd:element name="max_buffered_requests" type="xsd:unsignedLong"/>
      <xsd:element name="max_request_buffered_size" type="xsd:unsignedLong"/>
    </xsd:sequence>
    <xsd:attribute name="id" type="xsd:ID"/>  <!-- Threadpool ID should be 
                                                   referenced by individual policies
                                                   in the policysets below -->
  </xsd:complexType>

  <xsd:complexType name="ThreadpoolLaneDef">
    <xsd:sequence>
      <xsd:element name="static_threads" type="xsd:unsignedLong"/>
      <xsd:element name="dynamic_threads" type="xsd:unsignedLong"/>
      <xsd:element name="priority" type="CIAO:Priority"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="ConnectionBandsDef">
    <xsd:annotation>
    <xsd:documentation>
      This is only used to provide a ORB-wide view of all connection bands.
      The ORB doesn't really need to "create" this resource.
    </xsd:documentation>
    </xsd:annotation>
    <xsd:sequence>
      <xsd:element name="band" type="CIAO:PriorityBandDef" maxOccurs="unbounded"/>
    </xsd:sequence>
    <xsd:attribute name="id" type="xsd:ID"/>
  </xsd:complexType>

  <xsd:complexType name="PriorityBandDef">
    <xsd:sequence>
      <xsd:element name="low" type="xsd:int"/>
      <xsd:element name="high" type="xsd:int"/>
    </xsd:sequence>
  </xsd:complexType>

<!-- ========================================================================= -->

  <xsd:complexType name="PolicySet">
    <xsd:annotation>
      <xsd:documentation>
        Contains a set of CORBA Policies that can be applied to a
        component instance at once.  We should eventually expand this
        list to incorporate all the policies defined in
        ciaopolicy.xs.  I'm focusing on the RT aspects for now.

        The ID of a policy set should be referenced by the component
        instances in a DeploymentPlan document under the
        "deployedResource" tag.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:choice maxOccurs="unbounded">
      <xsd:element name="priorityModel" type="CIAO:PriorityModelPolicyDef"/>
      <xsd:element name="nwpriorityModel" type="CIAO:NWPriorityModelPolicyDef"/>
      <xsd:element name="cnwpriorityModel" type="CIAO:CNWPriorityModelPolicyDef"/>
      <xsd:element name="threadpool" type="xsd:IDREF"/>
      <xsd:element name="priorityBandedConnection" type="xsd:IDREF"/>
    </xsd:choice>
    <xsd:attribute name="id" type="xsd:ID"/>
  </xsd:complexType>

  <xsd:simpleType name="PriorityModel">
    <xsd:restriction base="xsd:NCName">
      <xsd:enumeration value="SERVER_DECLARED"/>
      <xsd:enumeration value="CLIENT_PROPAGATED"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="NWPriorityModel">
    <xsd:restriction base="xsd:NCName">
      <xsd:enumeration value="SERVER_DECLARED_NWPRIORITY"/>
      <xsd:enumeration value="CLIENT_PROPAGATED_NWPRIORITY"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:complexType name="PriorityModelPolicyDef">
    <xsd:sequence>
      <xsd:element name="priority_model" type="CIAO:PriorityModel"/>
    </xsd:sequence>
    <xsd:attribute name="server_priority" type="CIAO:Priority"/>
  </xsd:complexType>

  <xsd:complexType name="NWPriorityModelPolicyDef">
    <xsd:sequence>
      <xsd:element name="nw_priority_model" type="CIAO:NWPriorityModel"/>
      <xsd:element name="request_dscp" type="xsd:long"/>
      <xsd:element name="reply_dscp" type="xsd:long"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="CNWPriorityModelPolicyDef">
    <xsd:sequence>
      <xsd:element name="request_dscp" type="xsd:long"/>
      <xsd:element name="reply_dscp" type="xsd:long"/>
    </xsd:sequence>
  </xsd:complexType>

</xsd:schema>
