All Downloads are FREE. Search and download functionalities are using the official Maven repository.

z3-z3-4.13.0.src.api.dotnet.Params.cs Maven / Gradle / Ivy

The newest version!
/*++
Copyright (c) 2012 Microsoft Corporation

Module Name:

    Parameter.cs

Abstract:

    Z3 Managed API: Parameters

Author:

    Christoph Wintersteiger (cwinter) 2012-03-20

Notes:
    
--*/

using System.Diagnostics;
using System;

namespace Microsoft.Z3
{
    /// 
    /// A Params objects represents a configuration in the form of Symbol/value pairs.
    /// 
    public class Params : Z3Object
    {
        /// 
        /// Adds a parameter setting.
        /// 
        public Params Add(Symbol name, bool value)
        {
            Debug.Assert(name != null);

            Native.Z3_params_set_bool(Context.nCtx, NativeObject, name.NativeObject, (byte)(value ? 1 : 0));
            return this;
        }

        /// 
        /// Adds a parameter setting.
        /// 
        public Params Add(Symbol name, uint value)
        {
            Debug.Assert(name != null);

            Native.Z3_params_set_uint(Context.nCtx, NativeObject, name.NativeObject, value);
            return this;
        }

        /// 
        /// Adds a parameter setting.
        /// 
        public Params Add(Symbol name, double value)
        {
            Debug.Assert(name != null);            

            Native.Z3_params_set_double(Context.nCtx, NativeObject, name.NativeObject, value);
            return this;
        }

        /// 
        /// Adds a parameter setting.
        /// 
        public Params Add(Symbol name, string value)
        {
            Debug.Assert(value != null);

            Native.Z3_params_set_symbol(Context.nCtx, NativeObject, name.NativeObject, Context.MkSymbol(value).NativeObject);
            return this;
        }

        /// 
        /// Adds a parameter setting.
        /// 
        public Params Add(Symbol name, Symbol value)
        {
            Debug.Assert(name != null);
            Debug.Assert(value != null);

            Native.Z3_params_set_symbol(Context.nCtx, NativeObject, name.NativeObject, value.NativeObject);
            return this;
        }


        /// 
        /// Adds a parameter setting.
        /// 
        public Params Add(string name, bool value)
        {
            Native.Z3_params_set_bool(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, (byte)(value ? 1 : 0));
	    return this;
        }

        /// 
        /// Adds a parameter setting.
        /// 
        public Params Add(string name, uint value)
        {
            Native.Z3_params_set_uint(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, value);
	    return this;
        }

        /// 
        /// Adds a parameter setting.
        /// 
        public Params Add(string name, double value)
        {
            Native.Z3_params_set_double(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, value);
            return this;
        }

        /// 
        /// Adds a parameter setting.
        /// 
        public Params Add(string name, Symbol value)
        {
            Debug.Assert(value != null);

            Native.Z3_params_set_symbol(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, value.NativeObject);
            return this;
        }

        /// 
        /// Adds a parameter setting.
        /// 
        public Params Add(string name, string value)
        {
            Debug.Assert(name != null);
            Debug.Assert(value != null);

            Native.Z3_params_set_symbol(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, Context.MkSymbol(value).NativeObject);
            return this;
        }

        /// 
        /// A string representation of the parameter set.
        /// 
        public override string ToString()
        {
            return Native.Z3_params_to_string(Context.nCtx, NativeObject);
        }

        #region Internal
        internal Params(Context ctx)
            : base(ctx, Native.Z3_mk_params(ctx.nCtx))
        {
            Debug.Assert(ctx != null);
        }      

        internal override void IncRef(IntPtr o)
        {
            Native.Z3_params_inc_ref(Context.nCtx, o);
        }

        internal override void DecRef(IntPtr o)
        {
            lock (Context)
            {
                if (Context.nCtx != IntPtr.Zero)
                    Native.Z3_params_dec_ref(Context.nCtx, o);
            }
        }
        #endregion
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy