PageRenderTime 38ms CodeModel.GetById 29ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 27#ifndef LL_CALC_H
 28#define LL_CALC_H
 29
 30#include <map>
 31#include <string>
 32
 33class LLCalc
 34{
 35public:
 36	LLCalc();
 37	~LLCalc();
 38
 39	// Variable name constants
 40	static const char* X_POS;
 41	static const char* Y_POS;
 42	static const char* Z_POS;
 43	static const char* X_SCALE;
 44	static const char* Y_SCALE;
 45	static const char* Z_SCALE;
 46	static const char* X_ROT;
 47	static const char* Y_ROT;
 48	static const char* Z_ROT;
 49	static const char* HOLLOW;
 50	static const char* CUT_BEGIN;
 51	static const char* CUT_END;
 52	static const char* PATH_BEGIN;
 53	static const char* PATH_END;
 54	static const char* TWIST_BEGIN;
 55	static const char* TWIST_END;
 56	static const char* X_SHEAR;
 57	static const char* Y_SHEAR;
 58	static const char* X_TAPER;
 59	static const char* Y_TAPER;
 60	static const char* RADIUS_OFFSET;
 61	static const char* REVOLUTIONS;
 62	static const char* SKEW;
 63	static const char* X_HOLE;
 64	static const char* Y_HOLE;
 65	static const char* TEX_U_SCALE;
 66	static const char* TEX_V_SCALE;
 67	static const char* TEX_U_OFFSET;
 68	static const char* TEX_V_OFFSET;
 69	static const char* TEX_ROTATION;
 70	static const char* TEX_TRANSPARENCY;
 71	static const char* TEX_GLOW;
 72
 73	void	setVar(const std::string& name, const F32& value);
 74	void	clearVar(const std::string& name);
 75	void	clearAllVariables();
 76//	void	updateVariables(LLSD& vars);
 77
 78	bool	evalString(const std::string& expression, F32& result);
 79	std::string::size_type	getLastErrorPos()	{ return mLastErrorPos; }
 80	
 81	static LLCalc* getInstance();
 82	static void cleanUp();
 83
 84	typedef	std::map<std::string, F32> calc_map_t;
 85	
 86private:
 87	std::string::size_type	mLastErrorPos;
 88	
 89	calc_map_t	mConstants;
 90	calc_map_t	mVariables;
 91	
 92	// *TODO: Add support for storing user defined variables, and stored functions.
 93	//	Will need UI work, and a means to save them between sessions.
 94//	calc_map_t mUserVariables;
 95	
 96	// "There shall be only one"
 97	static LLCalc*	sInstance;
 98};
 99
100#endif // LL_CALC_H