|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tparamcontainer.h"
|
|
Toshihiro Shimizu |
890ddd |
//#include "tdoubleparam.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tparamset.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tparam.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TParamVar::setParamObserver(TParamObserver *obs)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_paramObserver == obs)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
TParam *param = getParam();
|
|
Toshihiro Shimizu |
890ddd |
if (param) {
|
|
Toshihiro Shimizu |
890ddd |
if (obs)
|
|
Toshihiro Shimizu |
890ddd |
param->addObserver(obs);
|
|
Toshihiro Shimizu |
890ddd |
if (m_paramObserver)
|
|
Toshihiro Shimizu |
890ddd |
param->removeObserver(m_paramObserver);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
m_paramObserver = obs;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class TParamContainer::Imp
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
std::map<string, *="" tparamvar=""> m_nameTable;</string,>
|
|
Toshihiro Shimizu |
890ddd |
std::vector<tparamvar *=""> m_vars;</tparamvar>
|
|
Toshihiro Shimizu |
890ddd |
TParamObserver *m_paramObserver;
|
|
Toshihiro Shimizu |
890ddd |
Imp() : m_paramObserver(0) {}
|
|
Toshihiro Shimizu |
890ddd |
~Imp() { clearPointerContainer(m_vars); }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TParamContainer::TParamContainer()
|
|
Toshihiro Shimizu |
890ddd |
: m_imp(new Imp())
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TParamContainer::~TParamContainer()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TParamContainer::setParamObserver(TParamObserver *observer)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_paramObserver = observer;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TParamObserver *TParamContainer::getParamObserver() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_imp->m_paramObserver;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TParamContainer::add(TParamVar *var)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_vars.push_back(var);
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_nameTable[var->getName()] = var;
|
|
Toshihiro Shimizu |
890ddd |
var->setParamObserver(m_imp->m_paramObserver);
|
|
Toshihiro Shimizu |
890ddd |
var->getParam()->setName(var->getName());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int TParamContainer::getParamCount() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_imp->m_vars.size();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TParam *TParamContainer::getParam(int index) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(0 <= index && index < getParamCount());
|
|
Toshihiro Shimizu |
890ddd |
return m_imp->m_vars[index]->getParam();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TParamContainer::isParamHidden(int index) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(0 <= index && index < getParamCount());
|
|
Toshihiro Shimizu |
890ddd |
return m_imp->m_vars[index]->isHidden();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
string TParamContainer::getParamName(int index) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(0 <= index && index < getParamCount());
|
|
Toshihiro Shimizu |
890ddd |
return m_imp->m_vars[index]->getName();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const TParamVar *TParamContainer::getParamVar(int index) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(0 <= index && index < getParamCount());
|
|
Toshihiro Shimizu |
890ddd |
return m_imp->m_vars[index];
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TParam *TParamContainer::getParam(string name) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::map<string, *="" tparamvar="">::const_iterator it;</string,>
|
|
Toshihiro Shimizu |
890ddd |
it = m_imp->m_nameTable.find(name);
|
|
Toshihiro Shimizu |
890ddd |
if (it == m_imp->m_nameTable.end())
|
|
Toshihiro Shimizu |
890ddd |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
return it->second->getParam();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TParamContainer::unlink()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < getParamCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
//TRangeParam *p0;//,*p1;
|
|
Toshihiro Shimizu |
890ddd |
TParamVar *var = m_imp->m_vars[i];
|
|
Toshihiro Shimizu |
890ddd |
TParam *param = var->getParam();
|
|
Toshihiro Shimizu |
890ddd |
//p0 = dynamic_cast<trangeparam *="">(param);</trangeparam>
|
|
Toshihiro Shimizu |
890ddd |
var->setParam(param->clone());
|
|
Toshihiro Shimizu |
890ddd |
/*p1 = dynamic_cast<trangeparam *="">(var->getParam());</trangeparam>
|
|
Toshihiro Shimizu |
890ddd |
if(p0 && p1)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
string name = p0->getName();
|
|
Toshihiro Shimizu |
890ddd |
name = p1->getName();
|
|
Toshihiro Shimizu |
890ddd |
}*/
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TParamContainer::link(const TParamContainer *src)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(getParamCount() == src->getParamCount());
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < getParamCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
assert(getParamName(i) == src->getParamName(i));
|
|
Toshihiro Shimizu |
890ddd |
assert(m_imp->m_vars[i]->getName() == getParamName(i));
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_vars[i]->setParam(src->getParam(i));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TParamContainer::copy(const TParamContainer *src)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(getParamCount() == src->getParamCount());
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < getParamCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
assert(getParamName(i) == src->getParamName(i));
|
|
Toshihiro Shimizu |
890ddd |
assert(m_imp->m_vars[i]->getName() == getParamName(i));
|
|
Toshihiro Shimizu |
890ddd |
getParam(i)->copy(src->getParam(i));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|