⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 link.cpp

📁 机甲指挥官2源代码
💻 CPP
字号:
//===========================================================================//
// File:	link.cc                                                          //
// Contents: Implementation details of base Link                             //
//---------------------------------------------------------------------------//
// Copyright (C) Microsoft Corporation. All rights reserved.                 //
//===========================================================================//

#include "StuffHeaders.hpp"

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Link ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//
//#############################################################################
// Link
//#############################################################################
//
Link::Link(
	Socket *socket,
	Plug *plug
)
{
	this->socket = socket;
	this->plug = plug;

	//
	//----------------------------------------------------
	// Add this new link to the plugs current set of links
	//----------------------------------------------------
	//
	AddToPlug(plug);
}

//
//#############################################################################
// ~Link
//#############################################################################
//
Link::~Link()
{
	Check_Signature(this);
	//
	//-----------------------------------------------------
	// Remove this link from the plugs current set of links
	//-----------------------------------------------------
	//
	Verify(!nextLink);
	Verify(!prevLink);
	Check_Object(plug);
	Verify(plug->linkHead != this);
}

//
//#############################################################################
// TestInstance
//#############################################################################
//
void
	Link::TestInstance()
{
	Check_Signature(socket);
	Check_Signature(plug);
}

//
//#############################################################################
// ReleaseFromPlug
//#############################################################################
//
void
	Link::ReleaseFromPlug()
{
	Check_Object(this);
	//
	//-----------------------------------------------------
	// Remove this link from the plugs current set of links
	//-----------------------------------------------------
	//
	Check_Object(plug);
	if (plug->linkHead == this)
	{
		plug->linkHead = nextLink;
	}
	if (prevLink != NULL)
	{
		Check_Object(prevLink);
		prevLink->nextLink = nextLink;
	}
	if (nextLink != NULL)
	{
		Check_Object(nextLink);
		nextLink->prevLink = prevLink;
	}
	prevLink = nextLink = NULL;
}

//
//#############################################################################
// AddToPlug
//#############################################################################
//
void
	Link::AddToPlug(Plug *plug)
{
	Check_Object(this);
	Check_Object(plug);

	if ((nextLink = plug->linkHead) != NULL)
	{
		Check_Object(nextLink);
		nextLink->prevLink = this;
	}
	this->prevLink = NULL;
	plug->linkHead = this;
}

⌨️ 快捷键说明

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