[SDL] ANNOUNCE: sdl++ v0.0.10
pjmlp at progtools.org
Thu Aug 13 00:47:02 PDT 2009
I don't have anything to do with SDL++, but I would step in and say the
answer could be:
Because it is a good application design not to have "magic numbers" on the
Regarding "#define" I only use them nowadays when there is any other
solution, like conditional compilation.
For macros use templates and for constants use const. Both are more type
safe than a simple #define.
On Thu, Aug 13, 2009 at 5:24 AM, Kenneth Bull <llubnek at gmail.com> wrote:
> 2009/8/9 Christopher Eineke <chris at chriseineke.com>:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA512
> > SDL++: A C++ Layer For SDL (Simple Direct Media Library)
> > SDL++ is a C++ layer on top of SDL. It provides wrapper classes for SDL
> > functionality. Highlights include templated event, timer, and task
> > that provide a type-safe way to send event data from event sources to
> > listeners, decentralized event dispatch and handling, and handy wrapper
> > classes for almost all SDL types.
> > This release adds partial support for libSDL_image (by defining a
> > macro, see SDL++.hpp and surface.hpp for details) and a class for library
> > initialization and providing access to SDL errors and loading of shared
> > objects. The test suite is also expanding and one code example has been
> > Right now on my TODO list are:
> > - Adding public const& members like in Surface to other wrapper classes
> > - Converting boolean return code-based error handling to
> > error handling
> > - Completing support for libSDL_image.
> > - Adding support for other SDL-based libraries.
> > - Completing the documentation.
> > - RW_ops needs an overhaul so that clients can use virtual methods
> > of static methods.
> > - Porting to 1.3. :-)
> > If somebody feels ambitious and adventurous enough to give sdl++ a try,
> > let me now. I'd be happy to help you with any issues you run into. I also
> > welcome your patches. :-)
> > Get v0.0.10 at http://www.chriseineke.com/sdl++/index.html or take a
> look at
> > the online documentation generated with Doxygen at
> > http://www.chriseineke.com/sdl++/doc/html/index.html.
> > Best regards,
> > Chris
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.4.9 (GNU/Linux)
> > iEYEAREKAAYFAkp+V28ACgkQPOmqd0kEEbs1XACggx/GLFK3GhOVQfc0z5jlu96Q
> > rwIAoMCAowg3FgiWg84YVMSePXondHQp
> > =Mx/p
> > -----END PGP SIGNATURE-----
> > _______________________________________________
> > SDL mailing list
> > SDL at lists.libsdl.org
> > http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
> ok, this is just an example.
> This is from http://www.chriseineke.com/sdl++/doc/html/namespacesdlpp.html
> I haven't looked at the source code itself yet.
> const unsigned MILLIS_PER_SECOND = 1000
> const unsigned HZ_1 = ((float) MILLIS_PER_SECOND / 1)
> const unsigned HZ_2 = ((float) MILLIS_PER_SECOND / 2)
> const unsigned HZ_5 = ((float) MILLIS_PER_SECOND / 5)
> const unsigned HZ_10 = ((float) MILLIS_PER_SECOND / 10)
> const unsigned HZ_25 = ((float) MILLIS_PER_SECOND / 25)
> const unsigned HZ_30 = ((float) MILLIS_PER_SECOND / 30)
> const unsigned HZ_50 = ((float) MILLIS_PER_SECOND / 50)
> const unsigned HZ_60 = ((float) MILLIS_PER_SECOND / 60)
> const unsigned HZ_100 = ((float) MILLIS_PER_SECOND / 100)
> const unsigned HZ_200 = ((float) MILLIS_PER_SECOND / 200)
> const unsigned HZ_250 = ((float) MILLIS_PER_SECOND / 250)
> const unsigned HZ_500 = ((float) MILLIS_PER_SECOND / 500)
> const unsigned HZ_1000 = ((float) MILLIS_PER_SECOND / 1000)
> Why are these constants defined like this?
> MILLIS_PER_SECOND is not implementation specific. There are 1000
> milliseconds per second no matter what, so why use a constant instead
> of the number? Should this be, say, TIMER_GRANULARITY instead?
> Why are you using constants instead of defines in the first place? Is
> it just to keep it in the namespace? Why not use an enumeration? Why
> are you using floating point math when you're storing the result in an
> Also, it seems you're trying to make some sort of signal / slot
> mechanism for event handling. You might want to take a look at
> http://sourceforge.net/projects/signalslot/ or
> If you want to take a look at my own SDLpp say so and I'll send you some
> SDL mailing list
> SDL at lists.libsdl.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SDL