MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
MathParser::StaticNameSpace Class Reference

#include <mathp.h>

Inheritance diagram for MathParser::StaticNameSpace:
Collaboration diagram for MathParser::StaticNameSpace:

Public Member Functions

 StaticNameSpace (Table *pTable=0)
 
 ~StaticNameSpace (void)
 
bool IsFunc (const std::string &fname) const
 
MathParser::MathFunc_tGetFunc (const std::string &fname) const
 
virtual TypedValue EvalFunc (MathParser::MathFunc_t *f) const
 
virtual TableGetTable (void)
 
- Public Member Functions inherited from MathParser::NameSpace
 NameSpace (const std::string &name)
 
virtual ~NameSpace (void)
 
virtual const std::string & sGetName (void) const
 

Private Types

typedef std::map< std::string,
MathParser::MathFunc_t * > 
funcType
 

Private Attributes

funcType func
 
Tablem_pTable
 

Detailed Description

Definition at line 205 of file mathp.h.

Member Typedef Documentation

typedef std::map<std::string, MathParser::MathFunc_t *> MathParser::StaticNameSpace::funcType
private

Definition at line 207 of file mathp.h.

Constructor & Destructor Documentation

MathParser::StaticNameSpace::StaticNameSpace ( Table pTable = 0)

Definition at line 2008 of file mathp.cc.

References MathParser::MathFunc_t::args, MathParser::MathFunc_t::errmsg, MathParser::MathFunc_t::f, MathParser::MathFunc_t::fname, func, TypedValue::GetTypeName(), MBDYN_EXCEPT_ARGS, mp_acos_t(), mp_acosh_t(), mp_actg(), mp_actg2(), mp_asin_t(), mp_atanh_t(), mp_cast(), mp_ctg(), mp_ctg_t(), mp_ctgh(), mp_ctgh_t(), mp_greater_than_0_t(), mp_greater_than_or_equal_to_0_t(), mp_max(), mp_min(), mp_par(), mp_print(), mp_ramp(), mp_rand(), mp_rndm(), mp_sign(), mp_sprintf(), mp_sramp(), mp_srnd(), mp_step(), mp_stop(), mp_tan_t(), MathParser::MathFunc_t::ns, MathParser::MathFunc_t::t, TypedValue::VAR_BOOL, TypedValue::VAR_INT, TypedValue::VAR_REAL, TypedValue::VAR_STRING, and TypedValue::VAR_UNKNOWN.

2009 : MathParser::NameSpace("default"), m_pTable(pTable)
2010 {
2011  // make sure there's only one StaticNameSpace
2012  if (sns) {
2013  // error
2015  }
2016  sns = true;
2017 
2018  MathFunc_t *f;
2019 
2020  // asin
2021  f = new MathFunc_t;
2022  f->fname = std::string("asin");
2023  f->ns = this;
2024  f->args.resize(1 + 1);
2025  f->args[0] = new MathArgReal_t;
2026  f->args[1] = new MathArgReal_t;
2027  f->f = mp_func_1<MathParser::MathArgReal_t, MathParser::MathArgReal_t, asin>;
2028  f->t = mp_asin_t;
2029  f->errmsg = std::string("invalid arg to asin()");
2030 
2031  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2032  silent_cerr("static namespace: "
2033  "unable to insert handler "
2034  "for function " << f->fname << std::endl);
2036  }
2037 
2038  // acos
2039  f = new MathFunc_t;
2040  f->fname = std::string("acos");
2041  f->ns = this;
2042  f->args.resize(1 + 1);
2043  f->args[0] = new MathArgReal_t;
2044  f->args[1] = new MathArgReal_t;
2045  f->f = mp_func_1<MathParser::MathArgReal_t, MathParser::MathArgReal_t, acos>;
2046  f->t = mp_acos_t;
2047  f->errmsg = std::string("invalid arg to acos()");
2048 
2049  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2050  silent_cerr("static namespace: "
2051  "unable to insert handler "
2052  "for function " << f->fname << std::endl);
2054  }
2055 
2056  // atan
2057  f = new MathFunc_t;
2058  f->fname = std::string("atan");
2059  f->ns = this;
2060  f->args.resize(1 + 1);
2061  f->args[0] = new MathArgReal_t;
2062  f->args[1] = new MathArgReal_t;
2063  f->f = mp_func_1<MathParser::MathArgReal_t, MathParser::MathArgReal_t, atan>;
2064  f->t = 0;
2065 
2066  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2067  silent_cerr("static namespace: "
2068  "unable to insert handler "
2069  "for function " << f->fname << std::endl);
2071  }
2072 
2073  // actan
2074  f = new MathFunc_t;
2075  f->fname = std::string("actan");
2076  f->ns = this;
2077  f->args.resize(1 + 1);
2078  f->args[0] = new MathArgReal_t;
2079  f->args[1] = new MathArgReal_t;
2080  f->f = mp_actg;
2081  f->t = 0;
2082 
2083  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2084  silent_cerr("static namespace: "
2085  "unable to insert handler "
2086  "for function " << f->fname << std::endl);
2088  }
2089 
2090  // atan2
2091  f = new MathFunc_t;
2092  f->fname = std::string("atan2");
2093  f->ns = this;
2094  f->args.resize(1 + 2);
2095  f->args[0] = new MathArgReal_t;
2096  f->args[1] = new MathArgReal_t;
2097  f->args[2] = new MathArgReal_t;
2098  f->f = mp_func_2<MathParser::MathArgReal_t, MathParser::MathArgReal_t, atan2>;
2099  f->t = 0;
2100 
2101  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2102  silent_cerr("static namespace: "
2103  "unable to insert handler "
2104  "for function " << f->fname << std::endl);
2106  }
2107 
2108  // actan2
2109  f = new MathFunc_t;
2110  f->fname = std::string("actan2");
2111  f->ns = this;
2112  f->args.resize(1 + 2);
2113  f->args[0] = new MathArgReal_t;
2114  f->args[1] = new MathArgReal_t;
2115  f->args[2] = new MathArgReal_t;
2116  f->f = mp_actg2;
2117  f->t = 0;
2118 
2119  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2120  silent_cerr("static namespace: "
2121  "unable to insert handler "
2122  "for function " << f->fname << std::endl);
2124  }
2125 
2126  // cos
2127  f = new MathFunc_t;
2128  f->fname = std::string("cos");
2129  f->ns = this;
2130  f->args.resize(1 + 1);
2131  f->args[0] = new MathArgReal_t;
2132  f->args[1] = new MathArgReal_t;
2133  f->f = mp_func_1<MathParser::MathArgReal_t, MathParser::MathArgReal_t, cos>;
2134  f->t = 0;
2135 
2136  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2137  silent_cerr("static namespace: "
2138  "unable to insert handler "
2139  "for function " << f->fname << std::endl);
2141  }
2142 
2143  // sin
2144  f = new MathFunc_t;
2145  f->fname = std::string("sin");
2146  f->ns = this;
2147  f->args.resize(1 + 1);
2148  f->args[0] = new MathArgReal_t;
2149  f->args[1] = new MathArgReal_t;
2150  f->f = mp_func_1<MathParser::MathArgReal_t, MathParser::MathArgReal_t, sin>;
2151  f->t = 0;
2152 
2153  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2154  silent_cerr("static namespace: "
2155  "unable to insert handler "
2156  "for function " << f->fname << std::endl);
2158  }
2159 
2160  // tan
2161  f = new MathFunc_t;
2162  f->fname = std::string("tan");
2163  f->ns = this;
2164  f->args.resize(1 + 1);
2165  f->args[0] = new MathArgReal_t;
2166  f->args[1] = new MathArgReal_t;
2167  f->f = mp_func_1<MathParser::MathArgReal_t, MathParser::MathArgReal_t, tan>;
2168  f->t = mp_tan_t;
2169 
2170  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2171  silent_cerr("static namespace: "
2172  "unable to insert handler "
2173  "for function " << f->fname << std::endl);
2175  }
2176 
2177  // ctan
2178  f = new MathFunc_t;
2179  f->fname = std::string("ctan");
2180  f->ns = this;
2181  f->args.resize(1 + 1);
2182  f->args[0] = new MathArgReal_t;
2183  f->args[1] = new MathArgReal_t;
2184  f->f = mp_ctg;
2185  f->t = mp_ctg_t;
2186 
2187  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2188  silent_cerr("static namespace: "
2189  "unable to insert handler "
2190  "for function " << f->fname << std::endl);
2192  }
2193 
2194  // cosh
2195  f = new MathFunc_t;
2196  f->fname = std::string("cosh");
2197  f->ns = this;
2198  f->args.resize(1 + 1);
2199  f->args[0] = new MathArgReal_t;
2200  f->args[1] = new MathArgReal_t;
2201  f->f = mp_func_1<MathParser::MathArgReal_t, MathParser::MathArgReal_t, cosh>;
2202  f->t = 0;
2203 
2204  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2205  silent_cerr("static namespace: "
2206  "unable to insert handler "
2207  "for function " << f->fname << std::endl);
2209  }
2210 
2211  // sinh
2212  f = new MathFunc_t;
2213  f->fname = std::string("sinh");
2214  f->ns = this;
2215  f->args.resize(1 + 1);
2216  f->args[0] = new MathArgReal_t;
2217  f->args[1] = new MathArgReal_t;
2218  f->f = mp_func_1<MathParser::MathArgReal_t, MathParser::MathArgReal_t, sinh>;
2219  f->t = 0;
2220 
2221  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2222  silent_cerr("static namespace: "
2223  "unable to insert handler "
2224  "for function " << f->fname << std::endl);
2226  }
2227 
2228  // tanh
2229  f = new MathFunc_t;
2230  f->fname = std::string("tanh");
2231  f->ns = this;
2232  f->args.resize(1 + 1);
2233  f->args[0] = new MathArgReal_t;
2234  f->args[1] = new MathArgReal_t;
2235  f->f = mp_func_1<MathParser::MathArgReal_t, MathParser::MathArgReal_t, tanh>;
2236  f->t = 0;
2237 
2238  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2239  silent_cerr("static namespace: "
2240  "unable to insert handler "
2241  "for function " << f->fname << std::endl);
2243  }
2244 
2245  // ctanh
2246  f = new MathFunc_t;
2247  f->fname = std::string("ctanh");
2248  f->ns = this;
2249  f->args.resize(1 + 1);
2250  f->args[0] = new MathArgReal_t;
2251  f->args[1] = new MathArgReal_t;
2252  f->f = mp_ctgh;
2253  f->t = mp_ctgh_t;
2254 
2255  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2256  silent_cerr("static namespace: "
2257  "unable to insert handler "
2258  "for function " << f->fname << std::endl);
2260  }
2261 
2262 #ifdef __USE_XOPEN
2263  // acosh
2264  f = new MathFunc_t;
2265  f->fname = std::string("acosh");
2266  f->ns = this;
2267  f->args.resize(1 + 1);
2268  f->args[0] = new MathArgReal_t;
2269  f->args[1] = new MathArgReal_t;
2270  f->f = mp_func_1<MathParser::MathArgReal_t, MathParser::MathArgReal_t, acosh>;
2271  f->t = mp_acosh_t;
2272 
2273  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2274  silent_cerr("static namespace: "
2275  "unable to insert handler "
2276  "for function " << f->fname << std::endl);
2278  }
2279 
2280  // asinh
2281  f = new MathFunc_t;
2282  f->fname = std::string("asinh");
2283  f->ns = this;
2284  f->args.resize(1 + 1);
2285  f->args[0] = new MathArgReal_t;
2286  f->args[1] = new MathArgReal_t;
2287  f->f = mp_func_1<MathParser::MathArgReal_t, MathParser::MathArgReal_t, asinh>;
2288  f->t = 0;
2289 
2290  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2291  silent_cerr("static namespace: "
2292  "unable to insert handler "
2293  "for function " << f->fname << std::endl);
2295  }
2296 
2297  // atanh
2298  f = new MathFunc_t;
2299  f->fname = std::string("atanh");
2300  f->ns = this;
2301  f->args.resize(1 + 1);
2302  f->args[0] = new MathArgReal_t;
2303  f->args[1] = new MathArgReal_t;
2304  f->f = mp_func_1<MathParser::MathArgReal_t, MathParser::MathArgReal_t, atanh>;
2305  f->t = mp_atanh_t;
2306 
2307  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2308  silent_cerr("static namespace: "
2309  "unable to insert handler "
2310  "for function " << f->fname << std::endl);
2312  }
2313 
2314  // actanh
2315  f = new MathFunc_t;
2316  f->fname = std::string("actanh");
2317  f->ns = this;
2318  f->args.resize(1 + 1);
2319  f->args[0] = new MathArgReal_t;
2320  f->args[1] = new MathArgReal_t;
2321  f->f = mp_actgh;
2322  f->t = 0;
2323 
2324  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2325  silent_cerr("static namespace: "
2326  "unable to insert handler "
2327  "for function " << f->fname << std::endl);
2329  }
2330 #endif /* __USE_XOPEN */
2331 
2332  // exp
2333  f = new MathFunc_t;
2334  f->fname = std::string("exp");
2335  f->ns = this;
2336  f->args.resize(1 + 1);
2337  f->args[0] = new MathArgReal_t;
2338  f->args[1] = new MathArgReal_t;
2339  f->f = mp_func_1<MathParser::MathArgReal_t, MathParser::MathArgReal_t, exp>;
2340  f->t = 0;
2341 
2342  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2343  silent_cerr("static namespace: "
2344  "unable to insert handler "
2345  "for function " << f->fname << std::endl);
2347  }
2348 
2349  // log
2350  f = new MathFunc_t;
2351  f->fname = std::string("log");
2352  f->ns = this;
2353  f->args.resize(1 + 1);
2354  f->args[0] = new MathArgReal_t;
2355  f->args[1] = new MathArgReal_t;
2356  f->f = mp_func_1<MathParser::MathArgReal_t, MathParser::MathArgReal_t, log>;
2357  f->t = mp_greater_than_0_t;
2358 
2359  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2360  silent_cerr("static namespace: "
2361  "unable to insert handler "
2362  "for function " << f->fname << std::endl);
2364  }
2365 
2366  // log10
2367  f = new MathFunc_t;
2368  f->fname = std::string("log10");
2369  f->ns = this;
2370  f->args.resize(1 + 1);
2371  f->args[0] = new MathArgReal_t;
2372  f->args[1] = new MathArgReal_t;
2373  f->f = mp_func_1<MathParser::MathArgReal_t, MathParser::MathArgReal_t, log10>;
2374  f->t = mp_greater_than_0_t;
2375 
2376  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2377  silent_cerr("static namespace: "
2378  "unable to insert handler "
2379  "for function " << f->fname << std::endl);
2381  }
2382 
2383  // sqrt
2384  f = new MathFunc_t;
2385  f->fname = std::string("sqrt");
2386  f->ns = this;
2387  f->args.resize(1 + 1);
2388  f->args[0] = new MathArgReal_t;
2389  f->args[1] = new MathArgReal_t;
2390  f->f = mp_func_1<MathParser::MathArgReal_t, MathParser::MathArgReal_t, sqrt>;
2392 
2393  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2394  silent_cerr("static namespace: "
2395  "unable to insert handler "
2396  "for function " << f->fname << std::endl);
2398  }
2399 
2400  // abs
2401  f = new MathFunc_t;
2402  f->fname = std::string("abs");
2403  f->ns = this;
2404  f->args.resize(1 + 1);
2405  f->args[0] = new MathArgReal_t;
2406  f->args[1] = new MathArgReal_t;
2407  f->f = mp_func_1<MathParser::MathArgReal_t, MathParser::MathArgReal_t, fabs>;
2408  f->t = 0;
2409 
2410  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2411  silent_cerr("static namespace: "
2412  "unable to insert handler "
2413  "for function " << f->fname << std::endl);
2415  }
2416 
2417  // sign
2418  f = new MathFunc_t;
2419  f->fname = std::string("sign");
2420  f->ns = this;
2421  f->args.resize(1 + 1);
2422  f->args[0] = new MathArgInt_t;
2423  f->args[1] = new MathArgReal_t;
2424  f->f = mp_sign;
2425  f->t = 0;
2426 
2427  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2428  silent_cerr("static namespace: "
2429  "unable to insert handler "
2430  "for function " << f->fname << std::endl);
2432  }
2433 
2434  // copysign
2435  f = new MathFunc_t;
2436  f->fname = std::string("copysign");
2437  f->ns = this;
2438  f->args.resize(1 + 2);
2439  f->args[0] = new MathArgReal_t;
2440  f->args[1] = new MathArgReal_t;
2441  f->args[2] = new MathArgReal_t;
2442  f->f = mp_func_2<MathParser::MathArgReal_t, MathParser::MathArgReal_t, copysign>;
2443  f->t = 0;
2444 
2445  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2446  silent_cerr("static namespace: "
2447  "unable to insert handler "
2448  "for function " << f->fname << std::endl);
2450  }
2451 
2452  // max
2453  f = new MathFunc_t;
2454  f->fname = std::string("max");
2455  f->ns = this;
2456  f->args.resize(1 + 2);
2457  f->args[0] = new MathArgReal_t;
2458  f->args[1] = new MathArgReal_t;
2459  f->args[2] = new MathArgReal_t;
2460  f->f = mp_max;
2461  f->t = 0;
2462 
2463  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2464  silent_cerr("static namespace: "
2465  "unable to insert handler "
2466  "for function " << f->fname << std::endl);
2468  }
2469 
2470  // min
2471  f = new MathFunc_t;
2472  f->fname = std::string("min");
2473  f->ns = this;
2474  f->args.resize(1 + 2);
2475  f->args[0] = new MathArgReal_t;
2476  f->args[1] = new MathArgReal_t;
2477  f->args[2] = new MathArgReal_t;
2478  f->f = mp_min;
2479  f->t = 0;
2480 
2481  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2482  silent_cerr("static namespace: "
2483  "unable to insert handler "
2484  "for function " << f->fname << std::endl);
2486  }
2487 
2488  // floor
2489  f = new MathFunc_t;
2490  f->fname = std::string("floor");
2491  f->ns = this;
2492  f->args.resize(1 + 1);
2493  f->args[0] = new MathArgReal_t;
2494  f->args[1] = new MathArgReal_t;
2495  f->f = mp_func_1<MathParser::MathArgReal_t, MathParser::MathArgReal_t, floor>;
2496  f->t = 0;
2497 
2498  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2499  silent_cerr("static namespace: "
2500  "unable to insert handler "
2501  "for function " << f->fname << std::endl);
2503  }
2504 
2505  // ceil
2506  f = new MathFunc_t;
2507  f->fname = std::string("ceil");
2508  f->ns = this;
2509  f->args.resize(1 + 1);
2510  f->args[0] = new MathArgReal_t;
2511  f->args[1] = new MathArgReal_t;
2512  f->f = mp_func_1<MathParser::MathArgReal_t, MathParser::MathArgReal_t, ceil>;
2513  f->t = 0;
2514 
2515  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2516  silent_cerr("static namespace: "
2517  "unable to insert handler "
2518  "for function " << f->fname << std::endl);
2520  }
2521 
2522 #ifdef __USE_XOPEN
2523  // round
2524  f = new MathFunc_t;
2525  f->fname = std::string("round");
2526  f->ns = this;
2527  f->args.resize(1 + 1);
2528  f->args[0] = new MathArgReal_t;
2529  f->args[1] = new MathArgReal_t;
2530  f->f = mp_func_1<MathParser::MathArgReal_t, MathParser::MathArgReal_t, rint>;
2531  f->t = 0;
2532 
2533  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2534  silent_cerr("static namespace: "
2535  "unable to insert handler "
2536  "for function " << f->fname << std::endl);
2538  }
2539 #endif /* __USE_XOPEN */
2540 
2541  // rand
2542  f = new MathFunc_t;
2543  f->fname = std::string("rand");
2544  f->ns = this;
2545  f->args.resize(1 + 0);
2546  f->args[0] = new MathArgInt_t;
2547  f->f = mp_rand;
2548  f->t = 0;
2549 
2550  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2551  silent_cerr("static namespace: "
2552  "unable to insert handler "
2553  "for function " << f->fname << std::endl);
2555  }
2556 
2557  // random
2558  f = new MathFunc_t;
2559  f->fname = std::string("random");
2560  f->ns = this;
2561  f->args.resize(1 + 0);
2562  f->args[0] = new MathArgReal_t;
2563  f->f = mp_rndm;
2564  f->t = 0;
2565 
2566  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2567  silent_cerr("static namespace: "
2568  "unable to insert handler "
2569  "for function " << f->fname << std::endl);
2571  }
2572 
2573  // seed
2574  f = new MathFunc_t;
2575  f->fname = std::string("seed");
2576  f->ns = this;
2577  f->args.resize(1 + 1);
2578  f->args[0] = new MathArgVoid_t;
2579  f->args[1] = new MathArgInt_t;
2580  f->f = mp_srnd;
2581  f->t = 0;
2582 
2583  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2584  silent_cerr("static namespace: "
2585  "unable to insert handler "
2586  "for function " << f->fname << std::endl);
2588  }
2589 
2590  // step
2591  f = new MathFunc_t;
2592  f->fname = std::string("step");
2593  f->ns = this;
2594  f->args.resize(1 + 1);
2595  f->args[0] = new MathArgReal_t;
2596  f->args[1] = new MathArgReal_t;
2597  f->f = mp_step;
2598  f->t = 0;
2599 
2600  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2601  silent_cerr("static namespace: "
2602  "unable to insert handler "
2603  "for function " << f->fname << std::endl);
2605  }
2606 
2607  // ramp
2608  f = new MathFunc_t;
2609  f->fname = std::string("ramp");
2610  f->ns = this;
2611  f->args.resize(1 + 1);
2612  f->args[0] = new MathArgReal_t;
2613  f->args[1] = new MathArgReal_t;
2614  f->f = mp_ramp;
2615  f->t = 0;
2616 
2617  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2618  silent_cerr("static namespace: "
2619  "unable to insert handler "
2620  "for function " << f->fname << std::endl);
2622  }
2623 
2624  // sramp
2625  f = new MathFunc_t;
2626  f->fname = std::string("sramp");
2627  f->ns = this;
2628  f->args.resize(1 + 2);
2629  f->args[0] = new MathArgReal_t;
2630  f->args[1] = new MathArgReal_t;
2631  f->args[2] = new MathArgReal_t;
2632  f->f = mp_sramp;
2633  f->t = 0;
2634 
2635  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2636  silent_cerr("static namespace: "
2637  "unable to insert handler "
2638  "for function " << f->fname << std::endl);
2640  }
2641 
2642  // par
2643  f = new MathFunc_t;
2644  f->fname = std::string("par");
2645  f->ns = this;
2646  f->args.resize(1 + 1);
2647  f->args[0] = new MathArgReal_t;
2648  f->args[1] = new MathArgReal_t;
2649  f->f = mp_par;
2650  f->t = 0;
2651 
2652  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2653  silent_cerr("static namespace: "
2654  "unable to insert handler "
2655  "for function " << f->fname << std::endl);
2657  }
2658 
2659  // in
2660  f = new MathFunc_t;
2661  f->fname = std::string("in_ll");
2662  f->ns = this;
2663  f->args.resize(1 + 3);
2664  f->args[0] = new MathArgReal_t;
2665  f->args[1] = new MathArgReal_t;
2666  f->args[2] = new MathArgReal_t;
2667  f->args[3] = new MathArgReal_t;
2668  f->f = mp_in<IN_LL>;
2669  f->t = 0;
2670 
2671  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2672  silent_cerr("static namespace: "
2673  "unable to insert handler "
2674  "for function " << f->fname << std::endl);
2676  }
2677 
2678  f = new MathFunc_t;
2679  f->fname = std::string("in_le");
2680  f->ns = this;
2681  f->args.resize(1 + 3);
2682  f->args[0] = new MathArgReal_t;
2683  f->args[1] = new MathArgReal_t;
2684  f->args[2] = new MathArgReal_t;
2685  f->args[3] = new MathArgReal_t;
2686  f->f = mp_in<IN_LE>;
2687  f->t = 0;
2688 
2689  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2690  silent_cerr("static namespace: "
2691  "unable to insert handler "
2692  "for function " << f->fname << std::endl);
2694  }
2695 
2696  f = new MathFunc_t;
2697  f->fname = std::string("in_el");
2698  f->ns = this;
2699  f->args.resize(1 + 3);
2700  f->args[0] = new MathArgReal_t;
2701  f->args[1] = new MathArgReal_t;
2702  f->args[2] = new MathArgReal_t;
2703  f->args[3] = new MathArgReal_t;
2704  f->f = mp_in<IN_EL>;
2705  f->t = 0;
2706 
2707  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2708  silent_cerr("static namespace: "
2709  "unable to insert handler "
2710  "for function " << f->fname << std::endl);
2712  }
2713 
2714  f = new MathFunc_t;
2715  f->fname = std::string("in_ee");
2716  f->ns = this;
2717  f->args.resize(1 + 3);
2718  f->args[0] = new MathArgReal_t;
2719  f->args[1] = new MathArgReal_t;
2720  f->args[2] = new MathArgReal_t;
2721  f->args[3] = new MathArgReal_t;
2722  f->f = mp_in<IN_EE>;
2723  f->t = 0;
2724 
2725  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2726  silent_cerr("static namespace: "
2727  "unable to insert handler "
2728  "for function " << f->fname << std::endl);
2730  }
2731 
2732  // print
2733  f = new MathFunc_t;
2734  f->fname = std::string("print");
2735  f->ns = this;
2736  f->args.resize(1 + 1);
2737  f->args[0] = new MathArgVoid_t;
2738  f->args[1] = new MathArgReal_t;
2739  f->f = mp_print;
2740  f->t = 0;
2741 
2742  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2743  silent_cerr("static namespace: "
2744  "unable to insert handler "
2745  "for function " << f->fname << std::endl);
2747  }
2748 
2749  // sprintf
2750  f = new MathFunc_t;
2751  f->fname = std::string("sprintf");
2752  f->ns = this;
2753  f->args.resize(1 + 2);
2754  f->args[0] = new MathArgString_t;
2755  f->args[1] = new MathArgString_t;
2756  f->args[2] = new MathArgAny_t;
2757  f->f = mp_sprintf;
2758  f->t = 0;
2759 
2760  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2761  silent_cerr("static namespace: "
2762  "unable to insert handler "
2763  "for function " << f->fname << std::endl);
2765  }
2766 
2767  // stop
2768  f = new MathFunc_t;
2769  f->fname = std::string("stop");
2770  f->ns = this;
2771  f->args.resize(1 + 2);
2772  f->args[0] = new MathArgVoid_t;
2773  f->args[1] = new MathArgInt_t;
2774  f->args[2] = new MathArgInt_t;
2775  f->f = mp_stop;
2776  f->t = 0;
2777 
2778  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2779  silent_cerr("static namespace: "
2780  "unable to insert handler "
2781  "for function " << f->fname << std::endl);
2783  }
2784 
2785  // cast
2786  {
2787  struct {
2788  TypedValue::Type type;
2789  MathArg_t *arg;
2790  } data[5] = {
2792  { TypedValue::VAR_INT },
2796  };
2797 
2798  data[0].arg = new MathArgBool_t;
2799  data[1].arg = new MathArgInt_t;
2800  data[2].arg = new MathArgReal_t;
2801  data[3].arg = new MathArgString_t;
2802 
2803  for (int i = 0; data[i].type != TypedValue::VAR_UNKNOWN; i++) {
2804  f = new MathFunc_t;
2805  f->fname = std::string(TypedValue::GetTypeName(data[i].type));
2806  f->ns = this;
2807  f->args.resize(1 + 1);
2808  f->args[0] = data[i].arg;
2809  f->args[1] = new MathArgAny_t;
2810  f->f = mp_cast;
2811  f->t = 0;
2812 
2813  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2814  silent_cerr("static namespace: "
2815  "unable to insert handler "
2816  "for function " << f->fname << std::endl);
2818  }
2819  }
2820  }
2821 }
MathArgPriv_t< Real, AT_REAL > MathArgReal_t
Definition: mathp.h:155
static int mp_cast(const MathParser::MathArgs &args)
Definition: mathp.cc:787
static int mp_step(const MathParser::MathArgs &args)
Definition: mathp.cc:606
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
static int mp_ramp(const MathParser::MathArgs &args)
Definition: mathp.cc:633
static int mp_greater_than_or_equal_to_0_t(const MathParser::MathArgs &args)
Definition: mathp.cc:205
static int mp_acosh_t(const MathParser::MathArgs &args)
Definition: mathp.cc:156
static int mp_actg2(const MathParser::MathArgs &args)
Definition: mathp.cc:456
static int mp_sign(const MathParser::MathArgs &args)
Definition: mathp.cc:515
static int mp_srnd(const MathParser::MathArgs &args)
Definition: mathp.cc:249
static int mp_greater_than_0_t(const MathParser::MathArgs &args)
Definition: mathp.cc:189
static int mp_rand(const MathParser::MathArgs &args)
Definition: mathp.cc:221
MathArgPriv_t< bool, AT_BOOL > MathArgBool_t
Definition: mathp.h:153
const char *const GetTypeName(void) const
Definition: mathp.cc:1176
static int mp_ctgh(const MathParser::MathArgs &args)
Definition: mathp.cc:481
static int mp_rndm(const MathParser::MathArgs &args)
Definition: mathp.cc:235
static int mp_actg(const MathParser::MathArgs &args)
Definition: mathp.cc:438
static int mp_atanh_t(const MathParser::MathArgs &args)
Definition: mathp.cc:172
MathArgPriv_t< TypedValue, AT_ANY > MathArgAny_t
Definition: mathp.h:152
static int mp_tan_t(const MathParser::MathArgs &args)
Definition: mathp.cc:137
static int mp_sprintf(const MathParser::MathArgs &args)
Definition: mathp.cc:264
static int mp_ctgh_t(const MathParser::MathArgs &args)
Definition: mathp.cc:499
static int mp_min(const MathParser::MathArgs &args)
Definition: mathp.cc:562
static int mp_stop(const MathParser::MathArgs &args)
Definition: mathp.cc:373
static int mp_acos_t(const MathParser::MathArgs &args)
Definition: mathp.cc:120
static int mp_sramp(const MathParser::MathArgs &args)
Definition: mathp.cc:657
MathArgPriv_t< std::string, AT_STRING > MathArgString_t
Definition: mathp.h:156
static int mp_ctg_t(const MathParser::MathArgs &args)
Definition: mathp.cc:419
static int mp_asin_t(const MathParser::MathArgs &args)
Definition: mathp.cc:103
static bool sns
Definition: mathp.cc:2006
MathArgPriv_t< Int, AT_INT > MathArgInt_t
Definition: mathp.h:154
static int mp_ctg(const MathParser::MathArgs &args)
Definition: mathp.cc:401
static int mp_max(const MathParser::MathArgs &args)
Definition: mathp.cc:538
static int mp_par(const MathParser::MathArgs &args)
Definition: mathp.cc:689
static int mp_print(const MathParser::MathArgs &args)
Definition: mathp.cc:344

Here is the call graph for this function:

MathParser::StaticNameSpace::~StaticNameSpace ( void  )

Definition at line 2823 of file mathp.cc.

References func().

2824 {
2825  for (funcType::iterator f = func.begin(); f != func.end(); ++f) {
2826  delete f->second;
2827  }
2828 }

Here is the call graph for this function:

Member Function Documentation

TypedValue MathParser::StaticNameSpace::EvalFunc ( MathParser::MathFunc_t f) const
virtual

Implements MathParser::NameSpace.

Definition at line 2859 of file mathp.cc.

References MathParser::MathFunc_t::args, MathParser::AT_BOOL, MathParser::AT_INT, MathParser::AT_REAL, MathParser::AT_STRING, MathParser::AT_VOID, MathParser::MathFunc_t::f, and MBDYN_EXCEPT_ARGS.

2860 {
2861  f->f(f->args);
2862 
2863  switch (f->args[0]->Type()) {
2864  case MathParser::AT_VOID:
2865  return TypedValue(0);
2866 
2867  case MathParser::AT_BOOL:
2868  return TypedValue((*dynamic_cast<MathArgBool_t*>(f->args[0]))());
2869 
2870  case MathParser::AT_INT:
2871  return TypedValue((*dynamic_cast<MathArgInt_t*>(f->args[0]))());
2872 
2873  case MathParser::AT_REAL:
2874  return TypedValue((*dynamic_cast<MathArgReal_t*>(f->args[0]))());
2875 
2876  case MathParser::AT_STRING:
2877  return TypedValue((*dynamic_cast<MathArgString_t*>(f->args[0]))());
2878 
2879  default:
2881  }
2882 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
MathFunc_f f
Definition: mathp.h:170
MathParser::MathFunc_t * MathParser::StaticNameSpace::GetFunc ( const std::string &  fname) const
virtual

Implements MathParser::NameSpace.

Definition at line 2847 of file mathp.cc.

References func().

2848 {
2849  funcType::const_iterator i = func.find(fname);
2850 
2851  if (i != func.end()) {
2852  return new MathParser::MathFunc_t(*i->second);
2853  }
2854 
2855  return 0;
2856 }

Here is the call graph for this function:

Table * MathParser::StaticNameSpace::GetTable ( void  )
virtual

Implements MathParser::NameSpace.

Definition at line 2885 of file mathp.cc.

2886 {
2887  return m_pTable;
2888 }
bool MathParser::StaticNameSpace::IsFunc ( const std::string &  fname) const
virtual

Implements MathParser::NameSpace.

Definition at line 2831 of file mathp.cc.

References func().

2832 {
2833 #if 0
2834  for (funcType::const_iterator f = func.begin(); f != func.end(); ++f) {
2835  silent_cerr("*** " << f->second->fname << std::endl);
2836  }
2837 #endif
2838 
2839  if (func.find(fname) != func.end()) {
2840  return true;
2841  }
2842 
2843  return false;
2844 }

Here is the call graph for this function:

Member Data Documentation

funcType MathParser::StaticNameSpace::func
private

Definition at line 208 of file mathp.h.

Referenced by StaticNameSpace().

Table* MathParser::StaticNameSpace::m_pTable
private

Definition at line 209 of file mathp.h.


The documentation for this class was generated from the following files: