搭建PVB架构,实现前端的基础布局、菜单、表格、图示等功能

This commit is contained in:
lixiaoyuan
2025-08-20 19:00:22 +08:00
parent 5de7687bcc
commit 7e965b6fb4
142 changed files with 28270 additions and 411 deletions

View File

@@ -0,0 +1,70 @@
/***************************************************************************
BMP.h - description
-------------------
begin : Sun Okt 12 2001
copyright : (C) 2000 by R. Lehrig
email : lehrig@t-online.de
***************************************************************************/
/***************************************************************************
* *
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as *
* published by the Free Software Foundation *
* *
***************************************************************************/
typedef struct mytagBITMAPFILEHEADER
{ // bmfh
unsigned short int bfType;
unsigned short int bfSize[2];
unsigned short int bfReserved1;
unsigned short int bfReserved2;
unsigned short int bfOffBits[2];
} myBITMAPFILEHEADER;
typedef struct mytagBITMAPINFOHEADER{ // bmih
unsigned int biSize;
unsigned int biWidth;
unsigned int biHeight;
unsigned short int biPlanes;
unsigned short int biBitCount;
unsigned int biCompression;
unsigned int biSizeImage;
unsigned int biXPelsPerMeter;
unsigned int biYPelsPerMeter;
unsigned int biClrUsed;
unsigned int biClrImportant;
} myBITMAPINFOHEADER;
typedef struct mytagBITMAPCOREHEADER { // bmch
unsigned int bcSize;
unsigned short int bcWidth;
unsigned short int bcHeight;
unsigned short int bcPlanes;
unsigned short int bcBitCount;
} myBITMAPCOREHEADER;
typedef struct mytagRGBTRIPLE { // rgbt
unsigned char rgbtBlue;
unsigned char rgbtGreen;
unsigned char rgbtRed;
} myRGBTRIPLE;
typedef struct mytagRGBQUAD { // rgbq
unsigned char rgbBlue;
unsigned char rgbGreen;
unsigned char rgbRed;
unsigned char rgbReserved;
} myRGBQUAD;
/* following BITMAPFILEHEADER */
typedef struct mytagBITMAPINFO {
myBITMAPINFOHEADER bmiHeader;
myRGBQUAD bmiColors[1];
} myBITMAPINFO;
/* following BITMAPFILEHEADER */
typedef struct my_BITMAPCOREINFO { // bmci
myBITMAPCOREHEADER bmciHeader;
myRGBTRIPLE bmciColors[1];
} myBITMAPCOREINFO;

View File

@@ -0,0 +1,415 @@
/*====================================================================
This software was written by Ian L. Kaplan, Chief Fat Bear, Bear Products
International. Use of this software, for any purpose, is granted on two
conditions:
1. This copyright notice must be included with the software
or any software derived from it.
2. The risk of using this software is accepted by the user. No
warranty as to its usefulness or functionality is provided
or implied. The author and Bear Products International provides
no support.
====================================================================*/
#ifndef DXF2GL_H
#define DXF2GL_H
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
// These rather convoluted ifndef's are required because both FALSE, TRUE
// and BOOLEAN are defined by various windows and windows/nt headers. When
// these headers are included, a redefine error results without these ifndefs.
//
typedef enum {
#ifndef FALSE
FALSE = 0,
#endif
#ifndef TRUE
TRUE = 1,
#endif
BOGUS
} BoolVals;
#ifndef _WIN32
typedef int BOOLEAN;
#endif
/* FileAccess - a class for opening and reading ASCII files.
Public functions:
FileAccess constructor - The argument to this constructor is
the file name. The constructor will
open the file and set the variable
FileOpenOK (which can be accessed via
FileOK).
FileAccess destructor - Close the file
get_line - get a line for the file and return it as a null
terminated string.
*/
class FileAccess {
// Variables
private:
FILE *FilePtr;
BOOLEAN FileOpenOK;
protected:
public:
// Class Functions
private:
//OpenFile(char *FileName);
void file_error(const char *msg);
protected:
public:
FileAccess(const char *FileName = "" );
~FileAccess(void);
BOOLEAN FileOK(void) { return FileOpenOK; }
BOOLEAN get_line(char *LineBuf, const int BufSize);
}; // FileAccess
/*
The page_pool object is designed to support rapid memory allocation
and deallocation of all allocated memory, once the object is no
longer needed. By using a block allocation scheme, the overhead of
memory allocation is greatly reduced, compared to "malloc" (or new).
Deallocation of large blocks of memory is also much faster than
calling free for every allocated block of memory.
The page_pool allocator allocates blocks of memory in "page_size"
increments. The page_size variable is set at start-up and contains
the system virtual memory page size.
The page_pool object contains the virtual function "add_to_list"
which can be implemented by the inherited function
ordered_list. Ordered list is a class that supports ordered list
insertion and deletion. In this case, this is used to support an
ordered list of free memory blocks. The ordered list is only
needed if the page_pool is used as the base for a memory allocater
that can allocate from a free list.
*/
class page_pool {
private: // typedefs and variables
typedef struct page_chain_struct
{ void *block;
unsigned int bytes_used;
unsigned int block_size;
page_chain_struct *next_page;
} page_chain;
// The min_block_size is the smallest block that will be returned by the
// page_pool allocater. The max_block_size is the largest memory block
// that can be requested. Ideally, this should be a multiple of the page
// size.
typedef enum { min_block_size = 96, max_block_size = 1024 * 8 } bogus;
page_chain *page_list_head;
page_chain *current_page;
static unsigned int page_size; // system page size, shared by all instances
private: // class functions
static unsigned int GetSysPageSize(void);
page_chain *new_block( unsigned int block_size );
void *add_block( unsigned int block_size );
public: // class functions
page_pool(void);
~page_pool(void);
void *page_alloc( unsigned int block_size );
void print_page_pool_info(void);
virtual void add_to_list(void *addr, unsigned int size);
}; // class page_pool
/*
A 3D graphic object can be described as a list of polygons. Each
of these polygons consists of three or more points in 3D space
(e.g., x, y, z coordinates).
The FaceList object will construct a list of polygon faces read from
a DXF file. Two DXF file polygon formats are supported:
- 3DFACE
- POLYLINE
The "face" structure member "f" is a pointer to an array of points.
This point array is dynamically allocated. The minimum number of
points that can be allocated for a polygon is four (a 3DFACE polygon
may only consist of three points, in which case the last point is
unused).
Although during creating there is a distinction made between DXF
3DFACE objects and POLYLINE objects, the class represents both as
polygon faces and no such distinction exists when the polygon
list is read.
The object supplies the following public functions for creating a
polygon list:
add_3DFACE_point - Add a 3D point to a 3DFACE polygon
add_poly_point - Add a 3D point to a POLYLINE polygon
get_new_3DFACE - Create a new 3DFACE polygon
get_new_poly_face - Create a new POLYLINE polygon
Once the polygon list is created, it can be read using the following
functions:
GetListStart - Return a handle for the start of the polygon face
list
GetFace - Get a polygon face, given a list handle
GetNextFace - Get the next polygon face in the list
*/
class FaceList {
public:
typedef enum {MinSize = 4} bogus; // minimum number of points
typedef enum {Xcoord, Ycoord, Zcoord} bogus2;
typedef struct { float v[3]; } vect; // a point in the 3D plane
typedef struct { vect *f; // an array of 3D points
int point_cnt; // number of points currently alloc'ed
int point_max; // max points
} face;
typedef void *ListHandle;
private:
typedef struct FaceListStruct { face cur_face;
struct FaceListStruct *next_face;
} FaceElem;
page_pool mem;
FaceElem *ListHead;
FaceElem *ListTail;
private:
void add_point(face *cur_face, float x, float y, float z);
// void GrowFace( face *cur_face );
public:
FaceList(void) { ListHead = NULL;
ListTail = NULL;
}
void add_3DFACE_point(float x, float y, float z );
void add_poly_point(float x, float y, float z);
void get_new_3DFACE(void);
void get_new_poly_face(int polypont);
ListHandle GetListStart(void) { return (ListHandle)ListHead; }
face *GetFace( ListHandle handle)
{ return &((FaceElem *)handle)->cur_face; }
ListHandle GetNextFace( ListHandle handle )
{ return (ListHandle)((FaceElem *)handle)->next_face; }
void print(void);
};
//
// The gl_token enumeration defines the tokens that are returned by the
// scanner and are used by the parser in attempting to recognize the
// components of a DXF file.
//
typedef enum { bad_gl_token,
section,
header,
endsec,
seqend,
blocks,
block,
endblk,
vertex,
tables,
table,
layer,
contin,
endtab,
entities,
three_d_face,
end_of_file,
polyline,
integer,
real,
name,
last_gl_token } gl_token;
/*
This file contains the stack object definition. The scanner
requires two token look ahead to resolve things like the EOF token
sequence. If this sequence is checked for, but not found, it is
necessary to "back up" the input stream. This is done via the token
stack.
Note that a DXF file may contain both integer and float values.
Two versions of "push_token" are implemented, one with an integer
value and one with a float value. The integer version may be used
with just a token value, in which case the default value will be
used for the integer.
*/
class token_stack {
public:
typedef union { int intval;
float realval;
} token_union;
typedef struct { gl_token token;
token_union val;
} token_stack_type;
private:
typedef enum {MaxTokens = 10} bogus1;
token_stack_type token_stack_buf[ MaxTokens ];
int token_sp;
public:
token_stack(void) { token_sp = MaxTokens; }
BOOLEAN StackHasItems(void) { return token_sp < MaxTokens; }
void push_token( gl_token token, int intval = 0 );
void push_token( gl_token token, float realval );
token_stack_type pop_token(void);
};
/*
This file contains the scanner object that tokenizes the input
stream. The scanner either returns a reserved word (e.g., section
or three_d_face), "name" (an identifier, such as a layer name or
face name), integer or real. The various DXF markers (e.g., the 70
marker or 0 for start) are returned as integers. This scanner is
designed as a front end for a program that reads a DXF file and
displays it as a 3D wire frame, using openGL (hense then "GL"
naming).
Scanning and parsing a DXF file is difficult, because the DXF file
format seems to have grown over time in an ad hoc manner. Further,
the documentation is obscure and/or incomplete. While parsing the
file, it is sometimes necessary to "back up". To support this, a
stack is maintained. Input tokens and values can be "pushed" onto
this stack and re-read. The token_stack class supports this feature.
*/
class GL_scanner {
// variables
private:
token_stack stack;
float gl_float;
int gl_int;
FileAccess *MyFileObj;
typedef enum {WordBufSize = 40} bogus2;
char WordBuf[ WordBufSize ];
protected:
public:
// class functions
private:
gl_token scan_number(char *cptr);
gl_token scan_word(char *cptr);
gl_token gl_name_lookup(void);
protected:
public:
GL_scanner( FileAccess *FileObj ) { MyFileObj = FileObj; }
float get_gl_float() { return gl_float; }
int get_gl_int() { return gl_int; }
char *get_gl_name() { return WordBuf; }
gl_token get_next_token(void);
BOOLEAN token_in_stack(void) { return stack.StackHasItems(); }
gl_token get_token_from_stack();
void put_token_in_stack(const gl_token token);
void put_token_in_stack(const gl_token token, int DX_val)
{ stack.push_token(token, DX_val); }
void print_token(const gl_token token);
};
/* This file contains the parser object that processes the DXF file.
The class function GL_GetFaceList returns the Face list for the
3D DXF object.
*/
class MinMax {
private:
float min;
float max;
public:
typedef enum {MAXVAL = 1024*1000} bogus;
// The initial values of max and min should be way beyond any reasonable
// range.
MinMax(void) { min = (float)MAXVAL; max = (float)(-(MAXVAL)); }
void SetMinMax( float val ) { if (val < min)
min = val;
if (val > max)
max = val;
}
float GetMin(void) { return min; }
float GetMax(void) { return max; }
};
class GL_object {
// variables
private:
GL_scanner *GL_scan;
protected:
public:
MinMax PointRange;
// class functions
private:
void set_min_max();
void undo(gl_token token);
BOOLEAN IsEndSec(void);
BOOLEAN IsStart(void);
BOOLEAN IsName(void);
BOOLEAN IsTable(void);
BOOLEAN IsLayerName(void);
BOOLEAN Is3DFace(void);
BOOLEAN IsEndSet(void);
float GetCoord(void);
void get_3DFACE_point(FaceList *FaceObjPtr);
void get_poly_point(FaceList *FaceObjPtr);
void SkipSection(void);
void Get3DFACE(FaceList *&CurObj);
void GetPolyLine(FaceList *&CurObj);
protected:
public:
GL_object(FileAccess *FileObj ) { GL_scan = new GL_scanner( FileObj ); };
~GL_object(void) { delete GL_scan; }
FaceList *GL_GetFaceList(void);
}; // GL_object
typedef enum { DXF_start = 0,
DXF_textval = 1,
DXF_name = 2,
DXF_othername1 = 3,
DXF_othername2 = 4,
DXF_entity_handle = 5,
DXF_line_type = 6,
DXF_text_style = 7,
DXF_layer_name = 8,
DXF_var_name = 9,
DXF_primary_X = 10,
DXF_other_X_1 = 11,
DXF_primary_Y = 20,
DXF_other_Y_1 = 21,
DXF_other_Z = 31,
DXF_elevation = 38,
DXF_thickness = 39,
DXF_floatvals = 40,
DXF_repeat = 49,
DXF_angle1 = 50, DXF_angle2 = 51,
DXF_angle3 = 52, DXF_angle4 = 53,
DXF_angle5 = 54, DXF_angle6 = 55,
DXF_angle7 = 56, DXF_angle8 = 57,
DXF_angle9 = 58,
DXF_colornum = 62,
DXF_entities_flg = 66,
DXF_ent_ident = 67,
DXF_SeventyFlag = 70,
DXF_SeventyOneFlag= 71,
DXF_SeventyTwoFlag= 72,
DXF_view_state = 69,
DXF_comment = 999 } DXF_values;
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,72 @@
// You may use this header if you use C++ string's
// avoid casts with .c_str()
// Warning: This file is NOT maintained on a regular basis, so some functions may be missing
// If you observe this please contact: R. Lehrig lehrig@t-online.de
#ifndef _PROCESS_VIEW_SERVER_STRING_H_
#define _PROCESS_VIEW_SERVER_STRING_H_
#include "processviewserver.h"
#include <string>
using namespace std;
inline int pvWait(PARAM *p, string pattern) { return pvWait(p, pattern.c_str()); }
inline int pvWarning(PARAM *p, string text) { return pvWarning(p, text.c_str()); }
inline int pvMainFatal(PARAM *p, string text) { return pvMainFatal(p, text.c_str()); }
inline int pvThreadFatal(PARAM *p, string text) { return pvThreadFatal(p, text.c_str()); }
inline int pvQButtonGroup(PARAM *p, int id, int parent, int columns, int orientation, string title) { return pvQButtonGroup(p, id, parent, columns, orientation, title.c_str()); }
inline int pvQImage(PARAM *p, int id, int parent, string imagename, int *w, int *h, int *depth) { return pvQImage(p, id, parent, imagename.c_str(), w, h, depth); }
inline int pvQGroupBox(PARAM *p, int id, int parent, int columns, int orientation, string title) { return pvQGroupBox(p, id, parent, columns, orientation, title.c_str()); }
inline int pvSetCaption(PARAM *p, string text) { return pvSetCaption(p, text.c_str()); }
inline int pvToolTip(PARAM *p, int id, string text) { return pvToolTip(p, id, text.c_str()); }
inline int pvSetText(PARAM *p, int id, string text) { return pvSetText(p, id, text.c_str()); }
inline int pvChangeItem(PARAM *p, int id, int index, string bmp_file, string text) { return pvChangeItem(p, id, index, bmp_file.c_str(), text.c_str()); }
inline int pvInsertItem(PARAM *p, int id, int index, string bmp_file, string text) { return pvInsertItem(p, id, index, bmp_file.c_str(), text.c_str()); }
inline int pvRemoveItemByName(PARAM *p, int id, string name) { return pvRemoveItemByName(p, id, name.c_str()); }
inline int pvAddColumn(PARAM *p, int id, string text, int size) { return pvAddColumn(p, id, text.c_str(), size); }
inline int pvSetTableText(PARAM *p, int id, int x, int y, string text) { return pvSetTableText(p, id, x, y, text.c_str()); }
inline int pvSetTableCheckBox(PARAM *p, int id, int x, int y, int state, string text) { return pvSetTableCheckBox(p, id, x, y, state, text.c_str()); }
inline int pvSetTableComboBox(PARAM *p, int id, int x, int y, int editable, string textlist) { return pvSetTableComboBox(p, id, x, y, editable, textlist.c_str()); }
inline int pvSetListViewText(PARAM *p, int id, string path, int column, string text) { return pvSetListViewText(p, id, path.c_str(), column, text.c_str()); }
inline int pvSetPixmap(PARAM *p, int id, string bmp_file) { return pvSetPixmap(p, id, bmp_file.c_str()); }
inline int pvSetTablePixmap(PARAM *p, int id, int x, int y, string bmp_file) { return pvSetTablePixmap(p, id, x, y, bmp_file.c_str()); }
inline int pvSetSource(PARAM *p, int id, string html_file) { return pvSetSource(p, id, html_file.c_str()); }
inline int pvSetImage(PARAM *p, int id, string filename) { return pvSetImage(p, id, filename.c_str()); }
inline int pvSetFont(PARAM *p, int id, string family, int pointsize, int bold, int italic , int underline, int strikeout) { return pvSetFont(p, id, family.c_str(), pointsize, bold, italic , underline, strikeout); }
inline int pvDisplayStr(PARAM *p, int id, string str) { return pvDisplayStr(p, id, str.c_str()); }
inline int pvAddTab(PARAM *p, int id, int id_child, string str) { return pvAddTab(p, id, id_child, str.c_str()); }
inline int pvSetListViewPixmap(PARAM *p, int id, string path, string bmp_file, int column) { return pvSetListViewPixmap(p, id, path.c_str(), bmp_file.c_str(), column); }
inline int pvRemoveListViewItem(PARAM *p, int id, string path) { return pvRemoveListViewItem(p, id, path.c_str()); }
inline int pvRemoveIconViewItem(PARAM *p, int id, string text) { return pvRemoveIconViewItem(p, id, text.c_str()); }
inline int pvSetIconViewItem(PARAM *p, int id, string bmp_file, string text) { return pvSetIconViewItem(p, id, bmp_file.c_str(), text.c_str()); }
inline int pvListViewEnsureVisible(PARAM *p, int id, string path) { return pvListViewEnsureVisible(p, id, path.c_str()); }
inline int pvListViewSetOpen(PARAM *p, int id, string path, int open) { return pvListViewSetOpen(p, id, path.c_str(), open); }
inline int pvVtkTcl(PARAM *p, int id, string tcl_command) { return pvVtkTcl(p, id, tcl_command.c_str()); }
inline int pvVtkTclScript(PARAM *p, int id, string filename) { return pvVtkTclScript(p, id, filename.c_str()); }
inline int pvHyperlink(PARAM *p, string link) { return pvHyperlink(p, link.c_str()); }
inline int pvWriteFile(PARAM *p, string filename, int width, int height) { return pvWriteFile(p, filename.c_str(), width, height); }
inline int pvSave(PARAM *p, int id, string filename) { return pvSave(p, id, filename.c_str()); }
inline int pvSaveAsBmp(PARAM *p, int id, string filename) { return pvSaveAsBmp(p, id, filename.c_str()); }
inline int pvSendFile(PARAM *p, string filename) { return pvSendFile(p, filename.c_str()); }
inline int pvDownloadFileAs(PARAM *p, string filename, string newname) { return pvDownloadFileAs(p, filename.c_str(), newname.c_str()); }
inline int pvDownloadFile(PARAM *p, string filename) { return pvDownloadFile(p, filename.c_str()); }
inline int pvPopupMenu(PARAM *p, int id_return, string text) { return pvPopupMenu(p, id_return, text.c_str()); }
inline int pvMessageBox(PARAM *p, int id_return, int type, string text, int button0, int button1, int button2) { return pvMessageBox(p, id_return, type, text.c_str(), button0, button1, button2); }
inline int pvInputDialog(PARAM *p, int id_return, string text, string default_text) { return pvInputDialog(p, id_return, text.c_str(), default_text.c_str()); }
inline int qpwSetTitle(PARAM *p, int id, string text) { return qpwSetTitle(p, id, text.c_str()); }
inline int qpwSetAxisTitle(PARAM *p, int id, int pos, string text) { return qpwSetAxisTitle(p, id, pos, text.c_str()); }
inline int qpwInsertCurve(PARAM *p, int id, int index, string text) { return qpwInsertCurve(p, id, index, text.c_str()); }
inline int qpwSetMarkerLabel(PARAM *p, int id, int number, string text) { return qpwSetMarkerLabel(p, id, number, text.c_str()); }
inline int qpwSetMarkerFont(PARAM *p, int id, int index, string family, int size, int style) { return qpwSetMarkerFont(p, id, index, family.c_str(), size, style); }
inline int qpwInsertLineMarker(PARAM *p, int id, int index, string text, int pos) { return qpwInsertLineMarker(p, id, index, text.c_str(), pos); }
inline int qpwSetAxisScaleDraw( PARAM *p, int id, int pos, string text ) { return qpwSetAxisScaleDraw( p, id, pos, text.c_str() ); }
inline int gWriteFile(string file) { return gWriteFile(file.c_str()); }
inline int gSetFont(PARAM *p, string family, int size, int weight, int italic) { return gSetFont(p, family.c_str(), size, weight, italic); }
inline int gText(PARAM *p, int x, int y, string text, int alignment) { return gText(p, x, y, text.c_str(), alignment); }
inline int gTextInAxis(PARAM *p, float x, float y, string text, int alignment) { return gTextInAxis(p, x, y, text.c_str(), alignment); }
inline int gSetFloatFormat(PARAM *p, string text) { return gSetFloatFormat(p, text.c_str()); }
inline int gBoxWithText(PARAM *p, int x, int y, int w, int h, int fontsize, string xlabel, string ylabel, string rylabel) { return gBoxWithText(p, x, y, w, h, fontsize, xlabel.c_str(), ylabel.c_str(), rylabel.c_str()); }
inline int gComment(PARAM *p, string comment) { return gComment(p, comment.c_str()); }
inline int gPlaySVG(PARAM *p, string filename) { return gPlaySVG(p, filename.c_str()); }
inline int qwtScaleSetTitle(PARAM *p, int id, string text) { return qwtScaleSetTitle(p, id, text.c_str()); }
inline int qwtScaleSetTitleFont(PARAM *p, int id, string family, int pointsize, int bold, int italic, int underline, int strikeout) { return qwtScaleSetTitleFont(p, id, family.c_str(), pointsize, bold, italic, underline, strikeout); }
#endif

View File

@@ -0,0 +1,31 @@
/***************************************************************************
pvapp.h - description
-------------------
begin : Sun Nov 12 2000
copyright : (C) 2000 by R. Lehrig
email : lehrig@t-online.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef _PVAPP_H_
#define _PVAPP_H_
#include "processviewserver.h"
int show_mask1(PARAM *p);
int show_mask2(PARAM *p);
int show_mask3(PARAM *p);
int show_mask4(PARAM *p);
int show_periodic(PARAM *p);
int show_maskvtk(PARAM *p);
int show_qwt(PARAM *p);
int show_modal1(PARAM *p);
#endif

View File

@@ -0,0 +1,36 @@
/***************************************************************************
pvbImage.h - description
-------------------
begin : Sun Okt 12 2001
copyright : (C) 2000 by R. Lehrig
email : lehrig@t-online.de
***************************************************************************/
/***************************************************************************
* *
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as *
* published by the Free Software Foundation *
* *
***************************************************************************/
#include "BMP.h"
typedef struct
{
unsigned char b,g,r,reserved;
}LUT;
typedef struct
{
int w,h,bpp,nLut;
LUT *lut;
void *image;
}
PVB_IMAGE;
PVB_IMAGE *pvbImageRead(const char *filename);
void pvbImageFree(PVB_IMAGE *pvbImage);
int pvmyread(int fhdl, char *cptr, int len);
int pvopenBinary(const char *filename);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,122 @@
/***************************************************************************
wthread.h - description
-------------------
begin : Sun Nov 12 2000
copyright : (C) 2000 by R. Lehrig
email : lehrig@t-online.de
***************************************************************************/
/***************************************************************************
* *
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as *
* published by the Free Software Foundation *
* *
***************************************************************************/
/***********************************************************************************
Wrapper for posix threads (UNIX,VMS,windows)
(C) R. Lehrig 2000 lehrig@t-online.de
***********************************************************************************/
#ifndef _WTHREAD_H_
#define _WTHREAD_H_
#include "processviewserver.h"
#ifdef PVWIN32
#define WTREAD_GNUC1 ( __GNUC__ * 1000 ) + __GNUC_MINOR__
#if WTREAD_GNUC1 < 4008
#define PVWIN32THREAD
#endif
#include <windows.h>
#include <winbase.h>
#endif
#include <stddef.h>
#include <string.h>
#ifdef PVWIN32THREAD
#ifndef _WRAPTHREAD_
#ifndef _RL_WTHREAD_H_
typedef unsigned long int pthread_t;
/* Attributes for threads */
struct __sched_param
{
int sched_priority;
};
typedef struct
{
int __detachstate;
int __schedpolicy;
struct __sched_param __schedparam;
int __inheritsched;
int __scope;
size_t __guardsize;
int __stackaddr_set;
void *__stackaddr;
size_t __stacksize;
}pthread_attr_t;
typedef HANDLE pthread_mutex_t;
//old typedef CRITICAL_SECTION pthread_mutex_t;
typedef long pthread_mutexattr_t;
#endif
#endif
#else /* VMS or UNIX or new GCC on Windows*/
#ifndef WIN_PTHREADS_H
#include <pthread.h>
#endif
#endif /* end of MSWINDOWS */
#ifndef _WRAPTHREAD_
#ifndef _RL_WTHREAD_H_
typedef struct
{
#ifdef PVWIN32THREAD
int cmax;
HANDLE hSemaphore;
#else
int cmax;
int nready;
pthread_mutex_t mutex;
pthread_cond_t cond;
#endif
}WSEMAPHORE;
#endif
#endif
/* function prototypes */
#ifndef __VMS
#ifdef __cplusplus
extern "C" {
#endif
#endif
int pvthread_attr_init(pthread_attr_t *attr);
int pvthread_create(pthread_t *tid, const pthread_attr_t *attr,
void *(*func)(void*), void *arg);
void pvthread_close_handle(pthread_t *tid);
void pvthread_exit(void *status);
int pvthread_join(pthread_t tid, void **status);
int pvthread_mutex_init(pthread_mutex_t *mptr, const pthread_mutexattr_t *attr);
int pvthread_mutex_destroy(pthread_mutex_t *mptr);
int pvthread_mutex_lock(pthread_mutex_t *mptr);
int pvthread_mutex_trylock(pthread_mutex_t *mptr);
int pvthread_mutex_unlock(pthread_mutex_t *mptr);
int pvthread_cancel(pthread_t tid);
int pvinit_semaphore(WSEMAPHORE *s, int cmax);
int pvincrement_semaphore(WSEMAPHORE *s);
int pvwait_semaphore(WSEMAPHORE *s);
int pvthread_sleep(long msec);
#ifndef __VMS
#ifdef __cplusplus
};
#endif
#endif
#endif