?? wfl.h
字號:
#if defined (WORKFLOW_Sym) /* Allow compiler one copy */
#else
#define WORKFLOW_Sym
/***********************************************************************
**+
** Module Name: workflow.h
**
** Description: Workflow specific defines
**
** Include Modules Referenced: None.
**
** Written by: John Tal
**
**
** Modification history:
**
** Date Engineer Mod # Modification Description
**
** 07-Jul-1991 Tal v 1.0-001 Initial release
**
***********************************************************************/
#define WRK_KEY_LEN 16 /* standard key length */
#define WRK_MAX_TRN_STATES 10 /* limit of transition states per profile */
#define WRK_NO_JOB -1 /* no jobs for a process */
#define WRK_DUPLICATE_ID -2
/*
** A workflow management system is a way to coordinate several processes
** which are all processing the same set of data. The environment
** in which the concept was developed at I2MS was for distributed Unix
** processing. Concept was defined by Mike Peregoy and implemented by
** the I2MS Blue Shield Imaging team lead by John Tal (Spring 1991).
**
** Basically, a workflow management system (WMS) is a way to 'send' jobs
** around a network through various states or queues. A particular
** process is looking for jobs with a particular state. Jobs it finds
** with a matching state are taken and locked for processing. When that
** process is finished processing a job, it resets the state to another
** value. This value is likely a selection value for another process.
**
** Network
**
** Process 1 Loads jobs into database
** Sets Jobs to state 200
**
** Process 2 Looking for Jobs with state 200
** Sets completed Jobs to state 300
**
** Process 3 Looking for Jobs with state 300
** Sets completed Jobs to state 400
**
** Process 4 Looking for Jobs with state 300
** Deletes jobs from database
**
**
**
** A major advantage to a WMS is the ability for the system manager to
** 'customize' the operation of the system. (Process 3 could execute
** before Process 2.)
**
** A review of WMS for the right-side of the brain.....
**
** All of these processes are plugged into this network
** and grab any jobs they can. After processing, they
** set the job state so that another process can have some
** fun.
**
** The program below is an example of how to use the C algorithms in
** constructing a WMS based on an in-memory database.
**
** A WMS would typically be created in a library layer above the
** disk-based data-base.
**
** FURTHER DEVELOPMENT
**
** An evolution to the EMS (especially meaningful in a multi-tasking
** environment) would be to have each process block until a job is
** available for processing. This would eliminate the constant
** polling to the database.
**
** To implement a priority-based scheme, you could add a priority to
** each job and change the link-list off each state node in the
** binary tree to a heap. The only limitation is that because most
** heaps are implemented in arrays, you would have to allocate for a
** maximum size if only one job existed at a given state.
**
*/
/*
** The following item is at each node of the workflow binary tree
**
** The workflow binary tree has one node for each state. All jobs
** for the same state are connected in a link-list off of the binary
** tree node for that state.
*/
/*
** The workflow data (WORK_ITEM_S) is stored in a linked-list hung off
** of a binary tree.
**
** The WORK_ITEM is data about each job.
*/
/*
** This is the workflow profile data
**
** It is contained in a linked list which is belongs to a process.
**
** This is a profile to describe how each 'process' is to access the data.
** A process initializes for this data once and then does queries against
** the master set of WORK_ITEM data to get a job for processing.
**
** The profile data contains the selection, activation, and transition
** state values. A process may have multiple WORK_FLOW entries as
** part of its profile.
**
** The profile data would normally be stored in a file on disk.
*/
/*
** The following are the array [] offsets for each type of state in the
** WORK_FLOW . sTrnState[]
*/
#define WRK_SEL_STATE 0
#define WRK_ACT_STATE 1
#define WRK_TRN_STATE 2
class PROFILE_C
{
protected:
LLIST_C clProfiles;
public:
struct PROFILE_S
{
CHAR szKey[WRK_KEY_LEN + 1]; /* Key = ID of process */
SHORT sTrnState[10]; /* States themselves */
SHORT sTrnStates; /* How many states are there */
};
typedef struct PROFILE_S PROFILE_T;
typedef PROFILE_T * PROFILE_P;
typedef PROFILE_T ** PROFILE_PP;
public:
PROFILE_C(VOID) {};
~PROFILE_C(VOID) {};
SHORT Add(PROFILE_P pstProfile);
SHORT Get(PROFILE_PP ppstProfile);
};
typedef PROFILE_C * PROFILE_CP;
typedef PROFILE_C ** PROFILE_CPP;
class WORK_FLOW_C
{
private:
struct WORK_TREE_S
{
SHORT sState; /* the state */
LLIST_C pstList; /* ptr to the list of jobs at that state */
};
typedef struct WORK_TREE_S WORK_TREE_T;
typedef WORK_TREE_T * WORK_TNODE_P;
TREE_C clStateTree;
TREE_C clIdTree;
protected:
struct WORK_ITEM_S
{
SHORT sState; /* the state, or queue job is currently at */
CHAR szId[WRK_KEY_LEN + 1]; /* unique identifier for job */
CHAR szKey[WRK_KEY_LEN + 1]; /* current or last owners Id */
BOOL fLocked; /* is currently in use */
PVOID pvData; /* common data type all processes/owners are using */
};
typedef struct WORK_ITEM_S WORK_ITEM_T;
typedef WORK_ITEM_T * WORK_ITEM_P;
typedef WORK_ITEM_T ** WORK_ITEM_PP;
friend SHORT CompareId(PVOID pvData1,PVOID pvData2);
friend SHORT CompareNodeState(PVOID pvData1,PVOID pvData2);
friend SHORT CompareState(PVOID pvData1,PVOID pvData2);
public:
#define WRK_TRN_OK 0
#define WRK_TRN_ERR_1 1
#define WRK_TRN_ERR_2 2
WORK_FLOW_C(void) {};
~WORK_FLOW_C(void) {};
SHORT Add(PCHAR szId, SHORT sState, PVOID pvData);
SHORT Select(PROFILE_CP pclProfile, PCHAR * ppcId, PVOID * ppvData);
SHORT SetTrans(PCHAR szId, PROFILE_CP pclProfile, SHORT sTrnStateNdx);
SHORT UnLock(PCHAR pcId, PROFILE_CP pclProfile);
};
typedef WORK_FLOW_C * WORK_FLOW_CP;
typedef WORK_FLOW_C ** WORK_FLOW_CPP;
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -