Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

9.8 Portable Guard Classes

Guarding other classes follows the same pattern. Assuming that all guards follow the pattern GuardXXX, where XXX is a DBTools.h++ class name, you can use a simple macro to provide a portable interface, whether or not the compiler uses templates. The macro would look something like this:

The first macro concatenates the word Guard with the name of the object, RWDBConnection, and creates an instance of that class called guard_, initialized with the OBJECT (conn). The second macro simply instantiates an instance of class Guard with type CLASS (CLASS = RWDBConnection). Even if your compiler or application does not support templates, you can use these macros in a portable manner as follows:

Even when using the portable guard class template, you must still create a specialized guard class for each DBTools.h++ object type you want to guard. For example, to guard an RWDBSchema, you have to create:

This is necessary in addition to using GUARD(RWDBSchema, mySchema) in your code.



Previous fileTop of DocumentContentsIndexNext file

©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.