Policy Based Design Using C++ Typemaps
Policies provide effective method of customizing class behavior. The standard way of providing policies is simply passing them to the class during instantiation or using typedef constructions. Both methods require knowledge about each policy position in template parameter list. Besides, if the required policy is not the first on the template parameter list, then the programmer is required to supply all the previous parameters. Moreover, the designer of class can't easily modify policy list without modifying the code where the class is used.
The proposed is method of using typemaps for providing policies. Typemaps are built using C++ meta-programming techniques. Each element of typemap contains the key and value parts. The key contains the policy category, and the value represents the policy itself. The programmer has to build the policy meta-container and pass it to every used class. The programmer, normally, would take the default policy list and replace only the necessary ones. Then the class accepts the whole list and chooses only the needed policies. Typemaps make policy based design easier and more convenient.
Copyright (C) 2005,2006,2013 Andre Mirzoyan