int DBObjRecord::Read (FILE *file,int swap) { if (DBObject::Read (file,swap) != DBSuccess) return (DBFault); if (fread ((char *) this + sizeof (DBObject),sizeof (DBObjRecord) - sizeof (DBObject) - sizeof (DBAddress),1,file) != 1) { CMmsgPrint (CMmsgSysError, "File Reading Error in: %s %d",__FILE__,__LINE__); return (DBFault); } if (swap) Swap (); if ((DataPTR = (DBAddress) ((char *) malloc (LengthVAR) - (char *) NULL)) == (DBAddress) NULL) { CMmsgPrint (CMmsgSysError, "Memory Allocation Error in: %s %d",__FILE__,__LINE__); return (DBFault); } if (fread ((char *) NULL + DataPTR,LengthVAR,1,file) != 1) { CMmsgPrint (CMmsgSysError, "File Reading Error in: %s %d",__FILE__,__LINE__); return (DBFault); } if (swap && ItemSizeVAR > 0) { DBUnsigned i; void (*swapFunc) (void *); switch (ItemSizeVAR) { case 1: swapFunc = (void (*) (void *)) NULL; break; case 2: swapFunc = DBByteOrderSwapHalfWord; break; case 4: swapFunc = DBByteOrderSwapWord; break; case 8: swapFunc = DBByteOrderSwapLongWord; break; default: CMmsgPrint (CMmsgAppError, "Invalid Item Size (Record %d %s) in: %s %d",RowID (), Name (),__FILE__,__LINE__); return (DBFault); } if (swapFunc != (void (*) (void *)) NULL) for (i = 0;i < LengthVAR;i += ItemSizeVAR) (*swapFunc) ((char *) NULL + DataPTR + i); } return (DBSuccess); }
TEST_F(JitValidateTest, ValidateOnReferenceTable) { JitRuntimeContext context; context.transaction_id = _transaction_context->transaction_id(); context.snapshot_commit_id = _transaction_context->snapshot_commit_id(); context.referenced_table = _test_table; auto source = std::make_shared<MockSource>(); auto validate = std::make_shared<JitValidate>(TableType::References); auto sink = std::make_shared<MockSink>(); // Link operators to pipeline source->set_next_operator(validate); validate->set_next_operator(sink); auto expected_value_itr = _expected_values.begin(); // input reference table has 2 chunks auto pos_list = std::make_shared<PosList>(4); context.pos_list = pos_list; // first chunk (*pos_list)[0] = RowID(ChunkID(0), 0u); (*pos_list)[1] = RowID(ChunkID(0), 1u); (*pos_list)[2] = RowID(ChunkID(0), 2u); (*pos_list)[3] = RowID(ChunkID(1), 0u); validate_row(ChunkID(0), ChunkOffset{0}, context, *expected_value_itr++, source, sink, TableType::References); validate_row(ChunkID(0), ChunkOffset{1}, context, *expected_value_itr++, source, sink, TableType::References); validate_row(ChunkID(0), ChunkOffset{2}, context, *expected_value_itr++, source, sink, TableType::References); validate_row(ChunkID(0), ChunkOffset{3}, context, *expected_value_itr++, source, sink, TableType::References); // second chunk (*pos_list)[0] = RowID(ChunkID(1), 1u); (*pos_list)[1] = RowID(ChunkID(1), 2u); (*pos_list)[2] = RowID(ChunkID(2), 0u); (*pos_list)[3] = RowID(ChunkID(2), 1u); validate_row(ChunkID(1), ChunkOffset{0}, context, *expected_value_itr++, source, sink, TableType::References); validate_row(ChunkID(1), ChunkOffset{1}, context, *expected_value_itr++, source, sink, TableType::References); validate_row(ChunkID(1), ChunkOffset{2}, context, *expected_value_itr++, source, sink, TableType::References); validate_row(ChunkID(1), ChunkOffset{3}, context, *expected_value_itr++, source, sink, TableType::References); }
UI2DView::UI2DView () : DBObject ("Noname 2DView",sizeof (UI2DView)) { char name [DBStringLength]; Widget menuBar, scrolledWindow, radioBox; Widget button; static Pixmap iconPixmap = (Pixmap) NULL, meshPixmap = (Pixmap) NULL; static Pixmap fullPixmap = (Pixmap) NULL, extentPixmap = (Pixmap) NULL; static Pixmap capturePixmap = (Pixmap) NULL, redrawPixmap = (Pixmap) NULL; static Pixmap zoomPixmap = (Pixmap) NULL, panePixmap = (Pixmap) NULL, userPixmap = (Pixmap) NULL; Pixel foreground, background; XWindowAttributes xwa; XSetWindowAttributes xswa; Atom deleteWindowAtom = XmInternAtom(XtDisplay(UITopLevel ()),(char *) "WM_DELETE_WINDOW",FALSE); _UI2DViewLIST.Add (this); sprintf (name,"2DView:%2d",RowID ()); Name (name); Image = (XImage *) NULL; DrawRegion = FullRegion = NULL; MaxVertexNumVAR = 0; PointARR = (XPoint *) NULL; RequiredEXT = (UIDataset ())->Extent (); DShell = XtVaCreatePopupShell ("UI2DView",xmDialogShellWidgetClass,UITopLevel (), XmNkeyboardFocusPolicy, XmPOINTER, XmNtitle, Name (), XmNtransient, false, XmNminWidth, 600, XmNminHeight, 450, NULL); XmAddWMProtocolCallback (DShell,deleteWindowAtom,(XtCallbackProc) _UI2DViewDeleteCBK,(XtPointer) this); MainFormW = XtVaCreateManagedWidget ("UI2DViewForm",xmFormWidgetClass,DShell, XmNdialogStyle, XmDIALOG_WORK_AREA, XmNshadowThickness, 0, XmNwidth, 600, XmNheight, 450, NULL); menuBar = XtVaCreateManagedWidget ("UI2DViewMenuBar",xmRowColumnWidgetClass,MainFormW, XmNtopAttachment, XmATTACH_FORM, XmNtopOffset, 2, XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 2, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 2, XmNorientation, XmHORIZONTAL, XmNrowColumnType, XmWORK_AREA, NULL); XtVaGetValues (MainFormW,XmNforeground, &foreground,XmNbackground, &background,NULL); iconPixmap = iconPixmap == (Pixmap) NULL ? XmGetPixmap(XtScreen (UITopLevel()),(char *) "GHAAS2Dview.bmp",foreground,background): iconPixmap; XtVaSetValues (DShell,XmNiconPixmap, iconPixmap,NULL); fullPixmap = fullPixmap == (Pixmap) NULL ? XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASfull.bmp", foreground,background) : fullPixmap; extentPixmap = extentPixmap == (Pixmap) NULL ? XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASextent.bmp",foreground,background) : extentPixmap; capturePixmap= capturePixmap == (Pixmap) NULL ? XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAAScapture.bmp",foreground,background):capturePixmap; redrawPixmap = redrawPixmap == (Pixmap) NULL ? XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASredraw.bmp", foreground,background) : redrawPixmap; zoomPixmap = zoomPixmap == (Pixmap) NULL ? XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASzoom.bmp", foreground,background) : zoomPixmap; panePixmap = panePixmap == (Pixmap) NULL ? XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASpane.bmp", foreground,background) : panePixmap; userPixmap = userPixmap == (Pixmap) NULL ? XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASuser.bmp", foreground,background) : userPixmap; meshPixmap = meshPixmap == (Pixmap) NULL ? XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASmesh.bmp", foreground,background) : meshPixmap; button = XtVaCreateManagedWidget ("UI2DViewRedrawButton",xmPushButtonGadgetClass,menuBar, XmNlabelType, XmPIXMAP, XmNlabelPixmap, redrawPixmap, NULL); XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _UI2DViewRedrawCBK,this); button = XtVaCreateManagedWidget ("UI2DViewFullButton",xmPushButtonGadgetClass,menuBar, XmNlabelType, XmPIXMAP, XmNlabelPixmap, fullPixmap, NULL); XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _UI2DViewFullActivateCBK,this); button = XtVaCreateManagedWidget ("UI2DViewExtentButton",xmPushButtonGadgetClass,menuBar, XmNlabelType, XmPIXMAP, XmNlabelPixmap, extentPixmap, NULL); XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _UI2DViewExtentActivateCBK,this); button = XtVaCreateManagedWidget ("UI2DViewCaptureButton",xmPushButtonGadgetClass,menuBar, XmNlabelType, XmPIXMAP, XmNlabelPixmap, capturePixmap, NULL); radioBox = XtVaCreateManagedWidget ("UI2DViewRadioBox",xmRowColumnWidgetClass,menuBar, XmNorientation, XmHORIZONTAL, XmNpacking, XmPACK_COLUMN, XmNisHomogeneous, true, XmNentryClass, xmToggleButtonGadgetClass, XmNradioBehavior, true, NULL); ZoomToggle = XtVaCreateManagedWidget ("UI2DViewZoomToggle",xmToggleButtonGadgetClass,radioBox, XmNlabelType, XmPIXMAP, XmNlabelPixmap, zoomPixmap, XmNshadowThickness, 0, XmNset, true, NULL); XtAddCallback (ZoomToggle,XmNvalueChangedCallback,(XtCallbackProc) _UI2DViewZoomToggleValueCBK,this); PaneToggle = XtVaCreateManagedWidget ("UI2DViewPaneToggle",xmToggleButtonGadgetClass,radioBox, XmNlabelType, XmPIXMAP, XmNlabelPixmap, panePixmap, XmNshadowThickness, 0, NULL); XtAddCallback (PaneToggle,XmNvalueChangedCallback,(XtCallbackProc) _UI2DViewPaneToggleValueCBK,this); UserToggle = XtVaCreateWidget ("UI2DViewUserToggle",xmToggleButtonGadgetClass,radioBox, XmNlabelType, XmPIXMAP, XmNlabelPixmap, userPixmap, XmNmappedWhenManaged, false, XmNshadowThickness, 0, NULL); XtAddCallback (UserToggle,XmNvalueChangedCallback,(XtCallbackProc) _UI2DViewUserToggleValueCBK,this); if (_UI2DViewUserFunction != (UI2DViewUserFunction) NULL) XtManageChild (UserToggle); MeshOptionW = XtVaCreateManagedWidget ("UI2DViewMeshOption",xmToggleButtonGadgetClass,menuBar, XmNlabelType, XmPIXMAP, XmNlabelPixmap, meshPixmap, XmNshadowThickness, 0, NULL); XtAddCallback (MeshOptionW,XmNvalueChangedCallback,(XtCallbackProc) _UI2DViewMeshOptionCBK,this); XtVaSetValues (menuBar, XmNmenuHelpWidget, MeshOptionW, NULL); ScaleW = XtVaCreateManagedWidget ("UI2DViewScale",xmScaleWidgetClass,MainFormW, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, menuBar, XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 2, XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, 18, XmNorientation, XmVERTICAL, XmNwidth, 16, NULL); XtAddCallback (ScaleW,XmNvalueChangedCallback,(XtCallbackProc) _UI2DViewScaleValueChangedCBK,this); scrolledWindow = XtVaCreateManagedWidget ("UI2DViewScrolledWindow",xmScrolledWindowWidgetClass,MainFormW, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, menuBar, XmNtopOffset, 2, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, ScaleW, XmNleftOffset, 3, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 3, XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, 3, XmNspacing, 2, NULL); HorScrollBarW = XtVaCreateManagedWidget ("UI2DViewHorScrollBar", xmScrollBarWidgetClass, scrolledWindow, XmNsliderSize, 100, XmNorientation, XmHORIZONTAL, XmNheight, 16, NULL); XtAddCallback (HorScrollBarW,XmNvalueChangedCallback,(XtCallbackProc) _UI2DViewHorScrollBarValueChangedCBK,this); VerScrollBarW = XtVaCreateManagedWidget ("UI2DViewVerScrollBar", xmScrollBarWidgetClass, scrolledWindow, XmNsliderSize, 100, XmNorientation, XmVERTICAL, XmNwidth, 16, NULL); XtAddCallback (VerScrollBarW,XmNvalueChangedCallback,(XtCallbackProc) _UI2DViewVerScrollBarValueChangedCBK,this); DrawingAreaW = XtVaCreateManagedWidget ("UI2DViewDrawingArea", xmDrawingAreaWidgetClass, scrolledWindow, XmNuserData, this, XmNbackground, UIColor (UIColorStandard,0), NULL); XtAddCallback (DrawingAreaW,XmNresizeCallback,(XtCallbackProc) _UI2DViewResizeCBK,this); XtAddEventHandler (DrawingAreaW,EnterWindowMask|LeaveWindowMask|PointerMotionMask|ButtonPressMask|ButtonReleaseMask, false,(XtEventHandler) _UI2DViewPointerEHR,this); XmScrolledWindowSetAreas(scrolledWindow,HorScrollBarW,VerScrollBarW,DrawingAreaW); _UI2DViewViewCursor = _UI2DViewViewCursor != (Cursor) NULL ? _UI2DViewViewCursor : XCreateFontCursor (XtDisplay (DrawingAreaW),XC_top_left_arrow), _UI2DViewUserCursor = _UI2DViewUserCursor != (Cursor) NULL ? _UI2DViewUserCursor : XCreateFontCursor (XtDisplay (DrawingAreaW),XC_crosshair); RegenCursor = XCreateFontCursor (XtDisplay (DrawingAreaW),XC_watch); ActiveCursor = xswa.cursor = _UI2DViewViewCursor; XChangeWindowAttributes (XtDisplay (DrawingAreaW), XtWindow (DrawingAreaW), CWCursor, &xswa); XGetWindowAttributes (XtDisplay (DrawingAreaW),XtWindow (DrawingAreaW),&xwa); Background = xwa.backing_pixel; xswa.backing_store = Always; XChangeWindowAttributes (XtDisplay (DrawingAreaW), XtWindow (DrawingAreaW),CWBackingStore,&xswa); InputMode (ZOOM_MODE); Size (); Set (); }