<?xml version="1.0" encoding="UTF-8"?>

<!--================================================================-->
<!-- Copyright 2003 P&P Software GmbH             -->
<!--================================================================-->

<!--===================================================================
Generator meta-component for the test case for the indexed parameter 
database class of the OBS Framework. 
          
This XSLT program generates the header file of the parameter database 
test case class.

This XSLT program process an XML file that describes the parameter 
database. The structure of the XML file is described in the XSLT 
program that generates the header of the indexed parameter database
(see file GenerateParameterDatabase.h).
===================================================================-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  version="1.1">

<xsl:strip-space elements="*"/>
<xsl:output omit-xml-declaration="yes" method="text"/>

<!--===================================================================
       Include general utility rules
===================================================================-->
 <xsl:include href="ClassNameFromPath.xsl"/>
 <xsl:include href="ClassIdFromClassName.xsl"/>
<xsl:include href="WriteCommentBody.xsl"/>
<xsl:include href="MakeFirstLetterCap.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="ClassId">
        <xsl:call-template name="ClassIdFromClassName">
              <xsl:with-param name="className" select="$ClassName"/>
        </xsl:call-template>
  </xsl:variable>
  <xsl:variable name="CodeDir" select="'../'"/>
  <xsl:variable name="Level" select="RobustnessLevel/@value"/>

  <!-- construct the name of the test case class                   -->
  <xsl:variable name="TestCaseClassName" select="
    concat('TestCase',substring($ClassName,4,string-length($ClassName)),'_1')"/>

  <!-- start code generation                                       -->
 <xsl:variable name="TargetFile" select="concat('/Projects/ObsFramework/src/cpp/RegressionTest/',$TestCaseClassName)"/>     
            
  Generating code for class <xsl:value-of select="$ClassName"/> in files <xsl:value-of select="$TargetFile"/>.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}.h" omit-xml-declaration="yes" method="text">  
//
// Copyright 2003 P&amp;P Software GmbH - All Rights Reserved
//
// <xsl:value-of select="$TestCaseClassName"/>.h
//
// This file was automatically generated by an XSL program
//

#ifndef <xsl:value-of select="$TestCaseClassName"/>H
#define <xsl:value-of select="$TestCaseClassName"/>H

#include "<xsl:value-of select="$CodeDir"/>Utilities/TestCaseWithEvtCheck.h"

/**
 * Verify the functionalities implemented by the
 * &lt;code&gt;<xsl:value-of select="$ClassName"/>&lt;/code&gt; component.
 * An instance of the component is created and the following
 * specific tests are performed upon it: &lt;ol&gt;
 * &lt;li&gt;It is verified that the class ID of the component has the correct 
 * value.&lt;/li&gt;
 * &lt;li&gt;It is verified that, after instantiation, the configuration service
 * of the component reports "not configured".&lt;/li&gt;
 * &lt;li&gt;The component is configured and it is verified that the configuration service
 * of the component reports "configured".&lt;/li&gt;
 * &lt;li&gt;It is verified that the operational table is initialized to hold a copy
 * of the default table.&lt;/li&gt;
 * &lt;li&gt;The setter and getter methods for all parameter types are verified.&lt;/li&gt;
 * &lt;li&gt;The pointer getter methods for all parameter types are verified.&lt;/li&gt;  <xsl:text/>
   <xsl:if test="$Level!=1">
 * &lt;li&gt;Non-nominal behaviour check: it is verified that a call to a setter method with an illegal
 * parameter identifier results in the generation of an "illegal database access" event 
 * report.  &lt;/li&gt;
 * &lt;li&gt;Non-nominal behaviour check: it is verified that a call to a pointer getter method with an illegal
 * parameter identifier results in the generation of an "illegal database access" event 
 * report.  &lt;/li&gt;
   </xsl:if>
   <xsl:if test="$Level=3">
 * &lt;li&gt;Non-nominal behaviour check: it is verified that a call to a getter method with an illegal
 * parameter identifier results in the generation of "illegal database access" event 
 * report.  &lt;/li&gt;
   </xsl:if>
 * &lt;/ol&gt;
 * Note that the code for this test class - like the code for the component it tests -
 * is automatically generated by an XSLT program. The XSLT program takes as an input an
 * XML file (the 'Parameter Database Descriptor File') that describes the structure
 * of the database encapsulated in the component being tested.
 * @see <xsl:value-of select="$ClassName"/>
 * @author Alessandro Pasetti (P&amp;P Software GmbH)
 * @version 1.0
 */
class <xsl:value-of select="$TestCaseClassName"/> : public TestCaseWithEvtCheck {

public :

     /**
      * Set the identifier and the name of the test case to: 
      * <xsl:value-of select="$ClassId"/>*10+1 and "<xsl:value-of select="$TestCaseClassName"/>".
      */
     <xsl:value-of select="$TestCaseClassName"/>();

     /**
      * Execute the test case. See class comment for details.
      */
      virtual void runTestCase();
};

#endif
</xsl:document>
</xsl:template>

</xsl:stylesheet>

