Jump to content
  • Advertisement
Sign in to follow this  
jjd

Global lookup

This topic is 4481 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a property that I expose to the user through an enum (I'm using C++ FYI). Basically, the enum contains a bunch of qualitative options so that the user doesn't have to worry about raw numbers (designers... [rolleyes]). Now, I want to create a lookup table of the values that the various enum terms correspond to and I wanted to know what is a "good" (read: safe, design friendly, not make me look like-the-n00b-I-am) way of doing this?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by jjd
I have a property that I expose to the user through an enum (I'm using C++ FYI). Basically, the enum contains a bunch of qualitative options so that the user doesn't have to worry about raw numbers (designers... [rolleyes]). Now, I want to create a lookup table of the values that the various enum terms correspond to and I wanted to know what is a "good" (read: safe, design friendly, not make me look like-the-n00b-I-am) way of doing this?
I don't presume to have an answer, but I'm curious as to what exactly you mean by a lookup table in this context. Do you mean mapping the enum values to some other set of values, or perhaps vice versa?

Share this post


Link to post
Share on other sites
That's right, a one-to-one mapping between the enum values and a bunch of other numbers.

Share this post


Link to post
Share on other sites
Quote:
Original post by jjd
That's right, a one-to-one mapping between the enum values and a bunch of other numbers.
std::map<>?

[Edit: That's assuming the enum-values are non-contiguous and/or don't start at 0. Otherwise a simple array might suffice.]

Share this post


Link to post
Share on other sites
Yeah, that's the obvious first approach but I don't really want to create a global variable that I will have to pass among all the projects in our game. I was hoping there might be some subclassing magic that I could invoke.

Share this post


Link to post
Share on other sites
Thanks for the help, jyk! In the end I created a static array in a static method.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!