/* * Constructor */ public GroupNode() { _priority = -1; _parent = null; _labels = null; _depignore = NO_IGNORE; _dependencies = null; }
/* * Member Methods */ public override object Clone() { // instantiate cloned object BranchGroupNode obj = new BranchGroupNode(); // call the cloneHelper cloneHelper(obj); // return object return(obj); }
/// <summary> /// This method helps in the cloning process by allowing each /// class in the hierarchy to clone their own member variables. /// The class being cloned will create a new instance of itself, /// and then call the cloneHelper in its super-class to get any /// member variables of its super classes to be copied. /// </summary> /// <param name="g">the instance of the cloned object</param> protected void cloneHelper(BranchGroupNode g) { base.cloneHelper(g); g._name = _name; // I believe this will always be true... // if it is then there is no need to copy _childContainers System.Diagnostics.Debug.Assert(_childContainers.Count == 0); // deep copy the children IEnumerator child = _children.GetEnumerator(); while (child.MoveNext()) { g._children.Add(((GroupNode)child.Current).Clone()); } }
public void CreateExtraStates(VariableTable varTable, IBranchDataWindow window) { // Add Length State _listLengthState = new ApplianceState(_appliance, LIST_LENGTH_STATE, true); PUC.Types.IntegerSpace intSpace; if (_itemCount != null) { intSpace = new PUC.Types.IntegerSpace(_itemCount, _itemCount); if (_itemCount is IConstraint) { new TypeConstraintListener(_listLengthState, (IConstraint)_itemCount); } } else if (_minimum == null && _maximum == null) { intSpace = new PUC.Types.IntegerSpace(new IntNumber(0), new IntNumber(Int32.MaxValue)); } else if (_minimum != null && _maximum != null) { intSpace = new PUC.Types.IntegerSpace(_minimum, _maximum); if (_minimum is IConstraint) { new TypeConstraintListener(_listLengthState, (IConstraint)_minimum); } if (_maximum is IConstraint) { new TypeConstraintListener(_listLengthState, (IConstraint)_maximum); } } else if (_minimum != null) { intSpace = new IntegerSpace(_minimum, new IntNumber(Int32.MaxValue)); if (_minimum is IConstraint) { new TypeConstraintListener(_listLengthState, (IConstraint)_minimum); } } else { intSpace = new IntegerSpace(new IntNumber(0), _maximum); if (_maximum is IConstraint) { new TypeConstraintListener(_listLengthState, (IConstraint)_maximum); } } _listLengthState.Type = new PUCType(intSpace); GroupNode newG = new ObjectGroupNode(_listLengthState); newG.Parent = this; this.Children.Add(newG); varTable.RegisterObject(_listLengthState.MakeFullName(this.FullPath), _listLengthState); window.AddChildWindow(_listLengthState); newG.Parent = null; // remove from group so it doesn't get in the way later this.Children.Remove(newG); // Add Selection States _listSelectionState = new ApplianceState(_appliance, LIST_SELECTION_STATE, _selectionReadOnly); _listSelectionState.Type = new PUCType(new IntegerSpace(new IntNumber(0), new NumberConstraint(_listSelectionState, _listLengthState))); if (_selectionType == SelectionType.One) { // one selection newG = new ObjectGroupNode(_listSelectionState); newG.Parent = this; this.Children.Add(newG); _listSelectionState.FullName = _listSelectionState.MakeFullName(this.FullPath); _listSelectionState.SetNetworkHandler(); window.AddChildWindow(_listSelectionState); newG.Parent = null; // remove from group so it doesn't get in the way later this.Children.Remove(newG); } else { // multiple selections BranchGroupNode selGroup = new BranchGroupNode(); _listSelectionLengthState = new ApplianceState(_appliance, LIST_LENGTH_STATE, false); _listSelectionLengthState.Type = new PUCType(new IntegerSpace(new IntNumber(0), new NumberConstraint(_listSelectionState, _listLengthState))); this.Children.Add(selGroup); selGroup.Name = LIST_SELECTION_STATE; newG = new ObjectGroupNode(_listSelectionLengthState); newG.Parent = selGroup; selGroup.Children.Add(newG); newG = new ObjectGroupNode(_listSelectionState); newG.Parent = selGroup; selGroup.Children.Add(newG); varTable.RegisterObject(_listSelectionLengthState.MakeFullName(selGroup.FullPath), _listSelectionLengthState); _listSelectionState.FullName = _listSelectionState.MakeFullName(selGroup.FullPath); window.AddChildWindow(_listSelectionLengthState); window.AddChildWindow(_listSelectionState); this.Children.Remove(selGroup); } varTable.RegisterObject(_listSelectionState.FullName, _listSelectionState); }