2019-11-05 14:47:55 +00:00
|
|
|
|
#ifndef __CODEMANAGER_H__
|
|
|
|
|
#define __CODEMANAGER_H__
|
|
|
|
|
|
|
|
|
|
#include "Memento.h"
|
|
|
|
|
#include <vector>
|
2021-10-30 02:45:26 +00:00
|
|
|
|
#include <string>
|
|
|
|
|
#include <stdio.h>
|
2019-11-05 14:47:55 +00:00
|
|
|
|
using namespace std;
|
|
|
|
|
|
2021-10-30 02:45:26 +00:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2019-11-05 14:47:55 +00:00
|
|
|
|
class CodeManager
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
CodeManager(){}
|
2021-10-30 02:45:26 +00:00
|
|
|
|
~CodeManager(){
|
|
|
|
|
for(auto* memento: mementoList){
|
|
|
|
|
if(memento){
|
|
|
|
|
delete memento;
|
|
|
|
|
memento = nullptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CodeManager(const CodeManager&) = delete;
|
|
|
|
|
CodeManager& operator=(const CodeManager&) = delete;
|
2019-11-05 14:47:55 +00:00
|
|
|
|
void commit(Memento* m){
|
2021-10-30 02:45:26 +00:00
|
|
|
|
printf("<EFBFBD>ύ<EFBFBD><EFBFBD><EFBFBD>汾-%d, <20><><EFBFBD><EFBFBD>-%s, <20><>ǩ-%s\n", m->getVersion(), m->getDate().c_str(), m->getLabel().c_str());
|
2019-11-05 14:47:55 +00:00
|
|
|
|
mementoList.push_back(m);
|
|
|
|
|
}
|
2021-10-30 02:45:26 +00:00
|
|
|
|
// <20>л<EFBFBD><D0BB><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>İ汾<C4B0><E6B1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>汾
|
2019-11-05 14:47:55 +00:00
|
|
|
|
Memento* switchToPointedVersion(int index){
|
|
|
|
|
mementoList.erase(mementoList.begin() + mementoList.size() - index, mementoList.end());
|
|
|
|
|
return mementoList[mementoList.size() - 1];
|
|
|
|
|
}
|
2021-10-30 02:45:26 +00:00
|
|
|
|
// <20><>ӡ<EFBFBD><D3A1>ʷ<EFBFBD>汾
|
2019-11-05 14:47:55 +00:00
|
|
|
|
void codeLog(){
|
|
|
|
|
for (int i = 0; i < mementoList.size(); i++){
|
2021-10-30 02:45:26 +00:00
|
|
|
|
printf("[%d]<5D><><EFBFBD>汾-%d, <20><><EFBFBD><EFBFBD>-%s, <20><>ǩ-%s\n", i, mementoList[i]->getVersion(),
|
2019-11-05 14:47:55 +00:00
|
|
|
|
mementoList[i]->getDate().c_str(), mementoList[i]->getLabel().c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private:
|
|
|
|
|
vector<Memento*> mementoList;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|