Example #1
0
Ball::Ball(const Ball& ball)
{
	_pPimpl = new BallPimpl;
	assert(_pPimpl);

	this->SetDiameter		(ball.GetDiameter		());
	this->SetCenterPoint	(ball.GetCenterPoint	());
	this->SetStatus			(ball.GetStatus			());
}
Example #2
0
//---------------------------------------------------------------------------
// ----- Methods :: File Serialize (XML) ----- //
//---------------------------------------------------------------------------
bool	Strip::Save		(const TCHAR* lpszFileName)
{
	// ----- Initialize & Declare ----- //
	FILE* stream = _tfopen(lpszFileName, _T("wb") CHARSET);

	if (stream == NULL || _pPimpl == NULL)
	{
		return false;
	}

	TiXmlDocument		doc;
	TiXmlDeclaration*	pDecl;
	TiXmlElement*		pRoot;
	TiXmlElement*		pBlockNode;
	TiXmlElement*		pUnitNode;
	TiXmlElement*		pBallNode;

	Block*				pBlockObject;
	Unit*				pUnitObject;
	Ball*				pBallObject;

	int					vectorBlockSize;
	int					vectorUnitCountX;
	int					vectorUnitCountY;
	int					vectorBallSize;

	pDecl = new TiXmlDeclaration("1.0", "euc-kr", "");
	doc.LinkEndChild(pDecl);

	// ----- Set a Strip Data ----- //
	pRoot = new TiXmlElement(ROOT_NAME_STRIP);
	pRoot->SetDoubleAttribute(ATTR_NAME_WIDTH,	_pPimpl->dWidth);
	pRoot->SetDoubleAttribute(ATTR_NAME_HEIGHT,	_pPimpl->dHeight);
	doc.LinkEndChild(pRoot);

	// ----- Insert a Block Data ----- //
	pBlockObject = FirstBlock();
	if (pBlockObject != NULL)
	{
		do
		{
			pBlockNode = new TiXmlElement(NODE_NAME_BLOCK);

			pBlockNode->SetDoubleAttribute(ATTR_NAME_COLUMN,	pBlockObject->GetColumn	());
			pBlockNode->SetDoubleAttribute(ATTR_NAME_ROW,		pBlockObject->GetRow	());
			pBlockNode->SetDoubleAttribute(ATTR_NAME_WIDTH,		pBlockObject->GetWidth	());
			pBlockNode->SetDoubleAttribute(ATTR_NAME_HEIGHT,	pBlockObject->GetHeight	());
			pBlockNode->SetDoubleAttribute(ATTR_NAME_START_X,	pBlockObject->GetStartX	());
			pBlockNode->SetDoubleAttribute(ATTR_NAME_START_Y,	pBlockObject->GetStartY	());

			// ----- Insert a Unit (in Block) Data ----- //
			pUnitObject = pBlockObject->FirstUnit();
			if (pUnitObject != NULL)
			{
				do
				{
					pUnitNode = new TiXmlElement(NODE_NAME_UNIT);

					pUnitNode->SetDoubleAttribute(ATTR_NAME_COLUMN,		pUnitObject->GetColumn	());
					pUnitNode->SetDoubleAttribute(ATTR_NAME_ROW,		pUnitObject->GetRow		());
					pUnitNode->SetDoubleAttribute(ATTR_NAME_START_X,	pUnitObject->GetStartX	());
					pUnitNode->SetDoubleAttribute(ATTR_NAME_START_Y,	pUnitObject->GetStartY	());
					pUnitNode->SetDoubleAttribute(ATTR_NAME_CENTER_X,	pUnitObject->GetCenterX	());
					pUnitNode->SetDoubleAttribute(ATTR_NAME_CENTER_Y,	pUnitObject->GetCenterY	());
					pUnitNode->SetDoubleAttribute(ATTR_NAME_WIDTH,		pUnitObject->GetWidth	());
					pUnitNode->SetDoubleAttribute(ATTR_NAME_HEIGHT,		pUnitObject->GetHeight	());

					// ----- Insert a Ball (in Unit) Data ----- //
					pBallObject = pUnitObject->FirstBall();
					if (pBallObject != NULL)
					{
						do
						{
							pBallNode = new TiXmlElement(NODE_NAME_BALL);

							pBallNode->SetDoubleAttribute(ATTR_NAME_DIAMETER,		pBallObject->GetDiameter	());
							pBallNode->SetDoubleAttribute(ATTR_NAME_CENTER_X,		pBallObject->GetCenterX		());
							pBallNode->SetDoubleAttribute(ATTR_NAME_CENTER_Y,		pBallObject->GetCenterY		());
							pBallNode->SetDoubleAttribute(ATTR_NAME_BALL_STATUS,	pBallObject->GetStatus		());

							pUnitNode->LinkEndChild(pBallNode);
						}
						while ((pBallObject = pUnitObject->NextBall()) != NULL);
					}

					pBlockNode->LinkEndChild(pUnitNode);
				}
				while ((pUnitObject = pBlockObject->NextUnit()) != NULL);
			}

			pRoot->LinkEndChild(pBlockNode);
		}
		while ((pBlockObject = NextBlock()) != NULL);
	}

	// ----- Save and Close ----- //
	doc.SaveFile(stream);

	fclose(stream);

	return true;
}