Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

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

Sign in to follow this  


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.
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!