数据类的设计

**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




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

虚坏叔叔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值