Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef TENV_INCLUDED
Toshihiro Shimizu 890ddd
#define TENV_INCLUDED
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//#include "texception.h"
Toshihiro Shimizu 890ddd
#include "tgeometry.h"
Toshihiro Shimizu 890ddd
#include "tfilepath.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//===================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TNZCORE_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
//=========================================================
Shinya Kitaoka 120a6e
namespace TEnv {
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI Variable {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  class Imp;
Shinya Kitaoka 120a6e
  Imp *m_imp;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  Variable(std::string name, std::string defaultValue);
Shinya Kitaoka 120a6e
  Variable(std::string name);
Shinya Kitaoka 120a6e
  virtual ~Variable();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  std::string getName() const;
Shinya Kitaoka 120a6e
  std::string getValue() const;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void assignValue(std::string str);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DVAPI IntVar final : public Variable {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  IntVar(std::string name, int defValue);
Shinya Kitaoka 120a6e
  IntVar(std::string name);
Shinya Kitaoka 120a6e
  operator int() const;
Shinya Kitaoka 120a6e
  void operator=(int v);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DVAPI DoubleVar final : public Variable {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  DoubleVar(std::string name, double defValue);
Shinya Kitaoka 120a6e
  DoubleVar(std::string name);
Shinya Kitaoka 120a6e
  operator double() const;
Shinya Kitaoka 120a6e
  void operator=(double v);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DVAPI StringVar final : public Variable {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  StringVar(std::string name, const std::string &defValue);
Shinya Kitaoka 120a6e
  StringVar(std::string name);
Shinya Kitaoka 120a6e
  operator std::string() const;
Shinya Kitaoka 120a6e
  void operator=(const std::string &v);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DVAPI FilePathVar final : public Variable {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  FilePathVar(std::string name, const TFilePath &defValue);
Shinya Kitaoka 120a6e
  FilePathVar(std::string name);
Shinya Kitaoka 120a6e
  operator TFilePath() const;
Shinya Kitaoka 120a6e
  void operator=(const TFilePath &v);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DVAPI RectVar final : public Variable {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  RectVar(std::string name, const TRect &defValue);
Shinya Kitaoka 120a6e
  RectVar(std::string name);
Shinya Kitaoka 120a6e
  operator TRect() const;
Shinya Kitaoka 120a6e
  void operator=(const TRect &v);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// NOTA BENE: bisogna chiamare setApplication() il prima possibile
Shinya Kitaoka 120a6e
// questa operazione inizializza il registry root (su Windows) e definisce il
Shinya Kitaoka 120a6e
// file dove
Toshihiro Shimizu 890ddd
// vengono lette e scritte le variabili di environment
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// es.:  TEnv::setApplication("Toonz","5.0");
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
Shinya Kitaoka 3bfa54
DVAPI std::string getApplicationName();
Shinya Kitaoka 3bfa54
DVAPI std::string getApplicationVersion();
Toshihiro Shimizu 890ddd
manongjohn fba662
// This are for the case where the file name of application changes and doesn't
manongjohn fba662
// match actual application name and we want to keep both. We will need that for
manongjohn fba662
// some stuff
manongjohn fba662
DVAPI void setApplicationFileName(std::string appFileName);
manongjohn fba662
DVAPI std::string getApplicationFileName();
manongjohn fba662
Jeremy Bullock 46512f
DVAPI bool getIsPortable();
Jeremy Bullock 46512f
Toshihiro Shimizu 890ddd
// es.: TEnv::setModuleFullName("Toonz 5.0.1 Harlequin");
Toshihiro Shimizu 890ddd
// (default: "<applicationname> <applicationversion>")</applicationversion></applicationname>
Shinya Kitaoka 3bfa54
DVAPI void setApplicationFullName(std::string applicationFullName);
Shinya Kitaoka 3bfa54
DVAPI std::string getApplicationFullName();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// es.: TEnv::setModuleName("inknpaint")
Toshihiro Shimizu 890ddd
// (default: "<applicationname>")</applicationname>
Shinya Kitaoka 3bfa54
DVAPI void setModuleName(std::string moduleName);
Shinya Kitaoka 3bfa54
DVAPI std::string getModuleName();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// es.: TEnv::setRootVarName("TABROOT");
Toshihiro Shimizu 890ddd
// (default: toUpper(<applicationname> + "ROOT"))</applicationname>
Shinya Kitaoka 3bfa54
DVAPI std::string getRootVarName();
Shinya Kitaoka 3bfa54
DVAPI void setRootVarName(std::string varName);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// es.: TEnv::setRootVarName("Toonz");
Toshihiro Shimizu 890ddd
// (default: <programname>)</programname>
Shinya Kitaoka 3bfa54
DVAPI void setSystemVarPrefix(std::string prefix);
Shinya Kitaoka 3bfa54
DVAPI std::string getSystemVarPrefix();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// su Windows ritorna
Toshihiro Shimizu 890ddd
//   'SOFTWARE\Digital Video\<applicationname>\<applicationversion>\<rootvar>'</rootvar></applicationversion></applicationname>
Toshihiro Shimizu 890ddd
// su Unix/Linux/MacOsX
Toshihiro Shimizu 890ddd
//   '<rootvar>'</rootvar>
Toshihiro Shimizu 890ddd
DVAPI TFilePath getRootVarPath();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// restituisce il valore della variabile di sistema varName
Toshihiro Shimizu 890ddd
// (su window aggiunge "SOFTWARE\Digital Video\....." all'inizio)
Shinya Kitaoka 3bfa54
DVAPI std::string getSystemVarStringValue(std::string varName);
Shinya Kitaoka 3bfa54
DVAPI TFilePath getSystemVarPathValue(std::string varName);
Shinya Kitaoka 3bfa54
DVAPI TFilePathSet getSystemVarPathSetValue(std::string varName);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
DVAPI TFilePath getStuffDir();
Toshihiro Shimizu 890ddd
DVAPI TFilePath getConfigDir();
Shinya Kitaoka 120a6e
// DVAPI TFilePath getProfilesDir();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// per l'utilizzo di ToonzLib senza che sia definita una TOONZROOT
Toshihiro Shimizu 890ddd
// bisogna chiamare TEnv::setStuffDir(stuffdir) prima di ogni altra operazione
Toshihiro Shimizu 890ddd
DVAPI void setStuffDir(const TFilePath &stuffDir);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
DVAPI void saveAllEnvVariables();
Toshihiro Shimizu 890ddd
shun-iwasawa e3b189
// register command line argument paths.
shun-iwasawa e3b189
// returns true on success
shun-iwasawa e3b189
DVAPI bool setArgPathValue(std::string key, std::string value);
shun-iwasawa e3b189
shun-iwasawa e3b189
DVAPI const std::map<std::string, std::string=""> &getSystemPathMap();</std::string,>
shun-iwasawa e3b189
Toshihiro Shimizu 890ddd
/*
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
  enum SystemFileId {
Toshihiro Shimizu 890ddd
    StuffDir,
Toshihiro Shimizu 890ddd
    ConfigDir,
Toshihiro Shimizu 890ddd
    ProfilesDir
Toshihiro Shimizu 890ddd
  };
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // bisogna assegnare (in qualsiasi ordine) tutti i vari nomi dei registry alle
Shinya Kitaoka 120a6e
  varie
Shinya Kitaoka 120a6e
  // directory di sistema.
Shinya Kitaoka 120a6e
  // StuffDir e' obbligatoria, tutte le altre hanno un valore di default
Shinya Kitaoka 120a6e
  relativo a StuffDir
Toshihiro Shimizu 890ddd
  DVAPI void defineSystemPath(SystemFileId id, const TFilePath ®istryName);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
  // restituisce il file (non la variabile di registro)
Toshihiro Shimizu 890ddd
  DVAPI TFilePath getSystemPath(SystemFileId id);
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=========================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=========================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
}  // namespace TEnv
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=========================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif