Jump to content
  • Advertisement
Sign in to follow this  
Johnn

Building a dynamic string vector at compilation via templates?

This topic is 4614 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've got a little problem with a profiling module I'm working on. Profiled elements are dynamic, ie. no enum or anything to describe the structure. I'm using strings so far. Example: StartTiming("Rendering") ... StartTiming("Particules") // more specific; indentation is important ... StopTiming("Particules") ... StopTiming("Particules") Now, the problem, as I see it, is that if the code doesn't reach a certain tag, it won't be in the structure (it won't show "Particules: 0 cycles" for instance until there are particules to render.) Could a more sophisticated solution use templates (template instantiation?) I'm not too familiar with that kind of programming; could it be possible to keep a totally dynamic structure (strings) while fixing the structure at compile time? Said in another way, it is possible to build a vector of strings and a vector of indentations at compile time instead of at run time? Thanks! -edit- Pretend in my example that "Particules" are indented...

Share this post


Link to post
Share on other sites
Advertisement
Hmm... Well, it depends on what you mean by that. When you launch the game, yes, the string/indent structure would be static (that's what I want.) The size of the structure would be equal to the number of different string IDs used in the whole game and that would be computed at compilation time (possible?)

But, I see it as dynamic also because you can add/remove elements and it's going to work next time you launch without having to change a hardcoded structure.

Share this post


Link to post
Share on other sites
I'm not entirely sure of what you are looking for, but you may want to take a look at the Boost Assignment library.

[edit] Oh, I think I see what you mean. Then the above is probably irrelevant. I think you will need to make a tool to scan your source files for all possible IDs and then output the correct initialization code.

jfl.

Share this post


Link to post
Share on other sites
Oh... That would be pretty inconvenient I guess...

My first idea revolved around templates because I remember reading something about computing n! at compile time with them. Any template wizz could share some opinion on that?

Thanks

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!