Exemple #1
0
        ///
        ///	 * <param name="caps">
        ///	 *            the element to append the ref to
        ///	 *  </param>
        ///	 * <returns> <seealso cref="JDFModuleCap"/> the Modulecap that id refers tp </returns>
        ///
        public static JDFModuleCap appendModuleRef(ICapabilityElement caps, string id)
        {
            caps.setAvailability(EnumAvailability.Module);
            JDFModulePool mp = caps.getCreateModulePool();

            ((KElement)caps).appendAttribute(AttributeName.MODULEREFS, id, null, null, true);
            return(mp.getCreateModuleCap(id));
        }
Exemple #2
0
        ///
        ///	 <summary> * getState()
        ///	 *  </summary>
        ///	 * <returns> JDFAbstractState </returns>
        ///
        public virtual JDFAbstractState getState()
        {
            ICapabilityElement ic = getRefTarget();

            if (ic is JDFAbstractState)
            {
                return((JDFAbstractState)ic);
            }
            return(null);
        }
Exemple #3
0
        ///
        ///	 <summary> * get the module availability based on modulerefs and availability
        ///	 *  </summary>
        ///	 * <param name="caps">
        ///	 *            either A State, devcap or devcaps
        ///	 * @return </param>
        ///
        public static EnumAvailability getModuleAvailability(ICapabilityElement caps)
        {
            EnumAvailability a = caps.getAvailability();

            if (!EnumAvailability.Module.Equals(a))
            {
                return(a);
            }
            JDFModulePool mp = caps.getModulePool();

            if (mp == null)
            {
                return(null);
            }
            return(mp.getMinAvailability(caps.getModuleRefs()));
        }
Exemple #4
0
        ///
        ///	 <summary> * getRefTargetName()
        ///	 *  </summary>
        ///	 * <returns> String </returns>
        ///
        public virtual string getRefTargetName()
        {
            ICapabilityElement e = getRefTarget();

            if (e is JDFAbstractState)
            {
                return(((JDFAbstractState)e).getName());
            }
            else if (e is JDFDevCap)
            {
                return(((JDFDevCap)e).getName());
            }
            else if (e is JDFDevCaps)
            {
                return(((JDFDevCaps)e).getName());
            }
            return(null);
        }
Exemple #5
0
        ///
        ///	 <summary> * append an action to this that references a Test that defines an exclusion
        ///	 * of two values
        ///	 *  </summary>
        ///	 * <param name="id1">
        ///	 *            the id of the first state or devcap to reference </param>
        ///	 * <param name="id2">
        ///	 *            the id of the 2nd state or devcap to reference
        ///	 *  </param>
        ///	 * <returns> the newly created action </returns>
        ///
        public virtual JDFAction appendExcludeTest(ICapabilityElement t1, ICapabilityElement t2)
        {
            if (t1 == null || t2 == null)
            {
                return(null); // snafu - cant find elements to match
            }
            string id1 = ((JDFElement)t1).appendAnchor(null);
            string id2 = ((JDFElement)t2).appendAnchor(null);

            JDFAction action = appendActionTest(EnumTerm.and, true); // fail if a &&
            // b
            JDFand and = (JDFand)action.getTestTerm();

            JDFEvaluation ev1 = (JDFEvaluation)and.appendTerm(t1.getEvaluationType());

            ev1.setrRef(id1);
            JDFEvaluation ev2 = (JDFEvaluation)and.appendTerm(t2.getEvaluationType());

            ev2.setrRef(id2);

            return(action);
        }
Exemple #6
0
        ///
        ///	 <summary> * gets the XPath to the attributes of a given JDF node
        ///	 *  </summary>
        ///	 * <param name="jdf">
        ///	 *            JDF node to test </param>
        ///	 * <returns> String - the XPath to the attributes </returns>
        ///
        protected internal virtual string getEvalXPath(KElement jdf)
        {
            ICapabilityElement stateDC = getRefTarget();

            if (stateDC == null)
            {
                return(null);
            }

            VString vPath    = null;
            bool    bElement = false;
            string  attName  = null;

            if (stateDC is JDFDevCap)
            {
                if (!(this is JDFIsPresentEvaluation)) // only ispresent may
                // reference a
                // devcap, all
                // others must
                // reference a state
                {
                    return(null);
                }
                bElement = true;
                JDFDevCap dc = (JDFDevCap)stateDC;
                vPath = dc.getNamePathVector(true);
                // fix up for the fact that ispresent for a resource is actually a
                // link
                if (vPath != null)
                {
                    for (int i = 0; i < vPath.Count; i++)
                    {
                        string  path   = vPath.stringAt(i);
                        VString tokens = new VString(StringUtil.tokenize(path, "/", false));
                        if (tokens.Count == 3 && tokens.stringAt(1).Equals(ElementName.RESOURCEPOOL))
                        {
                            tokens[1] = ElementName.RESOURCELINKPOOL;
                            tokens[2] = tokens.stringAt(2) + "Link";
                            vPath[i]  = StringUtil.setvString(tokens, "/", null, null);
                        }
                    }
                }
            }
            else if (stateDC is JDFDevCaps)
            {
                if (!(this is JDFIsPresentEvaluation)) // only ispresent may
                // reference a
                // devcap, all
                // others must
                // reference a state
                {
                    return(null);
                }
                bElement = true;
                JDFDevCaps dc = (JDFDevCaps)stateDC;
                vPath = dc.getNamePathVector();
                // fix up for the fact that ispresent for a resource is actually a
                // link
                if (vPath != null)
                {
                    for (int i = 0; i < vPath.Count; i++)
                    {
                        string  path   = vPath.stringAt(i);
                        VString tokens = new VString(StringUtil.tokenize(path, "/", false));
                        if (tokens.Count == 3 && tokens.stringAt(1).Equals(ElementName.RESOURCEPOOL))
                        {
                            tokens[1] = ElementName.RESOURCELINKPOOL;
                            string    link = tokens.stringAt(2) + "Link";
                            EnumUsage lu   = dc.getLinkUsage();
                            if (lu != null)
                            {
                                link += "[@Usage=\"" + lu.getName() + "\"]";
                            }
                            tokens[2] = link;
                            vPath[i]  = StringUtil.setvString(tokens, "/", null, null);
                        }
                    }
                }
            }
            else
            {
                // we have found our state -> take its xPath and look for
                // corresponding elem in JDFNode, we test

                JDFAbstractState state = (JDFAbstractState)stateDC;
                if (state.getListType().Equals(EnumListType.Span))
                {
                    vPath    = state.getNamePathVector(true);
                    bElement = true;
                }
                else
                {
                    KElement kdc = state.getParentNode_KElement();
                    if (kdc is IDeviceCapable)
                    {
                        vPath = ((IDeviceCapable)kdc).getNamePathVector();
                    }
                    else if (kdc is ICapabilityElement)
                    {
                        vPath = ((ICapabilityElement)kdc).getNamePathVector();
                    }
                    attName = state.getName();
                }
            }
            if (vPath != null)
            {
                for (int i = 0; i < vPath.Count; i++)
                {
                    string xPath  = vPath.stringAt(i);
                    int    slash  = xPath.Length;
                    string finalS = null;
                    do
                    {
                        string xPath2 = xPath.Substring(0, slash);
                        if (jdf.matchesPath(xPath2, true))
                        {
                            finalS = "." + xPath.Substring(slash);
                        }
                        slash = xPath2.LastIndexOf("/");
                    } while (slash >= 0 && finalS == null);

                    if (finalS != null && !bElement)
                    {
                        finalS += "/@" + attName;
                    }
                    if (finalS != null)
                    {
                        return(finalS);
                    }
                }
            }
            return(null);
        }