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

📄 datasupport.h

📁 一个windows系统下查看网络拓扑结构的程序
💻 H
字号:
#ifndef DATASUPPORT
#define DATASUPPORT
#include "stdafx.h"
#include "NetExplorer.h"
#include "RouterButton.h"
#include ".\routerbutton.h"


struct Line
{
	void *PFrom;
	void *PTo;
};
struct RouterEnty
{
	CRouterButton ButtonEnty;
	CList <Line *> ChildList;
	CList <ULONG> RouterIP;
	int CurrentPosition;
	
};

class DistributeDate//在这个类里实现了两个链表,分别用来存储所有的路由器节点和连线节点,这里实现了添加某个节点的子节点的功能,其余功能未实现
{                  //值得注意的是,这里不实现绘图功能,在重新绘制的时候,基于按钮的路由器节点没必要考虑,只需要划线即可
public:           //实现划线操作只需要便历所有的Line结构,并把其中标识的全部线画一遍就可以了,而新生成的节点位置需要在view类里定位,并由View调用Create函数
	CCriticalSection Section;
	RouterEnty* AddChild(RouterEnty *Father,CList <ULONG> &Child)//这个函数给某个节点添加新的子节点,如果添加新的节点为回路,则返回NULL,否则返回新的节点值
	{
		POSITION p=this->AllRouterEnty.GetHeadPosition();
		for(int i=0;i<this->AllRouterEnty.GetCount();i++)
		{
			RouterEnty * P=this->AllRouterEnty.GetNext(p);
			
			int Len=(int)P->RouterIP.GetCount();
			if(Len==Child.GetCount())
			{
				POSITION q=P->RouterIP.GetHeadPosition();
				POSITION r=Child.GetHeadPosition();
				ULONG Res1,Res2;
				Res1=Res2=0;//xffffffff;
				for(int j=0;j<Len;j++)
				{
					Res1+=(P->RouterIP.GetNext(q)%283);
					Res2+=(Child.GetNext(r)%283);
				}
				if(Res1==Res2)//rowback!
				{	
					if(Father!=P)
					{
						Line *PLine=this->NewLine(Father,P);
					}
					return NULL;
				}
			}
			else
			{
				continue;
			}
		
		}
		//CList <ULONG> ChildParament;
		//ChildParament.AddTail(Child);
		RouterEnty *PChild=this->NewRouterEnty(Child);
		Line *PLine=this->NewLine(Father,PChild);
		return PChild;
	}
	Line* NewLine(RouterEnty *PFrom,RouterEnty *PTo)
	{
		Line *P=new Line;
		P->PFrom=PFrom;
		P->PTo=PTo;
		Section.Lock();
		this->AllLine.AddTail(P);
		Section.Unlock();
		return P;
	}
	RouterEnty* NewRouterEnty(CList<ULONG> &RouterIp)
	{
		RouterEnty *P=new RouterEnty;
		P->CurrentPosition=0;
		POSITION p=RouterIp.GetHeadPosition();
		for(int i=0;i<RouterIp.GetCount();i++)
		{
			ULONG Tmp=RouterIp.GetNext(p);
			P->RouterIP.AddTail(Tmp);
			Section.Lock();
			P->ButtonEnty.IPList.AddTail(Tmp);
			Section.Unlock();
		}
		this->AllRouterEnty.AddTail(P);
		return P;
	}
	CList<Line*> AllLine;
	CList<RouterEnty*> AllRouterEnty;
	DistributeDate()
	{
	}
	~DistributeDate()
	{
		this->Destroy();
	}
	void Destroy()
	{
		POSITION p;
		p=this->AllLine.GetHeadPosition();
		for(int i=0;i<this->AllLine.GetCount();i++)
		{
			Line* P=this->AllLine.GetNext(p);
			delete P;
		}
		this->AllLine.RemoveAll();
		p=this->AllRouterEnty.GetHeadPosition();
		for(i=0;i<this->AllRouterEnty.GetCount();i++)
		{
			RouterEnty * P=this->AllRouterEnty.GetNext(p);
			delete P;
		}
		this->AllRouterEnty.RemoveAll();
	}
};


#endif

⌨️ 快捷键说明

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