Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dataset wrapper object

Status
Not open for further replies.

Griffyn

Programmer
Jul 11, 2002
1,077
AU
Hi all,

Working on this RPG that I've mentioned previously. My previous post regarding it was about a Visual component for a character, and having it linked to a non-visual object that actually contained all the stats and methods for manipulating the stats (ie. Picking up Armour would change Armour Protection stat).

I've set up the non-visual object already with fields and properties, etc., but now I'm thinking changing this to become a dataset wrapper would be a better way - and I'm interested in anyone's comments.

When I say wrapper - I mean that the non-visual object would not contain any fields relating to stats, or item lists (like weapons, potions, etc.), but instead the relevant properties would call functions that would directly read from the dataset. Similarly, writing to the properties would update the dataset. This approach would eliminate the need for a loading/saving routine, and the built-in caching routines in the datasets (and Windows) would not slow things down imo.

There would be a little bit of structuring involved to ensure efficient use of dataset objects - I wouldn't want every item to need it's own dataset of course.

I haven't thought this through enough to see if there's potential pitfalls waiting for me later on with either approach, perhaps somebody's already done this exercise?

Thanks.
 
Look at the VCL code for the TDBGrid. When it paints a row it reads the required row of the dataset with out scrolling the dataset. You could then have one dataset referenced by all items, with one record per item. Presumably performance is a big issue for your app: scroll=slow.

It does it via TDataLink, I think. Much of the code is embedded in DB.pas in private methods, but you may be able to use it.

Hope this helps
Simon

 
Thanks Simon, I'll definitely take a squiz at that.

The more I think about the wrapper approach, the more I'm likely it. Down the track if I make this a multi-player game, there will be pretty much no work involved in keeping everything in sync, because all the game data sharing will be handled by the database engine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top