/// <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="clone">the instance of the cloned object</param> protected void cloneHelper(ApplianceState clone) { base.cloneHelper(clone); // this may not always be appropriate...but should be given // when I expect the cloning to be taking place clone.SetNetworkHandler(); // these events should not have any handlers yet System.Diagnostics.Debug.Assert(TypeChangedEvent == null); System.Diagnostics.Debug.Assert(ValueChangedEvent == null); // this shouldn't contain anything yet // assuming that it doesn't, we don't need to copy it System.Diagnostics.Debug.Assert(_reverseDeps.Count == 0); // these items shouldn't be defined yet System.Diagnostics.Debug.Assert(_windowNames == null); System.Diagnostics.Debug.Assert(_windowRef == null); System.Diagnostics.Debug.Assert(_windowParent == null); // shallow copy these items clone._readonly = _readonly; clone._constraintVariable = _constraintVariable; clone._defined = _defined; clone._varTable = _varTable; clone._type = _type; clone._internalController = _internalController; }
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); }