Home » Community » Forums » » Using Managers
  Intel sponsors gamedev.net search:   
[Control Panel] [Register] [Bookmarks] [Who's Online] [Active Topics] [Stats] [FAQ] [Search]

Add Forum to Favorites |  Send Topic To a Friend | View Forum FAQ | Track this topic


 Last Thread Next Thread 
 Using Managers
Post Reply 
Nice ideas, and indeed the concept is sound. Code that only has to be written once is always a good thing, and I've made my own resource managers on the same premise. There are a few points that could be improved, however.

One thing you might want to consider instead of the use of pointers explicitly to ID your resources is to load resources by name. Simply a string, which could be a filename, used for identification. I find this much more intuitive, and later on when creating resources which depend on other resources, it's much easier to reference these other resources by their name, given this capability.

The second point is to use some sort of hash, or a map (such as that found in the STL) to allow a generally faster search for a resource that's already present. This applies to any identification method you choose, by the way.

The third point is arguable. Do you really need to enforce the singleton nature of a manager? I would think there are better ways to design around this.

Still, nice concise article.

"Don't be afraid to dream, for out of such fragile things come miracles."

 User Rating: 1079   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

This article was very good, but I find myself using 2 different managers with the same types of objects (ie enemy players and friendly players). A good way around this is to make the Base class the singleton instead of creating a manager singleton that then is inherited. But there are always exceptions to the rule.

-ecko


 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

This article is hilarious... it embodies so much about how to NOT write code in one article, while still misleadingly looking like a valid tip... I couldn't have done it better. Reference counting a singleton object? genius!


 User Rating: 1015    Report this Post to a Moderator | Link

DIdn't I see something awful similar to this in the Game Programming Gems series??? Hmmmm....

With regard to the previous post, I believe he is reference counting the objects the manager class is managing, not the singleton manager itself.

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Well, the way you built up your singleton is not estetic, because the least thing you should do is to inline your functions to prevent sensless stackusing.

However, a singleclass solution would be better. Also the refcount is a little anoying, becaus ein a multithreaded app it often happens, that at a moment ref count is set to 0, but the data in your manager is needed in the next function or whatever.

Also pointing out, that in many cases the use of a linked or doublelinked list
has advanteges, such as dynamic arraysize.

I would accept it if it was a very simple examplecode, but you build up nearly your entire article on this code.


cYa fooman

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

All times are ET (US)

Post Reply
 Last Thread Next Thread 
Forum Rules:
You may not post new threads
You may post replies
You may not edit your posts
You may not use HTML in your posts
Jump To:
Administrative Options: