5.5   Wind Foundation Classes

The Wind Foundation Classes include three libraries:

  • VxWorks Wrapper Class library
  • Tools.h++ library from Rogue Wave Software

The VxWorks Wrapper Class library provides a thin C++ interface to several standard VxWorks modules. The Tools.h++ foundation class library from Rogue Wave Software supports a variety of C++ features.


*

CAUTION: In order to prevent dependency conflicts between VxWorks libraries and Rogue Wave libraries, all VxWorks libraries, including the VxWorks Wrapper Class Library, should be included before all Rogue Wave libraries, including the Tools.h++ library.

5.5.1   VxWorks Wrapper Class Library

The classes in this library are called wrapper classes because each class encapsulates, or wraps, the interfaces for some portion of standard VxWorks functionality. Select INCLUDE_CPLUS_VXW for inclusion in the project facility VxWorks view to configure this library into VxWorks; see 5.2.4 Configuration Constants.

The VxWorks Wrapper Class library header files reside in the standard VxWorks header file directory, installDir/target/h. The classes and their corresponding header files are shown in Table 5-1. To use one of these classes, include the corresponding header file in the appropriate modules of your application.

Table 5-1:  Header Files for VxWorks Wrapper Classes 


Header File
Description

vxwLoadLib.h  
Object module loader and unloader (wraps loadLib, unldLib, moduleLib
vxwLstLib.h  
Linked lists (wraps lstLib
vxwMemPartLib.h  
Memory partitions (wraps memLib
vxwMsgQLib.h  
Message queues (wraps msgQLib
vxwRngLib.h  
Ring buffers (wraps rngLib
vxwSemLib.h  
Semaphores (wraps semLib
vxwSmLib.h  
Shared memory objects (adds support for shared memory semaphores, message queues, and memory partitions) 
vxwSymLib.h  
Symbol tables (wraps symLib
vxwTaskLib.h  
Tasks (wraps taskLib, envLib, errnoLib, sigLib, and taskVarLib
vxwWdLib.h  
Watchdog timers (wraps wdLib

The VxWorks Wrapper Classes are designed to provide C++ language bindings to VxWorks modules that are inherently object-oriented, but for which only C bindings have previously been available. Figure 5-1 shows the inheritance relationships for all of the VxWorks Wrapper Classes. The classes are named to correspond with the VxWorks features that they wrap. For example, VXWMsgQ is the class of message queues, and provides a C++ interface to msgQLib.


*

CAUTION: The classes VXWError and VXWIdObject are used internally by the VxWorks Wrapper Classes. They are listed in Figure 5-1 for completeness only. These two classes are not intended for direct use by applications.

Example 5-3:  Watchdog Timers

To illustrate the way in which the wrapper classes provide C++ language bindings for VxWorks objects, the following example exhibits methods in the watchdog timer class, VXWWd. See 2.6 Watchdog Timers for general information about watchdog timers.

/* Create a watchdog timer and set it to go off in 3 seconds. */ 
 
/* includes */ 
 
#include "vxWorks.h" 
#include "logLib.h" 
#include "vxwWdLib.h" 
 
/* defines */ 
 
#define  SECONDS (3)
task (void) { /* Create watchdog */
[1]      VXWWd myWatchDog; 
 
        /* Set timer to go off in SECONDS - printing a message to stdout */ 
 
[2]      if (myWatchDog.start (sysClkRateGet( ) * SECONDS, logMsg, 
                    int ("Watchdog timer just expired\n")) == ERROR) 
        return (ERROR); 
 
        while (TIMER_NEEDED) 
                    { 
                    /* ... */ 
            } 
[3]      }    

A notable difference from the C interface is that the wrapper classes allow you to manipulate watchdog timers as objects rather than through an object ID. Line [1] creates and names a watchdog object; C++ automatically calls the VXWWd constructor, implicitly invoking the C routine wdCreate( ) to create a watchdog timer.

Line [2] in the example illustrates how to use a method from the wrapper classes. The example invokes the method start( ) for the instance myWatchDog of the class VXWWd to call the timer. Because this method is invoked on a specific object, the argument list for the method start( ) does not require an argument to identify which timer to start (unlike wdStart( ), the corresponding C routine).

Finally, because myWatchDog is a local object, exiting from the routine task( ) on line [3] automatically calls the destructor for the VXWWd watchdog class. This implicit call to the destructor deallocates the watchdog object, and if the timer was still running removes it from the system timer queues. Thus, for objects declared on the stack, it is not necessary to call a routine equivalent to the C routine wdDelete( ). (However, if an object is created dynamically with the operator new, you must delete it explicitly with the operator delete, once your application no longer needs the object.)

For details of the wrapper classes and on each of the wrapper class functions, see the VxWorks Reference Manual.

5.5.2   Tools.h++ Library

Tools.h++ is an industry-standard foundation class library from Rogue Wave Software which supports the following features:

This library is configured into VxWorks by selecting INCLUDE_CPLUS_TOOLS for inclusion in the project facility VxWorks view; see 5.2.4 Configuration Constants.

The Tools.h++ library header files reside in the VxWorks header file directory installDir/target/h/rw. To use this library, #include one or more of these header files after the #include "vxWorks.h" statement and after the #include statements for all other VxWorks libraries in the appropriate modules of your application. For a list of all the header files and details on this library, see Rogue Wave's Tools.h++ Introduction and Reference Manual.