16,472
社区成员
发帖
与我相关
我的任务
分享
// Graph.h : header file
class CGraph : public CObject
{
DECLARE_SERIAL(CGraph)
public:
CGraph();
CGraph(UINT m_nDrawType, CPoint m_ptOrigin, CPoint m_ptEnd);
void Draw(CDC*pDC);
// Attributes
public:
unsigned int m_nDrawType;
CPoint m_ptOrigin;
CPoint m_ptEnd;
unsigned int m_nLineWidth;
// Operations
public:
// Implementation
public:
virtual ~CGraph();
virtual void Serialize(CArchive& ar);
};
////////////////////////////////////////////
// Graph.cpp
IMPLEMENT_SERIAL(CGraph,CObject,1)
CGraph::CGraph()
{
m_nDrawType = 0;
m_nLineWidth = 0;
}
CGraph::CGraph(UINT nDrawType, CPoint ptOrigin, CPoint ptEnd)
{
m_nDrawType = nDrawType;
m_ptOrigin = ptOrigin;
m_ptEnd = ptEnd;
}
CGraph::~CGraph()
{
}
void CGraph::Serialize(CArchive &ar)
{
if (ar.IsStoring())
{
ar << m_nDrawType << m_ptOrigin << m_ptEnd;
}
else
{
ar>> m_nDrawType >> m_ptOrigin >> m_ptEnd;
}
}
缺:
CGraph::~CGraph()
{
}
/////////////////////////////////////////////////////////////////////////////
// class CObject is the root of all compliant objects
#ifdef _AFXDLL
class CObject
#else
class AFX_NOVTABLE CObject
#endif
{
public:
// Object model (types, destruction, allocation)
virtual CRuntimeClass* GetRuntimeClass() const;
virtual ~CObject(); // virtual destructors are necessary
// Diagnostic allocations
void* PASCAL operator new(size_t nSize);
void* PASCAL operator new(size_t, void* p);
void PASCAL operator delete(void* p);
#if _MSC_VER >= 1200
void PASCAL operator delete(void* p, void* pPlace);
#endif
#if defined(_DEBUG) && !defined(_AFX_NO_DEBUG_CRT)
// for file name/line number tracking using DEBUG_NEW
void* PASCAL operator new(size_t nSize, LPCSTR lpszFileName, int nLine);
#if _MSC_VER >= 1200
void PASCAL operator delete(void *p, LPCSTR lpszFileName, int nLine);
#endif
#endif
// Disable the copy constructor and assignment by default so you will get
// compiler errors instead of unexpected behaviour if you pass objects
// by value or assign objects.
protected:
CObject();
private:
CObject(const CObject& objectSrc); // no implementation
void operator=(const CObject& objectSrc); // no implementation
// Attributes
public:
BOOL IsSerializable() const;
BOOL IsKindOf(const CRuntimeClass* pClass) const;
// Overridables
virtual void Serialize(CArchive& ar);
#if defined(_DEBUG) || defined(_AFXDLL)
// Diagnostic Support
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// Implementation
public:
static const AFX_DATA CRuntimeClass classCObject;
#ifdef _AFXDLL
static CRuntimeClass* PASCAL _GetBaseClass();
#endif
};