Esempio n. 1
0
        /// <inheritdoc />
        public void Assign(Snapshot snapshot, MemoryPath path, MemoryEntry value, bool forceStrongWrite)
        {
            if (snapshot.AssignInfo == null)
            {
                snapshot.AssignInfo = new AssignInfo();
            }
            MemoryIndexModificationList pathModifications = snapshot.AssignInfo.GetOrCreatePathModification(path);

            // Collecting all sources of the data
            MemoryEntryCollector entryCollector = new MemoryEntryCollector(snapshot);

            entryCollector.ProcessRootMemoryEntry(value);

            // Collecting all locations where to assign into
            TreeIndexCollector treeCollector = new TreeIndexCollector(snapshot);

            treeCollector.PostProcessAliases = true;
            treeCollector.ProcessPath(path);

            // Provides an assign operation
            AssignWorker worker = new AssignWorker(Factories, snapshot, entryCollector, treeCollector, pathModifications);

            worker.ForceStrongWrite = forceStrongWrite;
            worker.Assign();
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AssignWorker"/> class.
        /// </summary>
        /// <param name="factories">The factories.</param>
        /// <param name="snapshot">The snapshot.</param>
        /// <param name="memoryEntryCollector">The memory entry collector.</param>
        /// <param name="treeCollector">The tree collector.</param>
        /// <param name="pathModifications">The path modifications.</param>
        public AssignWorker(ModularMemoryModelFactories factories, Snapshot snapshot, MemoryEntryCollector memoryEntryCollector,
                            TreeIndexCollector treeCollector, MemoryIndexModificationList pathModifications)
            : base(factories, snapshot, treeCollector, pathModifications)
        {
            this.memoryEntryCollector = memoryEntryCollector;

            ForceStrongWrite = false;
            AssignAliasesIntoCollectedIndexes = false;
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AbstractAssignWorker"/> class.
        /// </summary>
        /// <param name="factories">The factories.</param>
        /// <param name="snapshot">The snapshot.</param>
        /// <param name="treeCollector">The tree collector.</param>
        /// <param name="pathModifications">The path modifications.</param>
        public AbstractAssignWorker(ModularMemoryModelFactories factories, Snapshot snapshot,
                                    TreeIndexCollector treeCollector, MemoryIndexModificationList pathModifications)
        {
            Factories = factories;

            this.Snapshot          = snapshot;
            this.treeCollector     = treeCollector;
            this.PathModifications = pathModifications;

            this.Structure = snapshot.Structure.Writeable;
            this.Data      = snapshot.CurrentData.Writeable;
        }
Esempio n. 4
0
        /// <inheritdoc />
        public void Assign(Snapshot snapshot, MemoryPath path, MemoryEntry value, bool forceStrongWrite)
        {
            if (snapshot.AssignInfo == null)
            {
                snapshot.AssignInfo = new AssignInfo();
            }
            MemoryIndexModificationList pathModifications = snapshot.AssignInfo.GetOrCreatePathModification(path);

            List <Tuple <MemoryIndex, HashSet <Value> > > valuesToAssign = new List <Tuple <MemoryIndex, HashSet <Value> > >();

            // Prepares locations and values to assign
            foreach (var item in pathModifications.Modifications)
            {
                MemoryIndex             index             = item.Key;
                MemoryIndexModification indexModification = item.Value;

                HashSet <Value> values = new HashSet <Value>();
                valuesToAssign.Add(new Tuple <MemoryIndex, HashSet <Value> >(index, values));

                if (indexModification.IsCollectedIndex)
                {
                    CollectionMemoryUtils.AddAll(values, value.PossibleValues);
                }

                // Loads all other datasources where to get additional values to assign - unknown indexes.
                foreach (var datasource in indexModification.Datasources)
                {
                    MemoryEntry entry;
                    if (datasource.SourceSnapshot.Infos.Readonly.TryGetMemoryEntry(datasource.SourceIndex, out entry))
                    {
                        CollectionMemoryUtils.AddAll(values, entry.PossibleValues);
                    }
                }
            }

            // Assigns values to locations
            foreach (var item in valuesToAssign)
            {
                MemoryIndex     index  = item.Item1;
                HashSet <Value> values = item.Item2;

                MemoryEntry entry = new MemoryEntry(values);
                snapshot.Infos.Writeable.SetMemoryEntry(index, entry);
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AliasWorker"/> class.
 /// </summary>
 /// <param name="factories">The factories.</param>
 /// <param name="snapshot">The snapshot.</param>
 /// <param name="treeCollector">The tree collector.</param>
 /// <param name="pathModifications">The path modifications.</param>
 public AliasWorker(ModularMemoryModelFactories factories, Snapshot snapshot, TreeIndexCollector treeCollector, MemoryIndexModificationList pathModifications)
     : base(factories, snapshot, treeCollector, pathModifications)
 {
     EntryCollector = new MemoryEntryCollector(snapshot);
 }