Shinya Kitaoka 810553
#pragma once
Shinya Kitaoka 810553
Toshihiro Shimizu 890ddd
#ifndef TPARAMCONTAINER_INCLUDED
Toshihiro Shimizu 890ddd
#define TPARAMCONTAINER_INCLUDED
Toshihiro Shimizu 890ddd
Shinya Kitaoka 262a92
#include <memory></memory>
Shinya Kitaoka 262a92
Toshihiro Shimizu 890ddd
#include "tparam.h"
Toshihiro Shimizu 890ddd
//#include "tfx.h"
Toshihiro Shimizu 890ddd
#include "tcommon.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TPARAM_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class TIStream;
Toshihiro Shimizu 890ddd
class TOStream;
Toshihiro Shimizu 890ddd
class TParamObserver;
Toshihiro Shimizu 890ddd
class TParam;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI TParamVar {
Shinya Kitaoka 120a6e
  std::string m_name;
Shinya Kitaoka 120a6e
  bool m_isHidden;
shun-iwasawa 9d0856
  // Flag for an obsolete parameter used for maintaining backward-compatiblity.
shun-iwasawa 9d0856
  // - The obsolete parameter will call a special function
shun-iwasawa 9d0856
  // (TFx::onObsoleteParameterLoaded) on loaded which enables to do some special
shun-iwasawa 9d0856
  // action. (e.g. converting to a new parameter etc.)
shun-iwasawa 9d0856
  // - The obsolete parameter will not be saved.
shun-iwasawa 9d0856
  bool m_isObsolete;
Shinya Kitaoka 120a6e
  TParamObserver *m_paramObserver;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
shun-iwasawa 9d0856
  TParamVar(std::string name, bool hidden = false, bool obsolete = false)
shun-iwasawa 9d0856
      : m_name(name)
shun-iwasawa 9d0856
      , m_isHidden(hidden)
shun-iwasawa 9d0856
      , m_isObsolete(obsolete)
shun-iwasawa 9d0856
      , m_paramObserver(0) {}
Shinya Kitaoka 120a6e
  virtual ~TParamVar() {}
Shinya Kitaoka 120a6e
  virtual TParamVar *clone() const = 0;
Shinya Kitaoka 120a6e
  std::string getName() const { return m_name; }
Shinya Kitaoka 120a6e
  bool isHidden() const { return m_isHidden; }
Shinya Kitaoka 120a6e
  void setIsHidden(bool hidden) { m_isHidden = hidden; }
shun-iwasawa 9d0856
  bool isObsolete() const { return m_isObsolete; }
shun-iwasawa 9d0856
  virtual void setParam(TParam *param) = 0;
shun-iwasawa 9d0856
  virtual TParam *getParam() const     = 0;
Shinya Kitaoka 120a6e
  void setParamObserver(TParamObserver *obs);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <class t=""></class>
Shinya Kitaoka d1f6c4
class TParamVarT final : public TParamVar {
shun-iwasawa 3f8e9a
  // Very dirty fix for link fx, separating the variable between the plugin fx
shun-iwasawa 3f8e9a
  // and the built-in fx.
shun-iwasawa 3f8e9a
  // Note that for now link fx is available only with built-in fx, since m_var
shun-iwasawa 3f8e9a
  // must be "pointer to pointer" of parameter to make the link fx to work
shun-iwasawa 3f8e9a
  // properly.
shun-iwasawa 3f8e9a
  T *m_var            = nullptr;
shun-iwasawa 3f8e9a
  TParamP m_pluginVar = 0;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
shun-iwasawa 3f8e9a
  TParamVarT(std::string name, T *var = nullptr, TParamP pluginVar = 0,
shun-iwasawa 3f8e9a
             bool hidden = false, bool obsolete = false)
shun-iwasawa 77d81f
      : TParamVar(name, hidden, obsolete), m_var(var), m_pluginVar(pluginVar) {}
shun-iwasawa 3f8e9a
  TParamVarT() = delete;
shun-iwasawa 3f8e9a
  void setParam(TParam *param) {
shun-iwasawa 3f8e9a
    if (m_var)
shun-iwasawa 3f8e9a
      *m_var = TParamP(param);
shun-iwasawa 3f8e9a
    else
shun-iwasawa 3f8e9a
      m_pluginVar = TParamP(param);
shun-iwasawa 3f8e9a
  }
shun-iwasawa 3f8e9a
  virtual TParam *getParam() const {
shun-iwasawa 3f8e9a
    if (m_var)
shun-iwasawa 3f8e9a
      return m_var->getPointer();
shun-iwasawa 3f8e9a
    else
shun-iwasawa 3f8e9a
      return m_pluginVar.getPointer();
shun-iwasawa 3f8e9a
  }
shun-iwasawa 3f8e9a
  TParamVar *clone() const {
shun-iwasawa 77d81f
    return new TParamVarT<t>(getName(), m_var, m_pluginVar, isHidden(),</t>
shun-iwasawa 77d81f
                             isObsolete());
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI TParamContainer {
Shinya Kitaoka 120a6e
  class Imp;
Shinya Kitaoka 120a6e
  std::unique_ptr<imp> m_imp;</imp>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TParamContainer();
Shinya Kitaoka 120a6e
  ~TParamContainer();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void add(TParamVar *var);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int getParamCount() const;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool isParamHidden(int index) const;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TParam *getParam(int index) const;
Shinya Kitaoka 120a6e
  std::string getParamName(int index) const;
Shinya Kitaoka 120a6e
  TParam *getParam(std::string name) const;
shun-iwasawa 9d0856
  TParamVar *getParamVar(std::string name) const;
Shinya Kitaoka 120a6e
  const TParamVar *getParamVar(int index) const;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void unlink();
Shinya Kitaoka 120a6e
  void link(const TParamContainer *src);
Shinya Kitaoka 120a6e
  void copy(const TParamContainer *src);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setParamObserver(TParamObserver *);
Shinya Kitaoka 120a6e
  TParamObserver *getParamObserver() const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  TParamContainer(const TParamContainer &);
Shinya Kitaoka 120a6e
  TParamContainer &operator=(const TParamContainer &);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif