1 /*!
2 	@file
3 	@author		Albert Semenov
4 	@date		07/2012
5 */
6 
7 #include "ActionDestroyData.h"
8 #include "DataManager.h"
9 
10 namespace tools
11 {
ActionDestroyData()12 	ActionDestroyData::ActionDestroyData() :
13 		mData(nullptr),
14 		mComplete(false)
15 	{
16 	}
17 
~ActionDestroyData()18 	ActionDestroyData::~ActionDestroyData()
19 	{
20 		if (mComplete)
21 		{
22 			delete mData;
23 			mData = nullptr;
24 		}
25 	}
26 
doAction()27 	void ActionDestroyData::doAction()
28 	{
29 		DataManager::getInstance().getRoot()->removeChild(mData);
30 
31 		DataManager::getInstance().invalidateDatas();
32 
33 		mComplete = true;
34 	}
35 
undoAction()36 	void ActionDestroyData::undoAction()
37 	{
38 		DataManager::getInstance().getRoot()->addChild(mData);
39 
40 		DataManager::getInstance().invalidateDatas();
41 
42 		mComplete = false;
43 	}
44 
setData(Data * _data)45 	void ActionDestroyData::setData(Data* _data)
46 	{
47 		mData = _data;
48 	}
49 }
50