FieldDescription* UnionMetaClass::get_proper_field_description(const Address address,const LString& field_name ) const { int index = get_tag_num( address ); if ((index >= 0) && ((*_union_fields)[ index ]->get_member_name() == field_name)) return (*_union_fields)[ index ]; return(NULL); }
Walker::ApplyStatus UnionMetaClass::walk(const Address instance,Walker &walk) const { AggregateWrapper agg_obj(instance, this); AggregateMetaClass::walk_fields(instance,walk); int index = get_tag_num( instance ); if ( index == -1 ) { return Walker::Continue; } FieldDescription* field_description = (*_union_fields)[ index ]; ObjectWrapper obj = field_description->build_object(agg_obj); return field_description->get_meta_class()->walk(obj.get_address(), walk); }
int main() { char key[] = "key1,key2,key3"; char tag[32]; int num = get_tag_num(key,','); // for(int i=0;i<num+1;i++) { get_tag_by_index(key,tag,2); printf("tag %d: %s\n",2,tag); // } return 0; }
FieldDescription* UnionMetaClass:: get_proper_field_description(const Address address, size_t i) const { // This used to be an INT. Just to make sure no one really // tried to get the -1 field assert here. kernel_assert(i < (unsigned)-10); // if (i < 0) // return NULL; int index = get_tag_num( address ); if ( index > 0 ) { if (i == 0) { FieldDescription* field_description = (*_union_fields)[ index ]; return field_description; } i--; } return(NULL); }
void UnionMetaClass::initialize( const ObjectWrapper &obj, InputStream* inputStream ) const { Address address = obj.get_address(); kernel_assert(obj.get_meta_class() == this); // debugit("initializing union ",address); AggregateWrapper agg_obj(address, this); AggregateMetaClass::initialize( obj, inputStream ); int index = get_tag_num( address ); if (index < 0) zero_field(address); else { FieldDescription* field_description = (*_union_fields)[ index ]; ObjectWrapper field = field_description->build_object(agg_obj); //Address instance_address = (Address)( ( (Byte*)address ) + field_description->offset ); field.initialize(inputStream); // field_description->get_meta_class()->initialize( field.get_address() ,inputStream ); } }
void UnionMetaClass::write( const ObjectWrapper &obj, OutputStream* outputStream ) const { Address instance = obj.get_address(); kernel_assert(obj.get_meta_class() == this); AggregateWrapper agg_obj(instance, this); AggregateMetaClass::write( obj, outputStream ); int index = get_tag_num( instance ); // if the tag number is not stored in a field that was already // written out => write out the tag number if ( _tag_offset == -1 ) { outputStream->write_unsigned_int( index ); } if ( index >= 0 ) { FieldDescription* field_description = (*_union_fields)[ index ]; ObjectWrapper field = field_description->build_object(agg_obj); outputStream->write( field, false ); } }
int display_cs_tags(Tcl_Interp *interp, /* in */ GapIO *io, /* in */ obj_cs *cs) /* in */ { GAnnotations *annotation; /* annotation structure */ char **tag_types = NULL; int num_tags; int tag_pos; /* tag LH position */ int whole_reading = 0; /* if TRUE display entire reading */ int r_pos, r_len; /* reading LH position and length */ int c_num; int r_num; GContigs contig; GReadings reading; int x1, x2; int tag_num = 0; /* get template display tag list */ /* HACK - put in registration structure ? */ if (TCL_ERROR == Tcl_VarEval(interp, "GetDefaultTags ", "CONTIG_SEL.TAGS ", NULL)) { printf("ERROR %s\n", Tcl_GetStringResult(interp)); } if (SetActiveTags2(Tcl_GetStringResult(interp), &num_tags, &tag_types) == -1) { return -1; } if (num_tags == 0) { if (tag_types) Tcl_Free((char *)tag_types); return 0; } for (c_num = 1; c_num <= NumContigs(io); c_num++) { /* reading tags */ contig_read(io, c_num, contig); for (r_num=contig.left; r_num; r_num=reading.right) { gel_read(io, r_num, reading); /* like vtagget except also returns tag_num */ annotation = get_tag_num(io, r_num, num_tags, tag_types, &tag_num); while (annotation && annotation != (GAnnotations *)-1){ /* if reading has been complemented, find new pos of tag */ if (reading.sense) { tag_pos = (reading.position - reading.start) + (reading.length - annotation->position - annotation->length + 1); tag_pos = find_position_in_DB(io, c_num, tag_pos); } else { tag_pos = annotation->position - (reading.start - reading.position +1); tag_pos = find_position_in_DB(io, c_num, tag_pos); } /* end if */ /* printf("num %d tag_pos %d len %d \n", c_num, tag_pos, annotation->length); */ SetReadingPosLen(whole_reading, io, r_num, &r_pos, &r_len); r_pos = find_position_in_DB(io, c_num, r_pos); CalcXCoords(tag_pos, annotation->length, &x1, &x2); /* clip tag at cutoff data */ x1 = MAX(x1, r_pos); x2 = MIN(x2, r_pos + r_len - 1); if (x2 >= x1) { DrawCSTags(interp, x1, x2, tag_num, annotation, cs->tag.offset, cs->hori, cs->tag.width, c_num, r_num); } annotation = get_tag_num(io, 0, num_tags, tag_types, &tag_num); } /* end while */ } /* end for each reading */ /* consensus tags */ annotation = get_tag_num(io, -c_num, num_tags, tag_types, &tag_num); while (annotation && annotation != (GAnnotations *)-1){ tag_pos = annotation->position; tag_pos = find_position_in_DB(io, c_num, tag_pos); CalcXCoords(tag_pos, annotation->length, &x1, &x2); DrawCSTags(interp, x1, x2, tag_num, annotation, cs->tag.offset+20, cs->hori, cs->tag.width, c_num, 0); annotation = get_tag_num(io, 0, num_tags, tag_types, &tag_num); } /* end while */ } /* end for each contig */ if (tag_types) Tcl_Free((char *)tag_types); return 0; }
size_t UnionMetaClass::get_proper_field_count(const Address address) const { int index = get_tag_num( address ); if ( index >= 0 ) return(1); return(0); // -1 is used to mark an empty union }