connection.cpp

来自「opc 源码 opc 源码」· C++ 代码 · 共 63 行

CPP
63 行
字号
// Connection.cpp: implementation of the CConnection class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "VCOPCClient.h"
#include "Connection.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CConnection::CConnection() : m_hServer(INVALID_HANDLE_VALUE)
{

}

CConnection::~CConnection()
{
	//删除已经创建的组
	for( vector<CGroup*>::iterator iter = m_Groups.begin();
		 iter != m_Groups.end(); 
		 ++iter)
	{
		RemoveGroup(m_hServer, (*iter)->m_Handle);
		delete *iter;
	}
	m_Groups.clear();
}

CGroup* CConnection::GetGroup(CString& strGroup)
{
	for( vector<CGroup*>::iterator iter = m_Groups.begin();
		 iter != m_Groups.end(); 
		 ++iter)
	{
		if ( strcmp(strGroup, (*iter)->m_Name) == 0 )
		{
			return *iter;
		}
	}
	return NULL;	
}

void CConnection::EraseGroup(CString& strGroup)
{
	for( vector<CGroup*>::iterator iter = m_Groups.begin();
		 iter != m_Groups.end(); 
		 ++iter)
	{
		if ( strcmp(strGroup, (*iter)->m_Name) == 0 )
		{
			m_Groups.erase(iter);
			return;
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?