Static reflector: a pattern for object-oriented access to non-object-oriented interfaces

Somewhere near the bottom of the food chain of object oriented programming, the developer frequently encounters a non object oriented API. This paper describes a specialisation of the Wrapper Facade pattern. Wrapper Facades encapsulate functions and data provided by existing non object oriented API's. The Static Reflector addresses the particular problem of building wrappers which contain functions which take C function pointers as parameters. The pattern makes use of a static reflection method to facilitate the construction of cohesive, reusable framework classes which make use of such C functions. We show that the application of this pattern is surprisingly wide. Though concerned primarily with the interface between C and C++, the pattern has implications for and applications to other languages as diverse as Java and [incr Tcl].This pattern was workshopped at the PLOP 2001 conference, Illinois. It is structured according to the canonical form under the headings Name, Problem, Context, Forces, Solution, Resulting Context, Rationale, Examples and Related Patterns.