首页 > 代码库 > 数据类的设计
数据类的设计
**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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。