[Home] [Groups] - Message: [Prev in Group] [Next in Group]

nu.kanga.list.mud-dev

17833: RE: [MUD-Dev] Persistent Worlds

[Full Header] [Plain Text]
From: "Jon Lambert" <tychomud@ix.netcom.com>
Newsgroups: nu.kanga.list.mud-dev
Date: Sat, 24 Feb 2001 01:21:47 -0500
References: [1]
Organization: Kanga.Nu
Ryan Rhodes wrote:
>  Jon Lambert wrote:
 
> Ok.  I couldn't understand why the need to abstract the object model
> into your Object Manager sort of design, at first, but I'm starting
> to warm up to it.  For it to be really decoupled from the game
> though, you would need a way to count the object accesses in a
> generic fashion.  I've never really understood this about "write
> your own" caching.  Is there some generic, low-level way to "Trap"
> an object access?  I can probably figure it out in java with a
> description in C or some other language...

In C++ I use the idiom of wrapping objects up in psuedo-objects or
tokens and overloading the dereference operators.  That way you
present an class interface to the client that walks, talks, and looks
like the class it is wrapping, but allows you to "trap" an object
access.

For example...

  class ObjectToken {
  private:
    long    mObjectId;
    Object* Fetch(long);  
  public:
    ObjectToken() : mObjectId(0) {}
    ObjectToken(long id) mObjectId(id) {}
    operator Object*() { return Fetch(mObjectId); }
    Object* operator->() { return Fetch(mObjectId); }
  };

--
--* Jon A. Lambert - TychoMUD        Email:jlsysinc@ix.netcom.com *--
--* Mud Server Developer's Page <http://tychomud.home.netcom.com> *--
--* If I had known it was harmless, I would have killed it myself.*--

_______________________________________________
MUD-Dev mailing list
MUD-Dev@kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev