Appendix B Creating Wrapped Classes
For instance, to wrap a C++ class called IntStack as a wrapped class called DSIntStack, you write a file called DSIntStackRO.wrp and run the wrap script. The wrapper generates the class named DSIntStackRO, writing the files DSintStackRO.h to declare it and DSintStackRO.cc to implement it. The command line interface to the wrap script determines where to place the generated files. It is described in Section B.3.1, "Command Line Interface" page 286.
We call the C++ class that we want to wrap the foundation class. In our example, the class IntStack is the foundation class. We encourage programmers to think of the wrapper class as a translation layer only, turning ADL messages and member assignments into calls to an instance of the foundation class. In the example, when you create an instance of DSintStackRO, the DSintStackRO constructor creates a corresponding IntStack instance. ADL messages such as Push and Pop translate into calls on that instance of IntStack. By making it easy for a wrapped object to use an instance of the foundation class, the wrapper encourages programmers to put very little into the wrapped class.
Generated with Harlequin WebMaker