/indra/llmath/llcalc.h

https://bitbucket.org/lindenlab/viewer-beta/ · C++ Header · 100 lines · 56 code · 13 blank · 31 comment · 0 complexity · 26e13d63a40d2e4be5a6981577ebb3aa MD5 · raw file

  1. /*
  2. * LLCalc.h
  3. * Copyright 2008 Aimee Walton.
  4. * $LicenseInfo:firstyear=2008&license=viewerlgpl$
  5. * Second Life Viewer Source Code
  6. * Copyright (C) 2008, Linden Research, Inc.
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation;
  11. * version 2.1 of the License only.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. *
  22. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  23. * $/LicenseInfo$
  24. *
  25. */
  26. #ifndef LL_CALC_H
  27. #define LL_CALC_H
  28. #include <map>
  29. #include <string>
  30. class LLCalc
  31. {
  32. public:
  33. LLCalc();
  34. ~LLCalc();
  35. // Variable name constants
  36. static const char* X_POS;
  37. static const char* Y_POS;
  38. static const char* Z_POS;
  39. static const char* X_SCALE;
  40. static const char* Y_SCALE;
  41. static const char* Z_SCALE;
  42. static const char* X_ROT;
  43. static const char* Y_ROT;
  44. static const char* Z_ROT;
  45. static const char* HOLLOW;
  46. static const char* CUT_BEGIN;
  47. static const char* CUT_END;
  48. static const char* PATH_BEGIN;
  49. static const char* PATH_END;
  50. static const char* TWIST_BEGIN;
  51. static const char* TWIST_END;
  52. static const char* X_SHEAR;
  53. static const char* Y_SHEAR;
  54. static const char* X_TAPER;
  55. static const char* Y_TAPER;
  56. static const char* RADIUS_OFFSET;
  57. static const char* REVOLUTIONS;
  58. static const char* SKEW;
  59. static const char* X_HOLE;
  60. static const char* Y_HOLE;
  61. static const char* TEX_U_SCALE;
  62. static const char* TEX_V_SCALE;
  63. static const char* TEX_U_OFFSET;
  64. static const char* TEX_V_OFFSET;
  65. static const char* TEX_ROTATION;
  66. static const char* TEX_TRANSPARENCY;
  67. static const char* TEX_GLOW;
  68. void setVar(const std::string& name, const F32& value);
  69. void clearVar(const std::string& name);
  70. void clearAllVariables();
  71. // void updateVariables(LLSD& vars);
  72. bool evalString(const std::string& expression, F32& result);
  73. std::string::size_type getLastErrorPos() { return mLastErrorPos; }
  74. static LLCalc* getInstance();
  75. static void cleanUp();
  76. typedef std::map<std::string, F32> calc_map_t;
  77. private:
  78. std::string::size_type mLastErrorPos;
  79. calc_map_t mConstants;
  80. calc_map_t mVariables;
  81. // *TODO: Add support for storing user defined variables, and stored functions.
  82. // Will need UI work, and a means to save them between sessions.
  83. // calc_map_t mUserVariables;
  84. // "There shall be only one"
  85. static LLCalc* sInstance;
  86. };
  87. #endif // LL_CALC_H