Chapter 6. Implementation Considerations


IN THIS CHAPTER

C++ Concepts

Memory Alignment

Handles and Rep objects

Iterators (pixel and STL)

Exception-Safe Locking

Image Framework Concepts

Image Datatypes

Image Coordinates

Image Storage

Image Object (Final Design)

Image Filtering Functions

Interfaces to Third-Party Software

In this chapter, we apply what we have learned through prototyping and examples to finalize the design for the image framework. The components of the framework are shown in Figure 6.1.

Figure 6.1. Image Framework Components

graphics/06fig01.gif

Our design has had many iterations, using a variety of C++ techniques. We started by using inheritance to create a framework that could handle numerous image types. It quickly became apparent in our subsequent prototype that templates both improved and simplified the design by eliminating most of the object hierarchy. However, we were still including image storage as a component of the image class, instead of separating it as an image component. We also explored using handles, but found they did nothing to improve the design. Once we prototyped a solution that separated storage from the image class, we knew that the final design was close at hand.

Each prototype was incomplete, but collectively they allowed us to test different design principles. We used a single, trivial, image processing function (computing thumbnail images) to observe the merits of each design. And, we wrote a unit test for each prototype to verify the correctness and the behavior of memory allocation, and to verify how pixels are accessed.

Often, the final design grows out of one or more prototypes. Sometimes it is obvious that you have hit on the right design, and other times it becomes an iterative process. From our prototypes , we applied the following ideas:

  • Image storage should be separate from the image processing functions. The image storage classes are independent of the image processing functions (but not vice versa).

  • Templates should be used for a more efficient design, allowing us to: produce a single version of code that works with any pixel type; optimize performance where needed by using specialization; and adapt our image storage component to use other memory allocators .



Applied C++
Applied C++: Practical Techniques for Building Better Software
ISBN: 0321108949
EAN: 2147483647
Year: 2003
Pages: 59

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net