tahoma2d/toonz/sources/tnzext/CompositeStatus.cpp

71 lines
1.6 KiB
C++
Raw Normal View History

2016-03-19 06:57:51 +13:00
#include "ext/CompositeStatus.h"
#include "tgeometry.h"
#include "tvectorimage.h"
#include "ext/Types.h"
#include "ext/StrokeParametricDeformer.h"
#include <vector>
2016-06-15 18:43:10 +12:00
namespace ToonzExt {
2016-03-19 06:57:51 +13:00
//---------------------------------------------------------------------------
/**
*@class CompositeStatus
*@brief This class mantains interal data for Dragger manipulator.
*/
CompositeStatus::CompositeStatus()
2016-06-15 18:43:10 +12:00
: dbImpl_(new std::map<std::string, CompositeStatus *>), db_(*dbImpl_) {}
2016-03-19 06:57:51 +13:00
//---------------------------------------------------------------------------
2016-06-15 18:43:10 +12:00
CompositeStatus::~CompositeStatus() {
iterator it = db_.begin(), end = db_.end();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
while (it != end) {
delete it->second;
++it;
}
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
delete dbImpl_;
2016-03-19 06:57:51 +13:00
}
//---------------------------------------------------------------------------
2016-06-15 18:43:10 +12:00
void CompositeStatus::add(CompositeStatus *status, const std::string &name) {
if (!status) return;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
CompositeStatus *tmp = this->find(name);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
if (tmp) delete tmp;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
db_[name] = status;
2016-03-19 06:57:51 +13:00
}
//---------------------------------------------------------------------------
2016-06-15 18:43:10 +12:00
void CompositeStatus::remove(const std::string &name) {
iterator found = db_.find(name), end = db_.end();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
if (found != end) {
delete found->second;
db_.erase(found);
}
2016-03-19 06:57:51 +13:00
}
//---------------------------------------------------------------------------
2016-06-15 18:43:10 +12:00
CompositeStatus *CompositeStatus::find(const std::string &name) const {
const_iterator found = db_.find(name), end = db_.end();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
if (found != end) return found->second;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
return 0;
2016-03-19 06:57:51 +13:00
}
//---------------------------------------------------------------------------
}