Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tdoubleparamrelayproperty.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//*****************************************************************************
Toshihiro Shimizu 890ddd
//    TDoubleParamRelayProperty  implementation
Toshihiro Shimizu 890ddd
//*****************************************************************************
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TDoubleParamRelayProperty::TDoubleParamRelayProperty(const std::string &name,
Shinya Kitaoka 120a6e
                                                     TDoubleParamP param)
Shinya Kitaoka 120a6e
    : TProperty(name), m_frame() {
Shinya Kitaoka 120a6e
  if (param) setParam(param);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TDoubleParamRelayProperty::~TDoubleParamRelayProperty() {
Shinya Kitaoka 120a6e
  if (m_param) m_param->removeObserver(this);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TDoubleParamRelayProperty::TDoubleParamRelayProperty(
Shinya Kitaoka 120a6e
    const TDoubleParamRelayProperty &other)
Shinya Kitaoka 120a6e
    : TProperty(other), m_param(other.m_param), m_frame(other.m_frame) {
Shinya Kitaoka 120a6e
  if (m_param) m_param->addObserver(this);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TDoubleParamRelayProperty &TDoubleParamRelayProperty::operator=(
Shinya Kitaoka 120a6e
    const TDoubleParamRelayProperty &other) {
Shinya Kitaoka 120a6e
  TProperty::operator=(other);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (m_param) m_param->removeObserver(this);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_param = other.m_param;
Shinya Kitaoka 120a6e
  m_frame = other.m_frame;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (m_param) m_param->addObserver(this);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  return *this;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TProperty *TDoubleParamRelayProperty::clone() const {
Shinya Kitaoka 120a6e
  return new TDoubleParamRelayProperty(*this);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
std::string TDoubleParamRelayProperty::getValueAsString() {
Shinya Kitaoka 120a6e
  return m_param ? std::to_string(m_param->getValue(m_frame)) : "";
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TDoubleParamRelayProperty::setParam(const TDoubleParamP ¶m) {
Shinya Kitaoka 120a6e
  if (m_param == param) return;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (m_param) m_param->removeObserver(this);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_param = param;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (param) param->addObserver(this);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TDoubleParamRelayProperty::setValue(double v) {
Shinya Kitaoka 120a6e
  if (m_param) m_param->setValue(m_frame, v);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
double TDoubleParamRelayProperty::getValue() const {
Shinya Kitaoka 120a6e
  return m_param ? m_param->getValue(m_frame) : 0.0;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TDoubleParamRelayProperty::accept(TProperty::Visitor &v) {
Shinya Kitaoka 120a6e
  if (TDoubleParamRelayProperty::Visitor *vv =
Shinya Kitaoka 120a6e
          dynamic_cast<tdoubleparamrelayproperty::visitor *="">(&v))</tdoubleparamrelayproperty::visitor>
Shinya Kitaoka 120a6e
    vv->visit(this);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TDoubleParamRelayProperty::onChange(const TParamChange &) {
Shinya Kitaoka 120a6e
  notifyListeners();
Toshihiro Shimizu 890ddd
}