/******************************************************************************/ /* File : HNops.cc */ /* Schema : bdeschema.sch */ /* GENCPP Version : Chgen V 12 - Sathya */ /******************************************************************************/ /* See comments below - logging has bugs (no RFLAG), redundancies-RJL 021110 */ #include #include #include #include "bdeschema.h" #include "SVschema.h" #include "TTschema.h" #include "TAschema.h" #include "VVschema.h" #include "TSschema.h" #include "FOschema.h" #include "GDschema.h" #include "HGschema.h" #include "HNschema.h" #include "HAschema.h" #include "HLschema.h" #include "HPschema.h" #include "HIschema.h" #include "CGschema.h" #include "GXschema.h" #ifdef USE_STL /******************************************************************************/ /* This routine returns table abbreviation. */ /******************************************************************************/ char *HNtable::getAbbrev() { return abbrev; } /******************************************************************************/ /* This routine returns table name. */ /******************************************************************************/ char *HNtable::getName() { return name; } /******************************************************************************/ /* This routine returns number of rows in the table. */ /******************************************************************************/ unsigned int HNtable::getRowCount() { return row.size(); } /******************************************************************************/ /* This routine returns an iterator to the first row in the table. */ /******************************************************************************/ list::iterator HNtable::getFirstRow() { return row.begin(); } /******************************************************************************/ /* This routine returns the last row in the table. */ /******************************************************************************/ HN *HNtable::getLastRow() { HN *retval; list::iterator iter; if (row.empty()) { retval = NULL; } else { iter = row.end(); iter--; retval = *iter; } return retval; } /******************************************************************************/ /* This routine returns the terminator after last row in the table. */ /******************************************************************************/ list::iterator HNtable::Terminator() { return row.end(); } bool HNtable::isFirstRow(HN* curr) { return(curr != NULL && curr != (*getFirstRow())); } bool HNtable::isLastRow(HN* curr) { return(curr != NULL && curr != getLastRow()); } #endif /* ifdef USE_STL */ #ifdef USE_STL /******************************************************************************/ /* This routine inserts a row into the table. */ /******************************************************************************/ void HNtable::insertRow(HN *newRow) { list::iterator iter; iter = row.begin(); while (iter != row.end() && (*iter)->get_pkid() < newRow->get_pkid()) iter++; row.insert(iter, newRow); } #endif /* USE_STL */ #ifdef USE_STL /******************************************************************************/ /* This routine returns removes the specified row from the table. */ /******************************************************************************/ list::iterator HNtable::removeRow(list::iterator i) { HN *tmpRow = (*i); return row.erase(i); } #endif #ifdef USE_STL /******************************************************************************/ /* Constructor for table class. */ /******************************************************************************/ HNtable::HNtable(char *newAbbrev, char *newName) { strcpy(abbrev, newAbbrev); name = new char[sizeof( newName )]; strcpy(name, newName); } #endif #ifdef USE_STL /******************************************************************************/ /* Table destructor. */ /******************************************************************************/ HNtable::~HNtable() { HN *currRow; list::iterator iterator; iterator = row.begin(); while (iterator != row.end()) { currRow = *iterator; iterator = currRow->delete_row(iterator); } delete [] name; } #endif /******************************************************************************/ /* This routine is used to set value to a data member. */ /******************************************************************************/ void HN::set_HGid (hcg_key value) { char log_text[BUFSIZE]; char temp_key[HCG_KEY_SIZE+1]; char temp_fkey[HCG_KEY_SIZE+1]; hcg_key HNid; logwait(); /* calls logstr with WAIT command iff hcg_log==1 (not RFLAG)*/ if (get_RFLAG()==1 && hcg_log ==1 ) { fprintf( hcg_logfileptr, "SET_KEY %s %s %s\n", decode_retstr( (hcg_key*)(get_pkid()) ), "HGid", decode_retstr(&value) ); } HGid = value ; HNid = RC::get_pkid(); decode(temp_key, &HNid); decode(temp_fkey, &value); sprintf(log_text,"PR_SET_KEY %s HGid %s\n",temp_key, temp_fkey); logstr(log_text); } /******************************************************************************/ /* This routine is used to set value to a data member. */ /******************************************************************************/ void HN::set_HGid2 (char *value) { char log_text[BUFSIZE]; char temp_key[HCG_KEY_SIZE+1]; hcg_key HNid; logwait(); if ( strlen(value) >= sizeof(HGid2) ) fprintf(stderr, "Warning: field HGid2 in class HN is too long- truncated\n"); if (get_RFLAG()==1 && hcg_log ==1 ) { fprintf( hcg_logfileptr, "SET_STR %s %s %s\n", decode_retstr( (hcg_key*)(get_pkid()) ),"HGid2", (value) ); } strncpy(HGid2, value, sizeof(HGid2)) ; HNid = RC::get_pkid(); decode(temp_key, &HNid); sprintf(log_text,"PR_SET_STR %s HGid2 %s\n",temp_key, value); logstr(log_text); } /******************************************************************************/ /* This routine is used to set value to a data member. */ /******************************************************************************/ void HN::set_shape (char *value) { char log_text[BUFSIZE]; char temp_key[HCG_KEY_SIZE+1]; hcg_key HNid; logwait(); if ( strlen(value) >= sizeof(shape) ) fprintf(stderr, "Warning: field shape in class HN is too long- truncated\n"); if (get_RFLAG()==1 && hcg_log ==1 ) { fprintf( hcg_logfileptr, "SET_STR %s %s %s\n", decode_retstr( (hcg_key*)(get_pkid()) ),"shape", (value) ); } strncpy(shape, value, sizeof(shape)) ; HNid = RC::get_pkid(); decode(temp_key, &HNid); sprintf(log_text,"PR_SET_STR %s shape %s\n",temp_key, value); logstr(log_text); } /******************************************************************************/ /* This routine is used to set value to a data member. */ /******************************************************************************/ void HN::set_centerx (float value) { char log_text[BUFSIZE]; char temp_key[HCG_KEY_SIZE+1]; hcg_key HNid; logwait(); if (get_RFLAG()==1 && hcg_log ==1 ) { fprintf( hcg_logfileptr, "SET_FLT %s %s %f\n", decode_retstr( (hcg_key*)(get_pkid()) ),"centerx", (value) ); } centerx = value ; HNid = RC::get_pkid(); decode(temp_key, &HNid); sprintf(log_text,"PR_SET_FLT %s centerx %f\n",temp_key, value); logstr(log_text); } /******************************************************************************/ /* This routine is used to set value to a data member. */ /******************************************************************************/ void HN::set_centery (float value) { char log_text[BUFSIZE]; char temp_key[HCG_KEY_SIZE+1]; hcg_key HNid; logwait(); if (get_RFLAG()==1 && hcg_log ==1 ) { fprintf( hcg_logfileptr, "SET_FLT %s %s %f\n", decode_retstr( (hcg_key*)(get_pkid()) ),"centery", (value) ); } centery = value ; HNid = RC::get_pkid(); decode(temp_key, &HNid); sprintf(log_text,"PR_SET_FLT %s centery %f\n",temp_key, value); logstr(log_text); } /******************************************************************************/ /* This routine is used to set value to a data member. */ /******************************************************************************/ void HN::set_width (float value) { char log_text[BUFSIZE]; char temp_key[HCG_KEY_SIZE+1]; hcg_key HNid; logwait(); if (get_RFLAG()==1 && hcg_log ==1 ) { fprintf( hcg_logfileptr, "SET_FLT %s %s %f\n", decode_retstr( (hcg_key*)(get_pkid()) ),"width", (value) ); } width = value ; HNid = RC::get_pkid(); decode(temp_key, &HNid); sprintf(log_text,"PR_SET_FLT %s width %f\n",temp_key, value); logstr(log_text); } /******************************************************************************/ /* This routine is used to set value to a data member. */ /******************************************************************************/ void HN::set_height (float value) { char log_text[BUFSIZE]; char temp_key[HCG_KEY_SIZE+1]; hcg_key HNid; logwait(); if (get_RFLAG()==1 && hcg_log ==1 ) { fprintf( hcg_logfileptr, "SET_FLT %s %s %f\n", decode_retstr( (hcg_key*)(get_pkid()) ),"height", (value) ); } height = value ; HNid = RC::get_pkid(); decode(temp_key, &HNid); sprintf(log_text,"PR_SET_FLT %s height %f\n",temp_key, value); logstr(log_text); } /******************************************************************************/ /* This routine is used to set value to a data member. */ /******************************************************************************/ void HN::set_txtfont (char *value) { char log_text[BUFSIZE]; char temp_key[HCG_KEY_SIZE+1]; hcg_key HNid; logwait(); if ( strlen(value) >= sizeof(txtfont) ) fprintf(stderr, "Warning: field txtfont in class HN is too long- truncated\n"); if (get_RFLAG()==1 && hcg_log ==1 ) { fprintf( hcg_logfileptr, "SET_STR %s %s %s\n", decode_retstr( (hcg_key*)(get_pkid()) ),"txtfont", (value) ); } strncpy(txtfont, value, sizeof(txtfont)) ; HNid = RC::get_pkid(); decode(temp_key, &HNid); sprintf(log_text,"PR_SET_STR %s txtfont %s\n",temp_key, value); logstr(log_text); } /******************************************************************************/ /* This routine is used to set value to a data member. */ /******************************************************************************/ void HN::set_txtoffsetx (float value) { char log_text[BUFSIZE]; char temp_key[HCG_KEY_SIZE+1]; hcg_key HNid; logwait(); if (get_RFLAG()==1 && hcg_log ==1 ) { fprintf( hcg_logfileptr, "SET_FLT %s %s %f\n", decode_retstr( (hcg_key*)(get_pkid()) ),"txtoffsetx", (value) ); } txtoffsetx = value ; HNid = RC::get_pkid(); decode(temp_key, &HNid); sprintf(log_text,"PR_SET_FLT %s txtoffsetx %f\n",temp_key, value); logstr(log_text); } /******************************************************************************/ /* This routine is used to set value to a data member. */ /******************************************************************************/ void HN::set_txtoffsety (float value) { char log_text[BUFSIZE]; char temp_key[HCG_KEY_SIZE+1]; hcg_key HNid; logwait(); if (get_RFLAG()==1 && hcg_log ==1 ) { fprintf( hcg_logfileptr, "SET_FLT %s %s %f\n", decode_retstr( (hcg_key*)(get_pkid()) ),"txtoffsety", (value) ); } txtoffsety = value ; HNid = RC::get_pkid(); decode(temp_key, &HNid); sprintf(log_text,"PR_SET_FLT %s txtoffsety %f\n",temp_key, value); logstr(log_text); } /******************************************************************************/ /* This routine is used to set value to a data member. */ /******************************************************************************/ void HN::set_txtwidth (int value) { char log_text[BUFSIZE]; char temp_key[HCG_KEY_SIZE+1]; hcg_key HNid; logwait(); if (get_RFLAG()==1 && hcg_log ==1 ) { fprintf( hcg_logfileptr, "SET_INT %s %s %d\n", decode_retstr( (hcg_key*)(get_pkid()) ),"txtwidth", (value) ); } txtwidth = value ; #ifdef USE_STL HNid = get_pkid(); #else HNid = RC::get_pkid(); #endif decode(temp_key, &HNid); sprintf(log_text,"PR_SET_INT %s txtwidth %d\n",temp_key, value); logstr(log_text); } /******************************************************************************/ /* This routine is used to set value to a data member. */ /******************************************************************************/ void HN::set_txtheight (int value) { char log_text[BUFSIZE]; char temp_key[HCG_KEY_SIZE+1]; hcg_key HNid; logwait(); if (get_RFLAG()==1 && hcg_log ==1 ) { fprintf( hcg_logfileptr, "SET_INT %s %s %d\n", decode_retstr( (hcg_key*)(get_pkid()) ),"txtheight", (value) ); } txtheight = value ; #ifdef USE_STL HNid = get_pkid(); #else HNid = RC::get_pkid(); #endif decode(temp_key, &HNid); sprintf(log_text,"PR_SET_INT %s txtheight %d\n",temp_key, value); logstr(log_text); } /******************************************************************************/ /* This routine is used to set value to a data member. */ /******************************************************************************/ void HN::set_nodename (char *value) { char log_text[BUFSIZE]; char temp_key[HCG_KEY_SIZE+1]; hcg_key HNid; logwait(); if ( strlen(value) >= sizeof(nodename) ) fprintf(stderr, "Warning: field nodename in class HN is too long- truncated\n"); if (get_RFLAG()==1 && hcg_log ==1 ) { fprintf( hcg_logfileptr, "SET_STR %s %s %s\n", decode_retstr( (hcg_key*)(get_pkid()) ),"nodename", (value) ); } strncpy(nodename, value, sizeof(nodename)) ; HNid = RC::get_pkid(); decode(temp_key, &HNid); sprintf(log_text,"PR_SET_STR %s nodename %s\n",temp_key, value); logstr(log_text); } /******************************************************************************/ /* This routine is used to get value from a data member. */ /******************************************************************************/ hcg_key HN::get_HGid () { return HGid; } /******************************************************************************/ /* This routine is used to get value from a data member. */ /******************************************************************************/ char* HN::get_HGid2 () { return HGid2; } /******************************************************************************/ /* This routine is used to get value from a data member. */ /******************************************************************************/ char* HN::get_shape () { return shape; } /******************************************************************************/ /* This routine is used to get value from a data member. */ /******************************************************************************/ float HN::get_centerx () { return centerx; } /******************************************************************************/ /* This routine is used to get value from a data member. */ /******************************************************************************/ float HN::get_centery () { return centery; } /******************************************************************************/ /* This routine is used to get value from a data member. */ /******************************************************************************/ float HN::get_width () { return width; } /******************************************************************************/ /* This routine is used to get value from a data member. */ /******************************************************************************/ float HN::get_height () { return height; } /******************************************************************************/ /* This routine is used to get value from a data member. */ /******************************************************************************/ char* HN::get_txtfont () { return txtfont; } /******************************************************************************/ /* This routine is used to get value from a data member. */ /******************************************************************************/ float HN::get_txtoffsetx () { return txtoffsetx; } /******************************************************************************/ /* This routine is used to get value from a data member. */ /******************************************************************************/ float HN::get_txtoffsety () { return txtoffsety; } /******************************************************************************/ /* This routine is used to get value from a data member. */ /******************************************************************************/ int HN::get_txtwidth () { return txtwidth; } /******************************************************************************/ /* This routine is used to get value from a data member. */ /******************************************************************************/ int HN::get_txtheight () { return txtheight; } /******************************************************************************/ /* This routine is used to get value from a data member. */ /******************************************************************************/ char* HN::get_nodename () { return nodename; } #ifndef USE_STL HN* HN::create_row() { HN *HNtmp; HNtmp = new HN; HNtmp->set_pkid(0); HNtmp->set_HGid(0); HNtmp->set_HGid2("\0"); HNtmp->set_shape("\0"); HNtmp->set_centerx(0.0); HNtmp->set_centery(0.0); HNtmp->set_width(0.0); HNtmp->set_height(0.0); HNtmp->set_txtfont("\0"); HNtmp->set_txtoffsetx(0.0); HNtmp->set_txtoffsety(0.0); HNtmp->set_txtwidth(0); HNtmp->set_txtheight(0); HNtmp->set_nodename("\0"); HNtmp->next_ptr = NULL; HNtmp->prev_ptr = NULL; HNtmp->HGid_pp = NULL; HNtmp->HGid_fpp = NULL; HNtmp->HGid_bpp = NULL; HNtmp->HAid_fcp = NULL; HNtmp->HAid_bcp = NULL; HNtmp->HLid1_fcp = NULL; HNtmp->HLid1_bcp = NULL; HNtmp->HLid2_fcp = NULL; HNtmp->HLid2_bcp = NULL; return HNtmp; } #endif /******************************************************************************/ /* This routine is used to add a single row to a virtual database table. */ /* Validations for valid table-id, table is within view, and the version */ /* number is the right one for this table in this view. if all this passes, */ /* the row is added to the database, and linked in to its parents, etc... */ /******************************************************************************/ void HN::add_row (char *viewname) { char error_table[HCG_ABBR_SIZE+1]; char tempkey[HCG_KEY_SIZE+1]; hcg_key HNid; char VNstring[NAMELENGTH] = "VN "; if (hcg_log == 1) { logwait(); if (strcmp(viewname, hcg_viewname)) { logstr(strcat (strcat (VNstring, viewname), "\n")); strcpy (hcg_viewname, viewname); } } if (!hcg_initialized) { printf("Error: pr_add() called when database is not yet initialized.\n"); add_row_log (viewname); return; } if (!find_view_idx(viewname)) { printf("Error: view %s passed to pr_load is not defined.\n",viewname); add_row_log (viewname); return; } if (!find_tbl_idx("HN")) { strncpy_null(error_table, "HN", HCG_ABBR_SIZE); printf("Warning: unknown table (%s) passed to pr_add, ignored.\n",error_table); add_row_log (viewname); return; } hcg_version = hcg_view_list.view_list[hcg_view_idx].version_list[hcg_tbl_idx]; hcg_table_seq_list[hcg_tbl_idx].rcount++; hcg_ts_list[hcg_tbl_idx].ts_list[hcg_version].rcount++; #ifndef USE_STL HNelt = this; #endif pr_gen_pkey(viewname,HN,HNid); #ifdef USE_STL set_pkid(HNid); #else RC::set_pkid(HNid); #endif #ifndef USE_STL pr_check_fkey(HN,HNelt,HGid,HG,HGid,HGelt); #else pr_check_fkey(HN,this,HGid,HG,HGid,HGelt); #endif pr_check_str (HN,HNelt,HGid2,8); pr_check_str (HN,HNelt,shape,1); pr_check_str (HN,HNelt,txtfont,25); pr_check_str (HN,HNelt,nodename,60); add_row_log (viewname); link_row(); hcg_ts_list[hcg_tbl_idx].ts_list[hcg_version].maxrow++; } /******************************************************************************/ /* This routine is used to link a single row to a virtual database table. */ /******************************************************************************/ void HN::link_row() { hcg_key HNid; #ifndef USE_STL insert_element(HN); #else HNtab->insertRow(this); #endif /* USE_STL */ link_child_bp_m(HA,HN,HNid,HNid,HNid,HAid); link_child_bp_m(HL,HN,HNid1,HNid,HNid1,HLid1); link_child_bp_m(HL,HN,HNid2,HNid,HNid2,HLid2); link_parent_bp_m(HN,HG,HGid,HGid,HGid,HNid); } /******************************************************************************/ /* This routine is used to parse a single row to a virtual database table. */ /* Validations for valid table-id, table is within view, and the version */ /* number is the right one for this table in this view. if all this passes, */ /* the row is added to the database, and linked in to its parents, etc... */ /******************************************************************************/ void HN::parse_row (char *buffer, int idx, hcg_key hcg_k) { #ifdef USE_STL set_pkid(hcg_k); #else RC::set_pkid(hcg_k); #endif hcg_parse(buffer, hcg_t, &idx); encode(hcg_t, &hcg_k); HGid = hcg_k; hcg_parse(buffer,hcg_t,&idx); mystrcpy(HGid2,hcg_t,8,0); hcg_parse(buffer,hcg_t,&idx); mystrcpy(shape,hcg_t,1,0); hcg_parse(buffer,hcg_t,&idx); set_centerx((float) atof(hcg_t)); hcg_parse(buffer,hcg_t,&idx); set_centery((float) atof(hcg_t)); hcg_parse(buffer,hcg_t,&idx); set_width((float) atof(hcg_t)); hcg_parse(buffer,hcg_t,&idx); set_height((float) atof(hcg_t)); hcg_parse(buffer,hcg_t,&idx); mystrcpy(txtfont,hcg_t,25,0); hcg_parse(buffer,hcg_t,&idx); set_txtoffsetx((float) atof(hcg_t)); hcg_parse(buffer,hcg_t,&idx); set_txtoffsety((float) atof(hcg_t)); hcg_parse(buffer,hcg_t,&idx); set_txtwidth(atoi(hcg_t)); hcg_parse(buffer,hcg_t,&idx); set_txtheight(atoi(hcg_t)); mystrcpy(nodename,buffer+idx,60,1); } /******************************************************************************/ /* This routine will delete a single row from the database. The row is the */ /* one pointed to by the XXcurr variable. */ /******************************************************************************/ #ifdef USE_STL list::iterator HN::delete_row (list::iterator rowIter) #else void HN::delete_row () #endif { static char rcsid[] = "$Id"; char temp_key[HCG_KEY_SIZE+1]; hcg_key HNid; char log_text[BUFSIZE]; logwait(); unlink_child_bp_m(HA,HN,HNid,HAid); unlink_child_bp_m(HL,HN,HNid1,HLid1); unlink_child_bp_m(HL,HN,HNid2,HLid2); #ifdef USE_STL HNcurr = rowIter; #endif unlink_parent_bp_m(HN,HG,HGid,HNid); #ifdef DEBUG #ifdef USE_STL HNid = get_pkid(); #else HNid = RC::get_pkid(); #endif decode(temp_key, &HNid); printf("The primary key deleted is %s\n",temp_key); #endif #ifdef USE_STL rowIter = HNtab->removeRow(rowIter); delete this; #else del_row(HN); #endif /* The following is to support logging */ #ifdef USE_STL HNid = get_pkid(); #else HNid = RC::get_pkid(); #endif decode(temp_key, &HNid); sprintf(log_text,"DL %s\n",temp_key); logstr(log_text); #ifdef USE_STL return rowIter; #endif } /******************************************************************************/ /* This routine will write-out (dump) all rows that meet the specified */ /* view to the specified file_name. The tbl indicates which table's row */ /* will be dumped. The open_file flag of 1 indicates open a file for dumping */ /* a single row. Otherwise doesn't open file because pr_dump had opened a */ /* file. If the mode of the view is write, the caller is allowed to specify a */ /* new_version flag of 1, which will cause a version number update. Finally, */ /* the modestr parameter indicates if a new file should be generated ('w'), */ /* or append to an existing file ('a'). */ /******************************************************************************/ #ifdef USE_STL void HNtable::dump_table ( char *viewname, char *file_name, int new_version, char *modestr ) #else void HN::dump_table ( char *viewname, char *file_name, int new_version, char *modestr ) #endif { table_loop(viewname,HN) { #ifndef USE_STL HNcurr->dump_row(viewname,file_name,new_version,modestr); #else (*HNcurr)->dump_row(viewname,file_name,new_version,modestr); #endif /* USE_STL */ } } /******************************************************************************/ /* This routine will write-out (dump) a single row that meet the specified */ /* view to the specified file_name. The tbl indicates which table's row */ /* will be dumped. The open_file flag of 1 indicates open a file for dumping */ /* a single row. Otherwise doesn't open file because pr_dump had opened a */ /* file. If the mode of the view is write, the caller is allowed to specify a */ /* new_version flag of 1, which will cause a version number update. Finally, */ /* the modestr parameter indicates if a new file should be generated ('w'), */ /* or append to an existing file ('a'). */ /******************************************************************************/ void HN::dump_row (char *viewname, char *file_name, int new_version, char *modestr ) { char outkey[3][HCG_KEY_SIZE+1]; hcg_key HNid; if (open_file==1) { if ((hcg_dump_fp=fopen(file_name,modestr)) == NULL) { printf("Error: dump_row() cannot open %s using file mode %s\n", file_name,modestr); exit(1); } } #ifdef USE_STL HNid = get_pkid(); #else HNid = RC::get_pkid(); #endif hcg_update_version(&HNid,HN_idx,new_version); decode(outkey[0], &HNid); hcg_update_version(&HGid,HG_idx,new_version); decode(outkey[1], &HGid); PrintCheck(fprintf(hcg_dump_fp, " %-8s %-8s %-8s %-1s %8.4f %8.4f %8.4f %8.4f %-25s %8.4f %8.4f %8d %8d %-60s\n" , outkey[0], outkey[1], HGid2, shape, centerx, centery, width, height , txtfont, txtoffsetx, txtoffsety, txtwidth, txtheight, nodename)); if (open_file==1) fclose(hcg_dump_fp); } #ifdef USE_STL void HN::insertChild_HAid(HA *childRow) { HAid_children.push_back(childRow); } void HN::removeChild_HAid(list::iterator rowIter) { HAid_children.remove((*rowIter)); } list::iterator HN::getFirstChild_HAid() { return HAid_children.begin(); } list::iterator HN::getLastChild_HAid() { list::iterator iter; iter = HAid_children.end(); if (!HAid_children.empty()) iter--; return iter; } list::iterator HN::HAid_Terminator() { return HAid_children.end(); } #endif /* USE_STL */ #ifdef USE_STL void HN::insertChild_HLid1(HL *childRow) { HLid1_children.push_back(childRow); } void HN::removeChild_HLid1(list::iterator rowIter) { HLid1_children.remove((*rowIter)); } list::iterator HN::getFirstChild_HLid1() { return HLid1_children.begin(); } list::iterator HN::getLastChild_HLid1() { list::iterator iter; iter = HLid1_children.end(); if (!HLid1_children.empty()) iter--; return iter; } list::iterator HN::HLid1_Terminator() { return HLid1_children.end(); } #endif /* USE_STL */ #ifdef USE_STL void HN::insertChild_HLid2(HL *childRow) { HLid2_children.push_back(childRow); } void HN::removeChild_HLid2(list::iterator rowIter) { HLid2_children.remove((*rowIter)); } list::iterator HN::getFirstChild_HLid2() { return HLid2_children.begin(); } list::iterator HN::getLastChild_HLid2() { list::iterator iter; iter = HLid2_children.end(); if (!HLid2_children.empty()) iter--; return iter; } list::iterator HN::HLid2_Terminator() { return HLid2_children.end(); } #endif /* USE_STL */ #ifdef USE_STL void HN::setParent_HGid(HG *currentRow) { HGid_pp = currentRow; } HG *HN::getParent_HGid() { return HGid_pp; } #endif /* USE_STL */ #ifdef USE_STL /********************************************************************************/ /* Default constructor for HN. */ /********************************************************************************/ HN::HN () { set_pkid(0); /* initialize */ set_HGid(0); set_HGid2("\0"); set_shape("\0"); set_centerx(0.0); set_centery(0.0); set_width(0.0); set_height(0.0); set_txtfont("\0"); set_txtoffsetx(0.0); set_txtoffsety(0.0); set_txtwidth(0); set_txtheight(0); set_nodename("\0"); setParent_HGid(NULL); } #endif #ifdef USE_STL /********************************************************************************/ /* Destructor for HN. */ /********************************************************************************/ HN::~HN () { /* Empty */ } #endif /********************************************************************************/ /* This routine is used to log a call to pr_add to hcg_logfile */ /* The tbl indicates which table is having a row added. */ /* tbl_ptr points to the record to be added. */ /********************************************************************************/ void HN::add_row_log (char *viewname) { char outkey[3][HCG_KEY_SIZE+1]; int idx; hcg_key HNid; /* Return if logging not on */ if (hcg_log != 1) return; find_tbl_idx("HN"); idx=hcg_tbl_idx; /* Write to hcg_logfile based on idx */ #ifdef USE_STL HNid = get_pkid(); #else HNid = RC::get_pkid(); #endif hcg_update_version(&HNid,HN_idx,0); decode(outkey[0], &HNid); hcg_update_version(&HGid,HG_idx,0); decode(outkey[1], &HGid); PrintCheck(fprintf(hcg_logfileptr, " %-8s %-8s %-8s %-1s %8.4f %8.4f %8.4f %8.4f %-25s %8.4f %8.4f %8d %8d %-60s\n" , outkey[0], outkey[1], HGid2, shape, centerx, centery , width, height, txtfont, txtoffsetx, txtoffsety, txtwidth , txtheight, nodename)); } /********************************************************************************/ /* This routine is used to to do the add given the viewname, the tablename */ /* and a string of the additional information */ /********************************************************************************/ void HN::log_do_add_row (char *view, char *theRest, int idx) { hcg_parse(theRest, hcg_t, &idx); encode(hcg_t, &hcg_k); HGid = hcg_k; hcg_parse(theRest, hcg_t, &idx); mystrcpy(HGid2, hcg_t, 8, 0); hcg_parse(theRest, hcg_t, &idx); mystrcpy(shape, hcg_t, 1, 0); hcg_parse(theRest, hcg_t, &idx); centerx = ((float) atof(hcg_t)); hcg_parse(theRest, hcg_t, &idx); centery = ((float) atof(hcg_t)); hcg_parse(theRest, hcg_t, &idx); width = ((float) atof(hcg_t)); hcg_parse(theRest, hcg_t, &idx); height = ((float) atof(hcg_t)); hcg_parse(theRest, hcg_t, &idx); mystrcpy(txtfont, hcg_t, 25, 0); hcg_parse(theRest, hcg_t, &idx); txtoffsetx = ((float) atof(hcg_t)); hcg_parse(theRest, hcg_t, &idx); txtoffsety = ((float) atof(hcg_t)); hcg_parse(theRest, hcg_t, &idx); txtwidth = (atoi(hcg_t)); hcg_parse(theRest, hcg_t, &idx); txtheight = (atoi(hcg_t)); mystrcpy(nodename, theRest+idx, 60, 1); add_row(view); } /********************************************************************************/ /* This routine is used to set the value of an int field. */ /********************************************************************************/ void HN::log_do_set_int_row (const char fieldname[NAMELENGTH+1], const int newval) { if(strcmp(fieldname,"txtwidth")==0) txtwidth = newval; else if(strcmp(fieldname,"txtheight")==0) txtheight = newval; } /********************************************************************************/ /* This routine is used to set the value of an float field. */ /********************************************************************************/ void HN::log_do_set_flt_row (const char fieldname[NAMELENGTH+1], const int newval) { if (strcmp(fieldname,"centerx")==0) centerx = newval; else if (strcmp(fieldname,"centery")==0) centery = newval; else if (strcmp(fieldname,"width")==0) width = newval; else if (strcmp(fieldname,"height")==0) height = newval; else if (strcmp(fieldname,"txtoffsetx")==0) txtoffsetx = newval; else if (strcmp(fieldname,"txtoffsety")==0) txtoffsety = newval; } /********************************************************************************/ /* This routine is used to set the value of an key field. */ /********************************************************************************/ void HN::log_do_set_key_row (const char fieldname[NAMELENGTH+1], hcg_key new_key) { if (strcmp(fieldname,"HNid")==0) #ifdef USE_STL set_pkid (new_key); #else RC::set_pkid (new_key); #endif else if (strcmp(fieldname,"HGid")==0) HGid = new_key; } /********************************************************************************/ /* This routine is used to set the value of an string field. */ /********************************************************************************/ void HN::log_do_set_str_row (const char fieldname[NAMELENGTH+1], const char newval[BUFSIZE+1]) { if (strcmp(fieldname,"HGid2")==0) strcpy(HGid2,newval); else if (strcmp(fieldname,"shape")==0) strcpy(shape,newval); else if (strcmp(fieldname,"txtfont")==0) strcpy(txtfont,newval); }