/* *NOT A CALLBACK* --> Must be called by inherited class (see aadldata.c) */ void aadlbox_load(ObjectNode obj_node, int version, DiaContext *ctx, Aadlbox *aadlbox) { AttributeNode attr; DataNode composite, data; Aadl_type type; gchar *declaration; Aadlport *port; ConnectionPoint *connection; int i, num; attr = object_find_attribute(obj_node, "aadlbox_ports"); composite = attribute_first_data(attr); num = attribute_num_data(attr); for (i=0; i<num; i++) { Point p; attr = composite_find_attribute(composite, "point"); data_point(attribute_first_data(attr), &p, ctx); attr = composite_find_attribute(composite, "port_type"); type = data_enum(attribute_first_data(attr), ctx); attr = composite_find_attribute(composite, "port_declaration"); declaration = data_string(attribute_first_data(attr), ctx); port = g_new0(Aadlport,1); port->handle = g_new0(Handle,1); port->type = type; port->declaration = declaration; aadlbox_add_port(aadlbox, &p, port); composite = data_next(composite); } attr = object_find_attribute(obj_node, "aadlbox_connections"); num = attribute_num_data(attr); data = attribute_first_data(attr); for (i=0; i<num; i++) { Point p; data_point(data, &p, ctx); connection = g_new0(ConnectionPoint,1); aadlbox_add_connection(aadlbox, &p, connection); data = data_next(data); } object_load_props(&aadlbox->element.object,obj_node, ctx); }
static DiaObject * bus_load(ObjectNode obj_node, int version, const char *filename) { Bus *bus; Connection *conn; LineBBExtras *extra; DiaObject *obj; AttributeNode attr; DataNode data; int i; bus = g_malloc0(sizeof(Bus)); conn = &bus->connection; obj = &conn->object; extra = &conn->extra_spacing; obj->type = &bus_type; obj->ops = &bus_ops; connection_load(conn, obj_node); attr = object_find_attribute(obj_node, "bus_handles"); bus->num_handles = 0; if (attr != NULL) bus->num_handles = attribute_num_data(attr); connection_init(conn, 2 + bus->num_handles, 0); data = attribute_first_data(attr); bus->handles = g_malloc(sizeof(Handle *)*bus->num_handles); bus->parallel_points = g_malloc(sizeof(Point)*bus->num_handles); for (i=0;i<bus->num_handles;i++) { bus->handles[i] = g_new0(Handle,1); bus->handles[i]->id = HANDLE_BUS; bus->handles[i]->type = HANDLE_MINOR_CONTROL; bus->handles[i]->connect_type = HANDLE_CONNECTABLE_NOBREAK; bus->handles[i]->connected_to = NULL; data_point(data, &bus->handles[i]->pos); obj->handles[2+i] = bus->handles[i]; data = data_next(data); } bus->line_color = color_black; attr = object_find_attribute(obj_node, "line_color"); if (attr != NULL) data_color(attribute_first_data(attr), &bus->line_color); extra->start_trans = extra->end_trans = extra->start_long = extra->end_long = LINE_WIDTH/2.0; bus_update_data(bus); return &bus->connection.object; }
static void pointarrayprop_load(PointarrayProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx) { guint nvals = attribute_num_data(attr); guint i; g_array_set_size(prop->pointarray_data,nvals); for (i=0; (i < nvals) && data; i++, data = data_next(data)) data_point(data,&g_array_index(prop->pointarray_data,Point,i),ctx); if (i != nvals) g_warning("attribute_num_data() and actual data count mismatch " "(shouldn't happen)"); }
static void enumarrayprop_load(EnumarrayProperty *prop, AttributeNode attr, DataNode data) { guint nvals = attribute_num_data(attr); guint i; g_array_set_size(prop->enumarray_data,nvals); for (i=0; (i < nvals) && data; i++, data = data_next(data)) g_array_index(prop->enumarray_data,gint,i) = data_enum(data); if (i != nvals) g_warning("attribute_num_data() and actual data count mismatch " "(shouldn't happen)"); }
void polyconn_load(PolyConn *poly, ObjectNode obj_node, DiaContext *ctx) /* NOTE: Does object_init() */ { int i; AttributeNode attr; DataNode data; DiaObject *obj = &poly->object; object_load(obj, obj_node, ctx); attr = object_find_attribute(obj_node, "poly_points"); if (attr != NULL) poly->numpoints = attribute_num_data(attr); else poly->numpoints = 0; object_init(obj, poly->numpoints, 0); data = attribute_first_data(attr); poly->points = g_malloc(poly->numpoints*sizeof(Point)); for (i=0;i<poly->numpoints;i++) { data_point(data, &poly->points[i], ctx); data = data_next(data); } obj->handles[0] = g_malloc(sizeof(Handle)); obj->handles[0]->connect_type = HANDLE_CONNECTABLE; obj->handles[0]->connected_to = NULL; obj->handles[0]->type = HANDLE_MAJOR_CONTROL; obj->handles[0]->id = HANDLE_MOVE_STARTPOINT; obj->handles[poly->numpoints-1] = g_malloc(sizeof(Handle)); obj->handles[poly->numpoints-1]->connect_type = HANDLE_CONNECTABLE; obj->handles[poly->numpoints-1]->connected_to = NULL; obj->handles[poly->numpoints-1]->type = HANDLE_MAJOR_CONTROL; obj->handles[poly->numpoints-1]->id = HANDLE_MOVE_ENDPOINT; for (i=1;i<poly->numpoints-1;i++) { obj->handles[i] = g_malloc(sizeof(Handle)); setup_handle(obj->handles[i], PC_HANDLE_CORNER); } polyconn_update_data(poly); }
static void dictprop_load(DictProperty *prop, AttributeNode attr, DataNode data) { DataNode kv; guint nvals = attribute_num_data(attr); if (!nvals) return; kv = attribute_first_data (data); while (kv) { xmlChar *key = xmlGetProp(kv, (const xmlChar *)"name"); if (key) { gchar *value = data_string(attribute_first_data (kv)); if (value) g_hash_table_insert (prop->dict, g_strdup((gchar *)key), value); } else { g_warning ("Dictionary key missing"); } kv = data_next(kv); } }
UMLOperation * uml_operation_read(DataNode composite) { UMLOperation *op; UMLParameter *param; AttributeNode attr_node; AttributeNode attr_node2; DataNode composite2; int i, num; op = g_new(UMLOperation, 1); op->name = NULL; attr_node = composite_find_attribute(composite, "name"); if (attr_node != NULL) op->name = data_string( attribute_first_data(attr_node) ); op->type = NULL; attr_node = composite_find_attribute(composite, "type"); if (attr_node != NULL) op->type = data_string( attribute_first_data(attr_node) ); op->visibility = FALSE; attr_node = composite_find_attribute(composite, "visibility"); if (attr_node != NULL) op->visibility = data_enum( attribute_first_data(attr_node) ); op->abstract = FALSE; attr_node = composite_find_attribute(composite, "abstract"); if (attr_node != NULL) op->abstract = data_boolean( attribute_first_data(attr_node) ); op->class_scope = FALSE; attr_node = composite_find_attribute(composite, "class_scope"); if (attr_node != NULL) op->class_scope = data_boolean( attribute_first_data(attr_node) ); op->parameters = NULL; attr_node2 = composite_find_attribute(composite, "parameters"); num = attribute_num_data(attr_node2); composite2 = attribute_first_data(attr_node2); for (i=0;i<num;i++) { param = g_new(UMLParameter, 1); param->name = NULL; attr_node = composite_find_attribute(composite2, "name"); if (attr_node != NULL) param->name = data_string( attribute_first_data(attr_node) ); param->type = NULL; attr_node = composite_find_attribute(composite2, "type"); if (attr_node != NULL) param->type = data_string( attribute_first_data(attr_node) ); param->value = NULL; attr_node = composite_find_attribute(composite2, "value"); if (attr_node != NULL) param->value = data_string( attribute_first_data(attr_node) ); param->kind = UML_UNDEF_KIND; attr_node = composite_find_attribute(composite2, "kind"); if (attr_node != NULL) param->kind = data_enum( attribute_first_data(attr_node) ); op->parameters = g_list_append(op->parameters, param); composite2 = data_next(composite2); } op->left_connection = NULL; op->right_connection = NULL; return op; }
static DiaObject * compound_load (ObjectNode obj_node, int version, DiaContext *ctx) { Compound * comp; DiaObject * obj; AttributeNode attr; DataNode data; gint i, num_handles; comp = g_new0 (Compound, 1); obj = &comp->object; /* load the objects position and bounding box */ object_load (obj, obj_node, ctx); /* init the object */ obj->type = &compound_type; obj->ops = &compound_ops; /* load the object's handles and its positions */ attr = object_find_attribute (obj_node, "comp_points"); g_assert (attr != NULL); num_handles = attribute_num_data (attr); g_assert (num_handles >= 3); /* allocate space for object handles and connectionpoints point arrays */ object_init (obj, num_handles, 1); data = attribute_first_data (attr); /* init our mount_point */ setup_mount_point (&comp->mount_point, obj, NULL); data_point (data, &comp->mount_point.pos, ctx); obj->connections[0] = &comp->mount_point; /* now init the handles */ comp->num_arms = num_handles-1; comp->handles = g_new0 (Handle, num_handles); setup_handle (&comp->handles[0], HANDLE_MOUNT_POINT, HANDLE_MAJOR_CONTROL, HANDLE_NONCONNECTABLE); comp->handles[0].pos = comp->mount_point.pos; obj->handles[0] = &comp->handles[0]; data = data_next (data); for (i = 1; i < num_handles; i++) { obj->handles[i] = &comp->handles[i]; setup_handle (obj->handles[i], HANDLE_ARM, HANDLE_MINOR_CONTROL, HANDLE_CONNECTABLE_NOBREAK); data_point (data, &obj->handles[i]->pos, ctx); data = data_next (data); } /* load remainding properties */ attr = object_find_attribute (obj_node, PROP_STDTYPE_LINE_WIDTH); if (attr == NULL) comp->line_width = 0.1; else comp->line_width = data_real (attribute_first_data (attr), ctx); attr = object_find_attribute (obj_node, "line_colour"); if (attr == NULL) comp->line_color = color_black; else data_color (attribute_first_data (attr), &comp->line_color, ctx); compound_update_data (comp); compound_sanity_check (comp, "Loaded"); return &comp->object; }