<?xml version="1.0" encoding="UTF-8"?>

<!--================================================================-->
<!-- Copyright 2003 P&P Software GmbH             -->
<!--================================================================-->

<!--===================================================================
Generator mea-component for an "#include" file that defines the 
parameter identifiers for a parameter database to be used in the OBS 
Framework. The include file generated by this code generator should be 
included by all classes that wish to have access to the items in the
parameter database by using symbolic names for the identifier.

This XSLT program process an XML file that describes the parameter 
database.
===================================================================-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.1"
    xmlns:lxslt="http://xml.apache.org/xslt"
    xmlns:redirect="org.apache.xalan.lib.Redirect"
    extension-element-prefixes="redirect">

<xsl:strip-space elements="*"/>
<xsl:output omit-xml-declaration="yes" method="text"/>

<!--===================================================================
       Include general utility rules
===================================================================-->
 <xsl:include href="ClassNameFromPath.xsl"/>
<!--===================================================================
      Top-level rule 
===================================================================-->
<xsl:template match="/ObsApplication/ParameterDatabase/IndexedDatabase">
<!--===================================================================
      Define general-purpose variables
 ===================================================================-->  
  <xsl:variable name="ClassName">
        <xsl:call-template name="ClassNameFromPath">
              <xsl:with-param name="path" select="@type"/>
        </xsl:call-template>
  </xsl:variable>
  <xsl:variable name="CodeDir" select="'../'"/>

  <!-- start code generation                                       -->
  <xsl:variable name="TargetFile" select="concat('/Projects/ObsFramework/src/cpp/',@type)"/>     
            
  Generating code for class <xsl:value-of select="$ClassName"/> in files <xsl:value-of select="$TargetFile"/>_inc.h

  <!-- Check whether writing to an output file is possible -->
  <xsl:if test="not(element-available('xsl:document'))">
        FATAL ERROR: the xsl:document element is not supported. Header files cannot be written! This element
        is normally supported only in version 1.1 of XSL.
  </xsl:if>
            
  <!-- ===================================================================================
         Create the output file  
          ===================================================================================-->
  <xsl:document href="{$TargetFile}_inc.h" omit-xml-declaration="yes" method="text">  

//
// Copyright 2004 P&amp;P Software GmbH - All Rights Reserved
//
// <xsl:value-of select="$ClassName"/>_inc.h
//
// This file is automatically generated by an XSL program
//

/**
 * @file <xsl:value-of select="$ClassName"/>_inc.h 
 * This file defines symbolic names for the parameter identifiers for the
 * parameter database defined in class &lt;code&gt;<xsl:value-of select="$ClassName"/>&lt;/code&gt;.
 * The symbolic names are obtained by capitalizing the name of the database
 * parameter as given in the XML database descriptor file and adding the prefix
 * "DB_" to it.
 * Classes that wish to use symbolic names to access the parameters in the database
 * should include this file. 
 * This file was generated automatically by an XSL program that processes the 
 * XML-based application model.
 * @see <xsl:value-of select="$ClassName"/>
 */

#ifndef <xsl:value-of select="$ClassName"/>_incH
#define <xsl:value-of select="$ClassName"/>_incH

#include "<xsl:value-of select="$CodeDir"/>GeneralInclude/BasicTypes.h"

<xsl:for-each select="Parameter">
  <xsl:variable name="CapName" select="translate(
          Name/@value,'abcdefghijlmnopqrstuvywz','ABCDEFGHIJLMNOPQRSTUVYWZ')"/>
const TD_DatabaseId DB_<xsl:value-of select="$CapName"/> = <xsl:value-of select="Id/@value"/>;<xsl:text/>
</xsl:for-each>

#endif
</xsl:document>
</xsl:template>


</xsl:stylesheet>

