Exemplo n.º 1
0
        /// <summary>
        /// Set defined for the source
        /// </summary>
        /// <param name="Source"></param>
        public void setDefined(TParameterDefinition Source)
        {
            int Idx;

            if (bIsScalar())
                FDefined = Source.FDefined;
            else
            {
                for (Idx = 0; Idx <= iCount - 1; Idx++)
                    FItems[Idx].setDefined(Source.FItems[Idx]);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initalises TParameterDefinition from another instance
        /// </summary>
        /// <param name="Source"></param>
        public TParameterDefinition(TParameterDefinition Source)
        {
            FItems = new TParameterDefinition[0];
            int Idx;

            FName = Source.sFullName;
            FNamePart = Source.sPartName;
            FType = Source.paramType;
            FCount = Source.iCount;

            if (FCount > 0)
            {
                Array.Resize(ref FItems, FCount);
                for (Idx = 0; Idx <= FCount - 1; Idx++)
                    FItems[Idx] = new TParameterDefinition(Source.item(Idx));
            }
            else
                FItems = null;

            FParamCount = Source.iParamCount;
            FDefined = Source.FDefined;
        }
Exemplo n.º 3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sTagDefinition"></param>
        /// <param name="aType"></param>
        protected void defineParameters(string sTagDefinition, TTypedValue.TBaseType aType)
        {
            string[] sDefn = new string[0];
            int Kdx;

            Tokenise(sTagDefinition, ref sDefn, "-");
            Kdx = FDefinitions.Length;
            Array.Resize(ref FDefinitions, Kdx + 1);
            FDefinitions[Kdx] = new TParameterDefinition(sDefn, aType);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="srcSet"></param>
        /// <param name="Defn"></param>
        protected void copyDefinition(TParameterSet srcSet, TParameterDefinition Defn)
        {
            int Idx;

            if ((Defn.bIsScalar()) && (srcSet != null) && (srcSet.bIsDefined(Defn.sFullName)))
            {
                switch (Defn.paramType)
                {
                    case ptyReal: setParam(Defn.sFullName, srcSet.fParam(Defn.sFullName));
                        break;
                    case ptyInt: setParam(Defn.sFullName, srcSet.iParam(Defn.sFullName));
                        break;
                    case ptyBool: setParam(Defn.sFullName, srcSet.bParam(Defn.sFullName));
                        break;
                    case ptyText: setParam(Defn.sFullName, srcSet.sParam(Defn.sFullName));
                        break;
                }
            }
            else if (Defn.bIsScalar())
                setUndefined(Defn.sFullName);
            else
                for (Idx = 0; Idx <= Defn.iCount - 1; Idx++)
                    copyDefinition(srcSet, Defn.item(Idx));
        }
Exemplo n.º 5
0
        private void writeParameters(TParameterSet subSet, TParameterDefinition Definition, List<string> Strings, int iIndent)
        {
            int iDiffCount;
            string sLine;
            int Idx;

            if (Definition.iDimension() > 1)                                         // Multi-dimensional array of
                for (Idx = 0; Idx <= Definition.iCount - 1; Idx++)                                  //   parameters - recurse
                    writeParameters(subSet, Definition.item(Idx), Strings, iIndent);

            else if (Definition.bIsScalar() && bDiffers(subSet, Definition))      // Single parameter value
            {
                sLine = new string(' ', iIndent)
                       + "<par name=\"" + Definition.sFullName + "\">"
                       + subSet.sParam(Definition.sFullName)
                       + "</par>";
                Strings.Add(sLine);
            }
            else                                                                     // List of parameter values (one-
            {                                                                    //   dimensional)
                iDiffCount = 0;
                for (Idx = 0; Idx <= Definition.iCount - 1; Idx++)
                    if (bDiffers(subSet, Definition.item(Idx)))
                        iDiffCount++;

                if (iDiffCount > 1)                                                // More than one difference - write
                {                                                                  //   the differing values in a list
                    sLine = new string(' ', iIndent)
                             + "<par name=\"" + Definition.sFullName + "\">";
                    for (Idx = 0; Idx <= Definition.iCount - 1; Idx++)
                    {
                        if (Idx > 0)
                            sLine += ',';
                        if (bDiffers(subSet, Definition.item(Idx)))
                            sLine += subSet.sParam(Definition.item(Idx).sFullName);
                    }
                    sLine += "</par>";
                    Strings.Add(sLine);
                }
                else if (iDiffCount == 1)                                           // Only one parameter is different -
                    for (Idx = 0; Idx <= Definition.iCount - 1; Idx++)                               //  write it as a scalar
                        if (bDiffers(subSet, Definition.item(Idx)))
                            writeParameters(subSet, Definition.item(Idx), Strings, iIndent);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="subSet"></param>
        /// <param name="Definition"></param>
        /// <returns></returns>
        private bool bDiffers(TParameterSet subSet, TParameterDefinition Definition)
        {
            bool result;

            if (!Definition.bValueDefined())
                result = false;
            else if ((subSet.Parent == null) || (!subSet.Parent.bIsDefined(Definition.sFullName)))
                result = true;
            else
            {
                switch (Definition.paramType)
                {
                    case ptyReal: result = (subSet.fParam(Definition.sFullName) != subSet.Parent.fParam(Definition.sFullName));
                        break;
                    case ptyInt: result = (subSet.iParam(Definition.sFullName) != subSet.Parent.iParam(Definition.sFullName));
                        break;
                    case ptyBool: result = (subSet.bParam(Definition.sFullName) != subSet.Parent.bParam(Definition.sFullName));
                        break;
                    case ptyText: result = (subSet.sParam(Definition.sFullName) != subSet.Parent.sParam(Definition.sFullName));
                        break;
                    default: result = false;
                        break;
                }
            }
            return result;
        }