Ejemplo n.º 1
0
		/// <summary>
		/// Enumerate thru all possible values that are currently instantiated.
		/// </summary>
		/// <param name="feature">The feature.</param>
		/// <param name="varValues">The possible values.</param>
		/// <param name="polarity">The variable polarity.</param>
		/// <returns>An enumerable of feature values.</returns>
		IEnumerable<FeatureValue> GetCurVarFeatValue(Feature feature, ICollection<FeatureValue> varValues, bool polarity)
		{
			foreach (FeatureValue value in varValues)
			{
				// if polarity is true, then return current value, otherwise return all other values
				if (polarity)
				{
					yield return value;
				}
				else
				{
					foreach (FeatureValue value2 in feature.PossibleValues)
					{
						if (value2 != value)
							yield return value2;
					}
				}
			}
		}
Ejemplo n.º 2
0
		/// <summary>
		/// Determines whether this node references the specified feature.
		/// </summary>
		/// <param name="feature">The feature.</param>
		/// <returns>
		/// 	<c>true</c> if the specified feature is referenced, otherwise <c>false</c>.
		/// </returns>
		public override bool IsFeatureReferenced(Feature feature)
		{
			if (base.IsFeatureReferenced(feature))
				return true;
			foreach (string variable in m_variables.Keys)
			{
				Feature feat = m_alphaVars.GetFeature(variable);
				if (feature == feat)
					return true;
			}
			return false;
		}
Ejemplo n.º 3
0
		public override bool IsFeatureReferenced(Feature feature)
		{
			return false;
		}
Ejemplo n.º 4
0
 /// <summary>
 /// Determines whether this node references the specified feature.
 /// </summary>
 /// <param name="feature">The feature.</param>
 /// <returns>
 ///     <c>true</c> if the specified feature is referenced, otherwise <c>false</c>.
 /// </returns>
 public abstract bool IsFeatureReferenced(Feature feature);
Ejemplo n.º 5
0
		/// <summary>
		/// Determines whether this node references the specified feature.
		/// </summary>
		/// <param name="feature">The feature.</param>
		/// <returns>
		/// 	<c>true</c> if the specified feature is referenced, otherwise <c>false</c>.
		/// </returns>
		public override bool IsFeatureReferenced(Feature feature)
		{
			return m_featureValues.ContainsFeature(feature);
		}
Ejemplo n.º 6
0
		/// <summary>
		/// Determines whether this set of feature values contains the specified feature.
		/// </summary>
		/// <param name="feature">The feature.</param>
		/// <returns>
		/// 	<c>true</c> if this set contains the specified feature, otherwise <c>false</c>.
		/// </returns>
		public bool ContainsFeature(Feature feature)
		{
			ValueInstance value;
			if (!m_values.TryGetValue(feature, out value))
				return false;

			FeatureValues fvs = value as FeatureValues;
			foreach (Feature sf in feature.SubFeatures)
			{
				if (fvs == null || !fvs.ContainsFeature(sf))
					return false;
			}
			return true;
		}
Ejemplo n.º 7
0
		Feature LoadFeature(XmlElement featDefNode, XmlElement featSysNode, FeatureSystem featSys)
		{
			XmlElement featElem = featDefNode.SelectSingleNode("Feature") as XmlElement;
			string featId = featElem.GetAttribute("id");
			Feature feature = featSys.GetFeature(featId);
			if (feature != null)
				return feature;

			string featureName = featElem.InnerText;
			string defValId = featElem.GetAttribute("defaultValue");
			feature = new Feature(featId, featureName, m_curMorpher);
			XmlNode valueListNode = featDefNode.SelectSingleNode("ValueList");
			if (valueListNode != null)
			{
				XmlNodeList valueList = valueListNode.SelectNodes("Value");
				foreach (XmlNode valueNode in valueList)
				{
					XmlElement valueElem = valueNode as XmlElement;
					string valueId = valueElem.GetAttribute("id");
					FeatureValue value = new FeatureValue(valueId, valueElem.InnerText, m_curMorpher);
					try
					{
						featSys.AddValue(value);
						feature.AddPossibleValue(value);
					}
					catch (InvalidOperationException ioe)
					{
						throw new LoadException(LoadException.LoadErrorType.TOO_MANY_FEATURE_VALUES, this,
							HCStrings.kstidTooManyFeatValues, ioe);
					}
				}
				if (!string.IsNullOrEmpty(defValId))
					feature.DefaultValue = new ClosedValueInstance(feature.GetPossibleValue(defValId));
			}
			else
			{
				XmlElement featListElem = featDefNode.SelectSingleNode("FeatureList") as XmlElement;
				string featDefIdsStr = featListElem.GetAttribute("features");
				string[] featDefIds = featDefIdsStr.Split(' ');
				foreach (string featDefId in featDefIds)
				{
					XmlNode subFeatDefNode = featSysNode.SelectSingleNode(string.Format("FeatureDefinition[@id = '{0}']", featDefId));
					Feature subFeature = LoadFeature(subFeatDefNode as XmlElement, featSysNode, featSys);
					feature.AddSubFeature(subFeature);
				}
			}
			featSys.AddFeature(feature);
			return feature;
		}
Ejemplo n.º 8
0
		/// <summary>
		/// Adds the specified feature.
		/// </summary>
		/// <param name="feature">The feature.</param>
		public void Add(Feature feature)
		{
			Add(feature, null);
		}
Ejemplo n.º 9
0
		/// <summary>
		/// Gets the values for the specified feature.
		/// </summary>
		/// <param name="feature">The feature.</param>
		/// <returns>All values.</returns>
		public ValueInstance GetValues(Feature feature)
		{
			ValueInstance value;
			if (m_values.TryGetValue(feature, out value))
				return value;
			return null;
		}
Ejemplo n.º 10
0
		/// <summary>
		/// Adds the specified feature-value pair.
		/// </summary>
		/// <param name="feature">The feature.</param>
		/// <param name="value">The value.</param>
		public void Add(Feature feature, ValueInstance value)
		{
			m_values[feature] = value;
		}
Ejemplo n.º 11
0
		/// <summary>
		/// Determines whether this set of feature values contains the specified feature.
		/// </summary>
		/// <param name="feature">The feature.</param>
		/// <returns>
		/// 	<c>true</c> if this set contains the specified feature, otherwise <c>false</c>.
		/// </returns>
		public bool ContainsFeature(Feature feature)
		{
			foreach (FeatureValue value in m_featSys.Values)
			{
				if (Get(value) && value.Feature == feature)
					return true;
			}
			return false;
		}
Ejemplo n.º 12
0
		/// <summary>
		/// Gets the values associated with the specified feature.
		/// </summary>
		/// <param name="feature">The feature.</param>
		/// <returns>The values.</returns>
		public IEnumerable<FeatureValue> GetValues(Feature feature)
		{
			foreach (FeatureValue value in feature.PossibleValues)
			{
				if (Get(value))
					yield return value;
			}
		}
Ejemplo n.º 13
0
		/// <summary>
		/// Adds the subfeature.
		/// </summary>
		/// <param name="feature">The feature.</param>
		public void AddSubFeature(Feature feature)
		{
			feature.m_parent = this;
			m_subFeatures.Add(feature);
		}
Ejemplo n.º 14
0
		/// <summary>
		/// Adds the feature.
		/// </summary>
		/// <param name="feature">The feature.</param>
		public void AddFeature(Feature feature)
		{
			m_features.Add(feature);
		}