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 {
Shinya Kitaoka 120a6e
  TParamP m_var;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
shun-iwasawa 9d0856
  TParamVarT(std::string name, TParamP var, bool hidden = false,
shun-iwasawa 9d0856
             bool obsolete = false)
shun-iwasawa 9d0856
      : TParamVar(name, hidden, obsolete), m_var(var) {}
shun-iwasawa 9d0856
  TParamVarT(std::string name, T *var, bool hidden = false,
shun-iwasawa 9d0856
             bool obsolete = false)
shun-iwasawa 9d0856
      : TParamVar(name, hidden, obsolete), m_var(var) {}
Shinya Kitaoka 473e70
  void setParam(TParam *param) override { m_var = TParamP(param); }
Shinya Kitaoka 473e70
Shinya Kitaoka 473e70
  TParam *getParam() const override { return m_var.getPointer(); }
Shinya Kitaoka 473e70
  TParamVar *clone() const override {
shun-iwasawa 9d0856
    return new TParamVarT<t>(getName(), m_var, isHidden(), isObsolete());</t>
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