首页 > 其他 > 详细

数据类的设计

时间:2014-06-06 18:19:44      阅读:362      评论:0      收藏:0      [点我收藏+]

**info.h

#pragma once

_MB_DATABASE_BEGIN

class MB_DATABASE_EXT CBeamSection:public CSection
{
public:
	CBeamSection();
	CBeamSection(const CBeamSection* pBeamSection);
	virtual ~CBeamSection(void);
	virtual CSection* Clone() const { return new CBeamSection(this);}
	virtual void Copy(const CSection* pSection);
	virtual BOOL Compare(const CSection* pSection) const;
	CBeamSection & operator = (const CBeamSection &BeamSection){ Copy(&BeamSection);return *this; }
	BOOL operator == (const CBeamSection &BeamSection) const { return Compare(&BeamSection); }
	virtual BOOL Import(const CSection* pSection);
	virtual void Serialize(CArchive& ar);
}
_MB_DATABASE_END


**info.cpp

_MB_DATABASE_BEGIN

CBeamSection::CBeamSection()
{
	m_enType=BST_STANDARD;
	m_enSectionType=ST_SPC001;
	m_dGrade = 0;
	m_dH = 1.5;
}
CBeamSection::CBeamSection(const CBeamSection* pBeamSection)
{
	Copy(pBeamSection);
}
CBeamSection::~CBeamSection(void)
{
}

void CBeamSection::Copy(const CSection* pSection)
{
  if (this == pSection) return;
	Import(pSection);
	CSection::Copy(pSection);
}

BOOL CBeamSection::Compare(const CSection* pSection) const
{
	_ASSERTE_RT_BL(pSection);
	if(!CSection::Compare(pSection))		return FALSE;
	const CBeamSection* pBeamSection = dynamic_cast<const CBeamSection*>(pSection);
	_ASSERTE_RT_BL(pBeamSection);

	if(m_enType != pBeamSection->m_enType)	return FALSE;
	if(m_enSectionType != pBeamSection->m_enSectionType)	return FALSE;
	if(!Equal2Dbl(m_dGrade, pBeamSection->m_dGrade))	return FALSE;
	if(!Equal2Dbl(m_dH, pBeamSection->m_dH))	return FALSE;

	return TRUE;
}

BOOL CBeamSection::Import(const CSection* pSection)
{
	const CBeamSection* pBeamSection = dynamic_cast<const CBeamSection*>(pSection);
	_ASSERTE_RT_BL(pBeamSection);
	m_enType       = pBeamSection->m_enType;
	m_bSingleSlope = pBeamSection->m_bSingleSlope;
	m_dGrade       = pBeamSection->m_dGrade;
	m_dH           = pBeamSection->m_dH;
	return TRUE;
}

void CBeamSection::Serialize(CArchive& ar)
{
	CSection::Serialize(ar);

	if(ar.IsStoring())
	{
		_PRESAVE(_T("CBeamSection"))
		{
			_BEGINESAVE(DATABASE_VERSION1)
			ar<< m_bSingleSlope;
			ar<< m_dGrade;
			ar<< m_dH;   
			MBasic::Serialize(ar,m_enType);
			_ENDSAVE
		}
		_POSTSAVE
	}
	else
	{
		_PREOPEN(_T("CBeamSection"))
		{
		  case DATABASE_VERSION1:	
			  ar>> m_bSingleSlope;
			  ar>> m_dGrade;
			  ar>> m_dH;
			  MBasic::Serialize(ar,m_enType);
			  break;
		}
		_POSTOPEN
	}
}
_MB_DATABASE_END




数据类的设计,布布扣,bubuko.com

数据类的设计

原文:http://www.cnblogs.com/zfyouxi/p/3766321.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!