gpointer question



G'Day !

I am writing a CAD application. The 3-D modeler part is very generic, so it can be used for any engineering displine, called modes.

The system data is contained in list of models. Each model structure has pointers to parts, layers, geometric data etc. But I also need to add a struct containing mode specific data. For example a ship would have a length, beam, draft, etc., but this information has no meaning for lets say a dam in a civil engineering model.

From what I have read, it looks like I can use a gpointer to add the data to my struct. Unfortunately, I really do not understand how (self taught, and not covered in my C books).

Here is an simplified example of what I would like to try:

typedef struct {
        int  model_id;
        int  active;
        int  units;
        typGeometry  geodata;
        gpointer  modeldata;
} typModel;

typdef struct {
        float length;
        float lwl;
        float beam;
        float draft;
        float depth;
} typShip;

So I want to get the gpointer in the typModel struct to point to the typShip struct. The trick is that I do not know the size of the struct pointed to until the assignemt at runtime (a designer may use the typMachine struct).

Any help would be appreciated.

Thanks.

cheers,
Jim Parker


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]