struct tank info, where to put it?

Dirk Hohndel dirk at hohndel.org
Mon Apr 15 09:41:27 PDT 2013


Tomaz Canabrava <tcanabrava at kde.org> writes:

> Continuing my port of the Cylinders, there`s a struct defined in
> equipment.c, named tank_info ( plus related functions ).
> Since I need a tank info on the Qt part too, I`m putting t the tank_info
> struct in the equipment.h ( and as usual, correct me if I`m wrong )

That works... this is basically what I am doing whenever I split logic
and UI for the other parts of Subsurface. You just got to equipment.c
before I did.

> There`s also an array of 100 tank_infos, that are filled manually on
> equipment.c too,
>
> 1 - what about porting this to a flat csv, json, xml style file?
>
> This is good for maintenability, since we can add more types without
> compiling the code.

Hadn't thought of that. I don't necessarily see this as wrong, I just
wonder if it really makes our lives easier. It's just another file that
needs to be packaged and then opened. The user can add Cylinders just as
easily when they enter a dive - and it's then automagically added to the
drop down list the next time they enter a dive.

So I don't think this buys us anything.

> 2 - I don`t want to put the initialization of the tank_info in the cpp
> files, since the logic code should not be in c++ , where can I put it? The
> code in equipment.c is full of GTK.

Leave it in equipment.c.

As I just said on IRC - once you have something to pull I'll take over
and split this into equipment.c and equipment-gtk.c

/D


More information about the subsurface mailing list