ANNOUNCE: sdl++ v0.0.10

-----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 classes
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 preprocessor
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 added.

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 exception-based
    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 instead
    of static methods.
  • Porting to 1.3. :slight_smile:

If somebody feels ambitious and adventurous enough to give sdl++ a try, please
let me now. I’d be happy to help you with any issues you run into. I also
welcome your patches. :slight_smile:

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-----

2009/8/9 Christopher Eineke :

-----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 classes
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 preprocessor
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 added.

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 exception-based
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 instead
of static methods.
? - Porting to 1.3. :slight_smile:

If somebody feels ambitious and adventurous enough to give sdl++ a try, please
let me now. I’d be happy to help you with any issues you run into. I also
welcome your patches. :slight_smile:

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
integer?

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
http://sourceforge.net/projects/sigslot/

If you want to take a look at my own SDLpp say so and I’ll send you some code.

Hi,

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
code?

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.

PersonallyOn Thu, Aug 13, 2009 at 5:24 AM, Kenneth Bull wrote:

2009/8/9 Christopher Eineke :

-----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
classes
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
preprocessor
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
added.

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
    exception-based
    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
    instead
    of static methods.
  • Porting to 1.3. :slight_smile:

If somebody feels ambitious and adventurous enough to give sdl++ a try,
please
let me now. I’d be happy to help you with any issues you run into. I also
welcome your patches. :slight_smile:

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
integer?

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
http://sourceforge.net/projects/sigslot/

If you want to take a look at my own SDLpp say so and I’ll send you some
code.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

2009/8/13 Paulo Pinto :

Hi,

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
code?

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.

Personally

Alright, so why not enum (especially if you’re worried about type
safety)? Why use floating point math when there’s no intermediate
result and the final result is stored in an integer? Why use C (float)
instead of C++ static_cast if you’re that picky? And why are
you willing to waste time and storage compiling these numbers?

Also, keep in mind that with these as defines instead of consts, the
user actually could use them at full precision in floating point code,
and in integer code, they would be optimized down to int at compile
time. That doesn’t work with const.

As I said before, I don’t have anything to do with SDL++.

But if that would have been written by me, most likely there would be some
enums as well.

And in what concerns casting, only C++ casts would be used.

Many compilers are also able to optimize away const.

When I write C++ code, I always use ANSI C++ 98 with STL and all the good
advices from
the most well known C++ gurus.

Only if performance requires it, I will go down to low level tricks and C
style code.

This is nothing new actually, I have worked in a few places with C++ coding
standards that
required such coding.

Just to give an example,
http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Preprocessor_Macros

Anyway for me this is going off topic, specially since I don’t have anything
to do with SDL++ and
because of that I should not speak for the author.–
Paulo

On Thu, Aug 13, 2009 at 5:24 PM, Kenneth Bull wrote:

2009/8/13 Paulo Pinto <@Paulo_Pinto>:

Hi,

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
code?

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.

Personally

Alright, so why not enum (especially if you’re worried about type
safety)? Why use floating point math when there’s no intermediate
result and the final result is stored in an integer? Why use C (float)
instead of C++ static_cast if you’re that picky? And why are
you willing to waste time and storage compiling these numbers?

Also, keep in mind that with these as defines instead of consts, the
user actually could use them at full precision in floating point code,
and in integer code, they would be optimized down to int at compile
time. That doesn’t work with const.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org