www.pudn.com > Ge_opc_Server_v1.rar > GRP_LIST.CPP


// Grp_list.cpp 
// 
//  This file contains the implementation of 
//  the LHEpipeview Group Object ITEM LIST management functions 
//  for the OPC server. 
// 
// 
//  (c) COPYRIGHT 1997 INTELLUTION INC. 
//  ALL RIGHTS RESERVED 
// 
// Original Author: Al Chisholm 
// 
// Note - this logic supports a fixed list of N_ITEMS 
// But is designed to be easily modified to support a varaiable length list 
// 
// Modification Log: 
// Vers    Date   By    Notes 
// ----  -------- ---   ----- 
// 0.90  04/08/97 ACC 
// 
 
#define WIN32_LEAN_AND_MEAN 
#define NOCOMM 
 
#include "OPCLHEpipeview.h" 
 
 
 
/////////////////////////////////////// 
// LHEpipeviewGroup::ItemValid 
// Verify that a handle is valid 
// 
BOOL LHEpipeviewGroup::ItemValid(OPCHANDLE h) 
{ 
	if (h >= N_ITEMS) return 0; 
	if(!m_items[h].inuse) return 0; 
	return 1; 
} 
 
 
/////////////////////////////////////// 
// LHEpipeviewGroup::ItemPtr 
// Return ptr to item, given handle 
// 
LHEpipeviewItem* LHEpipeviewGroup::ItemPtr(OPCHANDLE h) 
{ 
	if (!ItemValid(h)) return 0; 
	return m_items[h].pItem; 
} 
 
 
/////////////////////////////////////// 
// LHEpipeviewGroup::ItemHandles 
// Return # item handles (for use in loops) 
// Note that some item handles may be empty (See ItemValid) 
// 
int LHEpipeviewGroup::ItemHandles(void) 
{ 
	return N_ITEMS; 
} 
 
 
/////////////////////////////////////// 
// LHEpipeviewGroup::ItemAlloc 
// Return next available item handle 
// 
HRESULT LHEpipeviewGroup::ItemAlloc(OPCHANDLE *h) 
{ 
	int j; 
 
	// find a place to put the item 
	// 
	for(j=0; j= N_ITEMS) 
	{ 
		return E_OUTOFMEMORY; 
	} 
	*h = j; 
	return S_OK; 
} 
 
 
/////////////////////////////////////// 
// LHEpipeviewGroup::ItemReAlloc 
// Make sure a specific handle is available 
// (used only by Clone - you can assume the handle is free) 
// 
HRESULT LHEpipeviewGroup::ItemReAlloc(OPCHANDLE h) 
{ 
	if(h < N_ITEMS) return S_OK; 
	return E_OUTOFMEMORY; 
} 
 
 
 
/////////////////////////////////////// 
// LHEpipeviewGroup::ItemSet 
// Assign an Item to a specific handle 
// 
void LHEpipeviewGroup::ItemSet(OPCHANDLE h, LHEpipeviewItem * p) 
{ 
	m_items[h].pItem = p; 
	m_items[h].inuse = 1; 
} 
 
 
/////////////////////////////////////// 
// LHEpipeviewGroup::ItemFree 
// Free a specific Item Handle 
// (caller is assumed to have freed the item itself) 
// 
void LHEpipeviewGroup::ItemFree(OPCHANDLE h) 
{ 
	m_items[h].pItem = 0; 
	m_items[h].inuse = 0; 
}