Platform independent classes
Does anybody know of any good links that discuss designing (or converting) C++ classes that require platform independence (or at least with a set of specific platforms in mind). The idea is to not riddle the code with tons of #ifdef's. In my own mind, a good link that talks about designing such classes should take into consideration calls to library functions that may have slightly different signatures and/or return values on different platforms, different system include files between the various platforms, etc. I seem to be striking out googling for this. Thanks for your help.
Re: Platform independent classes
So long as you avoid using platform-dependent libraries, and user minimal wrappers where you must do so, it really isn't that hard.
Re: Platform independent classes
Have a look at the Bridge Design Pattern.
Re: Platform independent classes
You could create a base interface class with the cross platform functionality but with pure virtual platform dependent functions. Then define platform dependent concrete classes derived from it.
Re: Platform independent classes
Quote:
Originally Posted by JohnW@Wessex
You could create a base interface class with the cross platform functionality but with pure virtual platform dependent functions. Then define platform dependent concrete classes derived from it.
Actually, this is similar to the route I was thinking about taking. I just didn't know whether it would be the best path to start down, that's why I was wondering about other types of solutions that I haven't thought about or just aren't aware of. Thanks for your input.
Quote:
Originally Posted by _uj
Have a look at the Bridge Design Pattern.
I'm not familar with this particular design pattern, but I'll take a look at it. Thanks.