|
From: | Till Heuschmann |
Subject: | Re: [libredwg] Reply to review about proposal |
Date: | Sat, 25 May 2013 21:44:30 +0200 |
Hi Gaganjyot, your examples are high level but need some note:
There is a Dwg_Object_LAYER_CONTROL struct in the drawing which represents the layer table. A good API function would be: Dwg_Object_LAYER_CONTROL* dwg_get_layer_control(Dwg_Data *dwg); To access the layer control these functions are possible: // returns the number of records in the layer table int dwg_layer_control_get_length(Dwg_Object_LAYER_CONTROL *ctrl); // returns the layer at a given index Dwg_Object_LAYER* dwg_layer_control_get_at(Dwg_Object_LAYER_CONTROL *ctrl, int index); // returns the layer with a given handle Dwg_Object_LAYER* dwg_layer_control_get_by_handle(Dwg_Object_LAYER_CONTROL *ctrl, Dwg_Handle *handle); // returns the layer with a given handle Dwg_Object_LAYER* dwg_layer_control_get_by_name(Dwg_Object_LAYER_CONTROL *ctrl, DWGCHAR *name);
This function is a litle bit too high level. It not only returns the name of a layer but the layer itself. It wold be better to split the function: Dwg_Object_LAYER* dwg_entity_get_layer(Dwg_Object_Entity *entity); DWGCHAR dwg_layer_get_name(Dwg_Object_LAYER *layer); An API should hide the implementation details, that means a user of the API should not see the variables of internal structs like Dwg_Object_LAYER_CONTROL. Declare it as an opaque pointer in the header for the API: typedef struct Dwg_Object_LAYER_CONTROL Dwg_Object_LAYER_CONTROL; In the .c file where you implement the functions you can include the dwg.h and have the detailed definitions of all structs. regards Till Am 24.05.2013 um 17:54 schrieb gagan:
|
[Prev in Thread] | Current Thread | [Next in Thread] |