Porting to C++ Part I: There and back again

Published March 30, 2006
Advertisement
After finding myself bogged down with design issues which would be easy to solve in C++, I finally decided to make the big switch. So a couple of days ago, I embarked on my quest to port 26,000 lines of C code. I started with the config and math systems, using accessor objects and templates... lots of templates. They both remain incomplete for now.

I'm now in the process of developing the logging system. I've managed to override clog and cerr with custom source buffers. The source distributes output to various sinks. Currently, I've got basic console, file, and message (box) sinks implemented. The concept is similar to what I had in C, with the addition of wchar_t support.

While writing the win32 implementations of the console and message sinks, I ran into the issue of how to deal with multiple platform implementations. In C, I would compile-in platform specific source files, chosen by the build system, which would provide implementations for platform-dependent functions. With C++, you would derive platform specific classes from an abstract base class. The problem was how to choose which implementation to instantiate at build-time. Suddenly I realized the awsome power of the abstract factory pattern! I had never really understood its usefulness before. Case closed.
Previous Entry Windows Installer
Next Entry Hello again
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

Advertisement