Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


demonkoryu

Member Since 14 Mar 2004
Offline Last Active May 06 2014 10:31 AM

Topics I've Started

Compile-time polymorphism methods for cross-platform C++

12 October 2010 - 02:13 AM

Let's discuss methods for compile-time polymorphism in C++.

Background: In my current toy app (a file manager), I want to keep the platform-specific implementations in their own classes and namespaces, but use them without specifying a specific namespace/implementation.

These classes share the same interface, but since the platform will be known at compile time, I don't want to use abstract factories and pay for virtual function calls (however small that cost may be).

(Note: I don't plan to port this file manager over to *nix. I'm experimenting with coding techniques to improve code quality and organization.)

For example, consider a simple debug console.


// pseudocode:
interface console {
public:
static console &getSingleInstance();

void write(const std::wstring &);
void setTitle(const std::wstring &);
void clear();

protected:
console();
}


This interface will have several implementations, for example win32::console and unix::console.
But in my app, I just want to do this:

console &con = console::getSingleInstance();


without having to worry about the current platform.

Assuming that there are many of these classes, what are the different methods to achieve this, and their pros/cons?

I came up with a few ideas how this can be done, and hope that you will criticise them.

I'm assuming a modern compiler (VC++ >= 8 or GCC >= 4.5) here, so I'm open for techniques that may work only with them.


  • Preprocessor switch in a platform-independent header pulls in different implementation? Kinda defeats the namespaces.

  • Using namespaces and pull the platform-specific classes into the platform-independent namespace via using?

  • Using templates and tag dispatching? Define a "platform" tag type (struct) and have template specializations default to this "current platform" tag?

  • Maybe there is another template-based/template metaprogramming-based approach?

  • Use abstract base classes and cast to derived type?

  • Are there other methods?



[Edited by - Konfusius on October 12, 2010 10:45:41 AM]

id software released RTCW and W:ET source code

13 August 2010 - 01:29 AM

Yesterday, id software released the full source code for RTCW and W:ET.

Clicky

I'm happy that this has finally happened.

After Wolfenstein has failed to capture the die-hard multiplayer community of RTCW and W:ET, I hope that the modding community will take this and give the old games a much needed brush over.

Cheers!

_why?

31 August 2009 - 03:22 AM

Just stumbled across this: Eulogy to _why For me, _why is/was a key Ruby figure, a legend one could say. Even tough I couldn't read his texts (too crazy for me ^_^) I've used more than one of projects. Then... suddenly he removes himself from the internet and everyone (including me) is thoroughly bewildered/sentimental. Thoughts?

[web] Free Flash authoring software?

20 August 2009 - 03:41 AM

Is there any (free/low-cost) software for authoring Flash widgets for the web?

Just for fun: Delta Force vs. SWAT

21 March 2009 - 06:08 AM

As an FPS gamer, I had this setting several times in my mind: Delta Force vs. SWAT team, "IRL". Setting: An urban building, let's say an isolated standing 6 level buro building, has been captured. There are 24 people on each team. One team is the defender, the other must enter from outside. Three games are played, each consisting two rounds; after the first round, positions are swapped. Standard FPS weapons are issued (not including rocket launchers and large explosives). What do you think, who would win?

PARTNERS