Click or drag to resize

Customizing the Driver Header File

The header file for an IVI-C driver (<prefix>.h) is automatically generated by Nimbus. The code generation for this file is governed by the contents of a Nimbus text template (.ntt) file included in the IVI-C driver project. Driver developers can add content to the text template file to control certain aspects of how the header is generated. For instance, #include statements can be added to the text template file and they will be retained in the generated header file.

Basics of the header file template

The text template (<prefix>.ntt) file appears in the driver project with the generated header file (<prefix>.h) appearing as a dependency.

Header File Template
Caution note Caution

Do not modify the contents of the header file (.h), as those changes will be overwritten by Nimbus.

The template file (.ntt) presents the layout of the header file that will be generated. The auto-generated portions are represented by replacement tags that are delineated by percent signs (%). For instance, the following excerpt from a template file shows two replacement tags -- %Copyright% and %PrefixUpper%.

C++
/******************************************************************************
 *                                                                         
 * %Copyright%
 *
 *****************************************************************************/

#ifndef __%PrefixUpper%_HEADER
#define __%PrefixUpper%_HEADER

#include <ivivisatype.h>

The following excerpt shows the replacement tags where Nimbus injects attribute definitions and function declarations.

C++
/*===== IVI Inherent Instrument Attributes ==============================*/
%InherentAttributeDeclarations%

/*===== Instrument-Specific Attributes =====================================*/
%SpecificAttributeDeclarations%

/****************************************************************************
*------------------------ Attribute Value Defines -------------------------*
****************************************************************************/
%AttributeValueDeclarations%

/****************************************************************************
*---------------- Instrument Driver Function Declarations -----------------*
****************************************************************************/
%FunctionDeclarations%

At build time, these tags are replaced by Nimbus code generation with the appropriate values. It is important that these values not be removed or modified. Any customizations to the help template should be done "around" these replacement tags.

Example Customization: Adding an include file

A simple and common usage for IVI-C header template files is inclusion of additional header files specific to the driver under development. In the code excerpt below, two additional include files foo.h and bar.h. are added to the text template.

C++
/******************************************************************************
 *                                                                         
 * %Copyright%
 *
 *****************************************************************************/

#ifndef __%PrefixUpper%_HEADER
#define __%PrefixUpper%_HEADER

#include <ivivisatype.h>
#include <foo.h>
#include <bar.h>

When the build runs, the resulting header file would be generated with the following content in place of the above.

C++
/******************************************************************************
 *                                                                         
 * Copyright 2020 Pacific MindWorks. All rights reserved.
 *
 *****************************************************************************/

#ifndef __ACME_HEADER
#define __ACME_HEADER

#include <ivivisatype.h>
#include <foo.h>
#include <bar.h>

Download a complete CHM version of this documentation here.