Exemplo n.º 1
0
        //template <typename T>
        public param_num_t(core_device_t device, string name, T val)
            : base(device, name)
        {
            m_param = val;


            bool   found = false;
            string p     = this.get_initial(device, out found);

            if (found)
            {
                plib.pfunction <nl_fptype, nl_fptype_ops> func = new plib.pfunction <nl_fptype, nl_fptype_ops>();
                func.compile_infix(p, new std.vector <string>());
                var valx = func.evaluate();
                if (ops.is_integral())  //if (plib::is_integral<T>::value)
                {
                    if (plib.pg.abs(valx - plib.pg.trunc(valx)) > nlconst.magic(1e-6))
                    {
                        throw new nl_exception(MF_INVALID_NUMBER_CONVERSION_1_2(device.name() + "." + name, p));
                    }
                }
                m_param = ops.cast(valx);  //m_param = plib::narrow_cast<T>(valx);
            }

            device.state().save(this, m_param, this.name(), "m_param");
        }
Exemplo n.º 2
0
 protected param_t(core_device_t device, string name)
     : base(device, device.name() + "." + name)
 {
     device.state().setup().register_param_t(this);
 }