[MUD-Dev] Persistent Worlds
Jon Lambert
tychomud at ix.netcom.com
Sat Feb 24 01:21:47 CET 2001
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 at 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 at kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev
More information about the mud-dev-archive
mailing list