Thread: Final resource mgr design

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607

    Final resource mgr design

    After using my extremely flawed resource manager I finally re-designed it.

    Here is the new design.

    BaseMgr
    -----------
    - A template mgr class that wraps a map<unsigned int, T* pObject>.
    - Supports Add, Remove, Get, and Update.
    - Cleans up memory during destruction

    DerivedMgr
    --------------
    - Simply derive from manager base and set the template type.


    ResMgr
    ---------
    - Class that wraps a vector of BaseMgr objects - ID is returned to user when
    object is added - unique ID which is just the size_t index of the object
    - Supports Add, Remove, Get, and Update
    - Cleans up memory during destruction


    Nice and simple and handles all my resources. It would be easy to add in a cache to disk scheme in the update function of BaseMgr.

    Comments? I did it this way b/c most of the manager classes shared the same traits and basic operations. Coding those for every type of manager became really annoying. And now I have a nice way of wrapping all the manager's into one object called a resource manager. The main app class has a pointer to this which can then be used to access the manager's it contains.

    The only problem now is the size_t index of the manager's in the ResMgr vector. This would not be known to other objects and the only scheme I can come up with is an enum that these objects can use to access the manager objects. I don't like this but haven't figured out a better method yet.
    Last edited by VirtualAce; 07-08-2008 at 11:14 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sorting out a resource manager
    By psychopath in forum Game Programming
    Replies: 1
    Last Post: 11-10-2008, 07:12 PM
  2. CreateProcess with Resource of executable, not the Filename
    By Ktulu in forum Windows Programming
    Replies: 4
    Last Post: 11-04-2006, 01:07 AM
  3. Generic Resource_Manager WIP with lots TODO
    By Shamino in forum C++ Programming
    Replies: 19
    Last Post: 02-01-2006, 01:55 AM
  4. resource problem/question
    By stallion in forum Windows Programming
    Replies: 4
    Last Post: 01-29-2003, 02:08 PM
  5. Serial Communications in C
    By ExDigit in forum Windows Programming
    Replies: 7
    Last Post: 01-09-2002, 10:52 AM