/// <summary> /// Initializes a new instance. /// </summary> /// <param name="context">The context of the traversal process.</param> /// <param name="transitionSizeInBytes">The size of a transition in bytes.</param> /// <param name="model">The runtime model the state graph is generated for.</param> /// <param name="createModel"> /// The factory function that should be used to create instances of the <see cref="RuntimeModel" /> /// the state graph is generated for. /// </param> internal StateGraph(TraversalContext context, int transitionSizeInBytes, TExecutableModel model, CoupledExecutableModelCreator <TExecutableModel> createModel) { Requires.NotNull(context, nameof(context)); TransitionSize = transitionSizeInBytes; RuntimeModel = model; RuntimeModelCreator = createModel; _stateStorage = context.States; _transitionCapacity = context.ModelCapacity.MemoryLimitTransitions.Value; _transitionsBuffer.Resize(_transitionCapacity, zeroMemory: false); _stateMapBuffer.Resize(context.ModelCapacity.NumberOfStates * sizeof(TransitionRange), zeroMemory: false); _transitions = _transitionsBuffer.Pointer; _stateMap = (TransitionRange *)_stateMapBuffer.Pointer; }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="context">The context of the traversal process.</param> /// <param name="stateFormulas">The state formulas that can be evaluated over the generated state graph.</param> /// <param name="transitionSizeInBytes">The size of a transition in bytes.</param> /// <param name="model">The runtime model the state graph is generated for.</param> /// <param name="createModel"> /// The factory function that should be used to create instances of the <see cref="RuntimeModel" /> /// the state graph is generated for. /// </param> internal StateGraph(TraversalContext context, Formula[] stateFormulas, int transitionSizeInBytes, RuntimeModel model, Func<RuntimeModel> createModel) { Requires.NotNull(context, nameof(context)); StateFormulas = stateFormulas; TransitionSize = transitionSizeInBytes; RuntimeModel = model; RuntimeModelCreator = createModel; _stateStorage = context.States; _transitionCapacity = context.Configuration.TransitionCapacity; _transitionsBuffer.Resize(TransitionSize * _transitionCapacity, zeroMemory: false); _stateMapBuffer.Resize(context.Configuration.StateCapacity * sizeof(TransitionRange), zeroMemory: false); _transitions = _transitionsBuffer.Pointer; _stateMap = (TransitionRange*)_stateMapBuffer.Pointer; }