/// <summary> /// Internal! This is used by the Installer to create new classes. /// </summary> /// <param name="runtime">Smalltalk runtime this class is part of.</param> /// <param name="name">Name of the class.</param> /// <param name="superclass">Optional binding to the class' superclass.</param> /// <param name="instanceState">State of the class' instances (named, object-indexable, byte-indexable).</param> /// <param name="instanceVariables">Instance variables bindings. Those are initially not initialized.</param> /// <param name="classVariables">Class variable binding.</param> /// <param name="classInstanceVariables">Class-instance variables bindings. Those are initially not initialized.</param> /// <param name="importedPools">Collection of pools that are imported by the class.</param> /// <param name="instanceMethods">Collection with the methods defining the instance behaviors.</param> /// <param name="classMethods">Collection with the methods defining the class behaviors.</param> public SmalltalkClass(SmalltalkRuntime runtime, Symbol name, ClassBinding superclass, InstanceStateEnum instanceState, BindingDictionary <InstanceVariableBinding> instanceVariables, DiscreteBindingDictionary <ClassVariableBinding> classVariables, BindingDictionary <ClassInstanceVariableBinding> classInstanceVariables, DiscreteBindingDictionary <PoolBinding> importedPools, InstanceMethodDictionary instanceMethods, ClassMethodDictionary classMethods) { if (runtime == null) { throw new ArgumentNullException("runtime"); } if ((name == null) || (name.Value.Length == 0)) { throw new ArgumentNullException("name"); } if (!SmalltalkClass.ValidateIdentifiers <InstanceVariableBinding>(instanceVariables)) { throw new ArgumentException("Invalid or duplicate instance variable name found", "instanceVariables"); } if (!SmalltalkClass.ValidateIdentifiers <ClassVariableBinding>(classVariables)) { throw new ArgumentException("Invalid or duplicate class variable name found", "classVariables"); } if (!SmalltalkClass.ValidateIdentifiers <ClassInstanceVariableBinding>(classInstanceVariables)) { throw new ArgumentException("Invalid or duplicate class instance variable name found", "classInstanceVariables"); } if (!SmalltalkClass.ValidateIdentifiers <PoolBinding>(importedPools)) { throw new ArgumentException("Invalid or duplicate imported pool name found", "importedPools"); } if (!SmalltalkClass.CheckDuplicates <InstanceVariableBinding, ClassVariableBinding>(instanceVariables, classVariables)) { throw new ArgumentException("Duplicate instance or class variable name. Instance and class variable names must be unique."); } if (!SmalltalkClass.CheckDuplicates <ClassInstanceVariableBinding, ClassVariableBinding>(classInstanceVariables, classVariables)) { throw new ArgumentException("Duplicate class-instance or class variable name. Class-instance and class variable names must be unique."); } this.Runtime = runtime; this.ClassInstanceVariableBindings = classInstanceVariables ?? new BindingDictionary <ClassInstanceVariableBinding>(this.Runtime, 1); this.ClassBehavior = classMethods ?? new ClassMethodDictionary(this.Runtime); this.ClassVariableBindings = classVariables ?? new DiscreteBindingDictionary <ClassVariableBinding>(this.Runtime, 1); this.ImportedPoolBindings = importedPools ?? new DiscreteBindingDictionary <PoolBinding>(this.Runtime, 1); this.InstanceBehavior = instanceMethods ?? new InstanceMethodDictionary(this.Runtime); this.InstanceState = instanceState; this.InstanceVariableBindings = instanceVariables ?? new BindingDictionary <InstanceVariableBinding>(this.Runtime, 1); this.Name = name; this.SuperclassBinding = superclass; // Null is OK .... Object has null this.InstanceSize = 0; this.ClassInstanceSize = 0; this.ClassInstanceVariables = new object[0]; }
public GlobalClass(Global parent, XmlNode xml, XmlNamespaceManager nsm) : this(parent) { if (xml == null) { throw new ArgumentNullException(); } if (nsm == null) { throw new ArgumentNullException(); } XmlAttribute attr = xml.SelectSingleNode("@superclass", nsm) as XmlAttribute; if (attr != null) { this.Superclass = attr.Value; } attr = xml.SelectSingleNode("@instaneState", nsm) as XmlAttribute; if (attr != null) { if (attr.Value == "byte") { this.InstanceState = InstanceStateEnum.Byte; } else if (attr.Value == "object") { this.InstanceState = InstanceStateEnum.Object; } else { this.InstanceState = InstanceStateEnum.None; } } foreach (XmlAttribute node in xml.SelectNodes("sd:InstanceVariable/@name", nsm)) { this.InstanceVariables.Add(node.Value); } foreach (XmlAttribute node in xml.SelectNodes("sd:ClassVariable/@name", nsm)) { this.ClassVariables.Add(node.Value); } foreach (XmlAttribute node in xml.SelectNodes("sd:ClassInstanceVariable/@name", nsm)) { this.ClassInstanceVariables.Add(node.Value); } foreach (XmlAttribute node in xml.SelectNodes("sd:ImportedPool/@name", nsm)) { this.ImportedPools.Add(node.Value); } }
public XClass(ClassDefinition definition, XSystemDictionary smalltalk) { if ((definition == null) || (smalltalk == null)) throw new ArgumentNullException(); this.Name = definition.Name.Value; if (!String.IsNullOrWhiteSpace(definition.SuperclassName.Value) && (definition.SuperclassName.Value != "nil")) this._superclass = smalltalk.GetOrCreateBinding(definition.SuperclassName.Value); this.InstanceState = definition.InstanceState.Value; this.ClassVariables = new ClassVariablesPool(definition.ClassVariableNames); this.ClassInstanceVariables = new ClassInstanceVariablesPool(this, definition.ClassInstanceVariableNames); this.ImportedPools = new ImportedPoolsPool(smalltalk, definition.ImportedPoolNames); this.InstanceVariableNames = definition.InstanceVariableNames.Select(sr => sr.Value).ToArray(); }
/// <summary> /// Internal! This is used by the Installer to create new classes. /// </summary> /// <param name="runtime">Smalltalk runtime this class is part of.</param> /// <param name="name">Name of the class.</param> /// <param name="superclass">Optional binding to the class' superclass.</param> /// <param name="instanceState">State of the class' instances (named, object-indexable, byte-indexable).</param> /// <param name="instanceVariables">Instance variables bindings. Those are initially not initialized.</param> /// <param name="classVariables">Class variable binding.</param> /// <param name="classInstanceVariables">Class-instance variables bindings. Those are initially not initialized.</param> /// <param name="importedPools">Collection of pools that are imported by the class.</param> public SmalltalkClass(SmalltalkRuntime runtime, Symbol name, ClassBinding superclass, InstanceStateEnum instanceState, BindingDictionary <InstanceVariableBinding> instanceVariables, DiscreteBindingDictionary <ClassVariableBinding> classVariables, BindingDictionary <ClassInstanceVariableBinding> classInstanceVariables, DiscreteBindingDictionary <PoolBinding> importedPools) : this(runtime, name, superclass, instanceState, instanceVariables, classVariables, classInstanceVariables, importedPools, null, null) { }
/// <summary> /// Constructor. /// </summary> /// <param name="sopClassUid">SOP class UID.</param> /// <param name="sopInstanceUid">SOP instance UID.</param> public ReferencedSopItem(System.String sopClassUid, System.String sopInstanceUid) { _instanceState = InstanceStateEnum.InstanceCreated; _sopClassUid = sopClassUid; _sopInstanceUid = sopInstanceUid; }
private static void AddReferencedSopSequence(ReferencedSopItemCollection storageCommitItems, uint tag, DvtkData.Dimse.AttributeSet attributeSet, InstanceStateEnum newInstanceState) { ushort group = (ushort)(tag >> 16); ushort element = (ushort)(tag & 0x0000FFFF); DvtkData.Dimse.Tag tagValue = new DvtkData.Dimse.Tag(group, element); DvtkData.Dimse.Attribute referencedSopSequence = attributeSet.GetAttribute(tagValue); if (referencedSopSequence != null) { attributeSet.Remove(referencedSopSequence); } referencedSopSequence = new DvtkData.Dimse.Attribute(tag, DvtkData.Dimse.VR.SQ); SequenceOfItems referencedSopSequenceOfItems = new SequenceOfItems(); referencedSopSequence.DicomValue = referencedSopSequenceOfItems; foreach(ReferencedSopItem referencedSopItem in storageCommitItems) { if (((referencedSopItem.InstanceState == InstanceStateEnum.InstanceStored) && (newInstanceState == InstanceStateEnum.InstanceMppsCompleted)) || ((referencedSopItem.InstanceState == InstanceStateEnum.InstanceMppsCompleted) && (newInstanceState == InstanceStateEnum.InstanceStorageCommitRequested))) { DvtkData.Dimse.SequenceItem referencedSopSequenceItem = new DvtkData.Dimse.SequenceItem(); referencedSopSequenceItem.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_CLASS_UID.GroupNumber, DvtkData.Dimse.Tag.REFERENCED_SOP_CLASS_UID.ElementNumber, DvtkData.Dimse.VR.UI, referencedSopItem.SopClassUid); referencedSopSequenceItem.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_INSTANCE_UID.GroupNumber, DvtkData.Dimse.Tag.REFERENCED_SOP_INSTANCE_UID.ElementNumber, DvtkData.Dimse.VR.UI, referencedSopItem.SopInstanceUid); referencedSopItem.InstanceState = newInstanceState; referencedSopSequenceOfItems.Sequence.Add(referencedSopSequenceItem); } } attributeSet.Add(referencedSopSequence); }
private static void UpdateReferencedSopItem(ReferencedSopItemCollection storageCommitItems, DvtkData.Dimse.SequenceItem item, InstanceStateEnum newInstanceState) { if (item != null) { System.String sopClassUid = System.String.Empty; System.String sopInstanceUid = System.String.Empty; // Try to get the SOP Class UID and SOP Instance UID out of the item DvtkData.Dimse.Attribute attribute = item.GetAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_CLASS_UID); if (attribute != null) { UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)attribute.DicomValue; if (uniqueIdentifier.Values.Count > 0) { sopClassUid = uniqueIdentifier.Values[0]; } } attribute = item.GetAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_INSTANCE_UID); if (attribute != null) { UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)attribute.DicomValue; if (uniqueIdentifier.Values.Count > 0) { sopInstanceUid = uniqueIdentifier.Values[0]; } } ReferencedSopItem referencedSopItem = storageCommitItems.Find(sopClassUid, sopInstanceUid); if ((referencedSopItem != null) && (referencedSopItem.InstanceState == InstanceStateEnum.InstanceStorageCommitRequested)) { referencedSopItem.InstanceState = newInstanceState; } } }
/// <summary> /// Constructor. /// </summary> /// <param name="sopClassUid">SOP class UID.</param> /// <param name="sopInstanceUid">SOP instance UID.</param> public ReferencedSopItem(System.String sopClassUid, System.String sopInstanceUid) { _instanceState = InstanceStateEnum.InstanceCreated; _sopClassUid = sopClassUid; _sopInstanceUid = sopInstanceUid; }