views:

80

answers:

2

I have been tasked with removing RogueWave components from a legacy C++ codebase. To do so, I am attempting to build wrappers around the existing components, make sure that the code functions the same, and then choose a different library like boost to stick into the wrappers.

One of the problems I am coming against is that much of the codebase expects pointers to RogueWave objects. I can create a dummy Wrapper Object class that points to the original RogueWave object, but I cannot figure out how to correctly wrap pieces of that RW object, such as iterator items when the code expects a modifiable pointer into the original object.

Any suggestions, or advice for alternate approaches? (Note: I am a bit rusty on my C++)

+1  A: 

Adapter Pattern

Bridge Pattern

If those do not work out:

Facade Pattern

JustBoo
I understand how these work for single classes. My problem is that I do not know/understand how to design/implement this for multiple classes. For example, if I have a RW Collection class, and inside are RW Strings, how do I access the contents of the wrapper collection as wrapper strings?
Paul
Do you mean you have something like RWCollection<RWString>, and you need to replace it with MyCollection<MyString>? I don't see the problem. Care to elaborate?
Rodyland
If I define MyCollection as an adapter that contains an instance of RWCollection<RWString>, when I iterate through MyCollection I will get pointers to RWStrings rather than MyStrings. How do I convert one to the other and return a pointer to the newly wrapping MyString?
Paul
I don't think that will work. You cannot expose any RW. So you need to wrap the RWStrings, and the RWCollection<>::iterators, and everything else.
Rodyland
Given all the comments and given how corporate directives can change like the wind; in my humble opinion, **strike while the iron is hot** (and you have the funding) and go for the Facade Pattern. I think it would fix it now, and any changes in the future, when that new manager decides it’s now going to be all boost or whatever the flavor of the month is. :-)
JustBoo
A: 

I had a similar task about 10 years ago, it turned out most of the stuff we used Roguewave for was part of the standard in C++. In most instances there was a direct C++ standard data structure that was able to replace the Roguewave usage.

If you can't do a direct replacement and might use yet another 3rd party library or your own library, the patterns that JustBoo mentioned would be ideal.