DataBase.cpp
资源名称:CAD.zip [点击查看]
上传用户:hehe2haha
上传日期:2013-08-16
资源大小:161k
文件大小:1k
源码类别:
CAD
开发平台:
Visual C++
- // DataBase.cpp: implementation of the CDataBase class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "DataBase.h"
- #include "Line.h"
- #include "Rectangle.h"
- #include "Circle.h"
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CDataBase::CDataBase()
- {
- }
- CDataBase::~CDataBase()
- {
- }
- CShape * CDataBase::OpenObject(ifstream &ifs)
- {
- char className[255];
- CShape *pShape = NULL;
- //读取类名
- ifs>>className;
- //识别类名
- if (strcmp(className,"CLine") == 0)
- {
- pShape = new CLine;
- }
- if(strcmp(className,"CCircle") == 0)
- {
- pShape = new CCircle;
- }
- if(strcmp(className,"CRectangle") == 0)
- {
- pShape = new CRectangle;
- }
- //文件无内容
- if (pShape == NULL) return pShape;
- pShape->Open(ifs);
- return pShape;
- }
- void CDataBase::SaveObject(ofstream &ofs,CShape* pShape)
- {
- pShape->SaveClassName(ofs);
- pShape->Save(ofs);
- }