Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ITransactionalActionStack.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Collections.Generic;
5 
6 namespace SiliconStudio.ActionStack
7 {
8  /// <summary>
9  /// Base interface for a transactional action stack.
10  /// </summary>
11  /// <remarks>
12  /// A transactional action stack is an action stack that generates <see cref="IAggregateActionItem"/> from the action items that are added after a
13  /// transaction is started and before it is finished. A transaction can also be cancelled (undone) or discarded instead of creating an aggregate action item.
14  /// Multiple transactions can be created at the same time, each transaction that ends will become a single item of the parent transaction in progress.
15  /// </remarks>
17  {
18  /// <summary>
19  /// Creates a BeginTransaction-EndTransaction subscription.
20  /// Use it with a using statement to ensure balanced state integrity.
21  /// </summary>
22  /// <param name="name">The name given to the transaction at the end.</param>
23  /// <returns>An EndTransaction subscription.</returns>
24  /// <seealso cref="BeginTransaction"/>
25  /// <seealso cref="EndTransaction(string)"/>
26  IDisposable BeginEndTransaction(string name);
27 
28  /// <summary>
29  /// Creates a BeginTransaction-EndTransaction subscription.
30  /// Use it with a using statement to ensure balanced state integrity.
31  /// </summary>
32  /// <param name="getName">A delegate that late-evaluate the name given to the transaction at the end.</param>
33  /// <returns>Returns a end transaction subscription.</returns>
34  /// <seealso cref="BeginTransaction"/>
35  /// <seealso cref="EndTransaction(string)"/>
36  IDisposable BeginEndTransaction(Func<string> getName);
37 
38  /// <summary>
39  /// Creates a BeginTransaction-CancelTransaction transaction subscription.
40  /// Use it with a using statement to ensure balanced state integrity.
41  /// </summary>
42  /// <returns>Returns a cancel transaction subscription.</returns>
43  /// <seealso cref="BeginTransaction"/>
44  /// <seealso cref="CancelTransaction"/>
45  IDisposable BeginCancelTransaction();
46 
47  /// <summary>
48  /// Creates a BeginTransaction-DiscardTransaction transaction subscription.
49  /// Use it with a using statement to ensure balanced state integrity.
50  /// </summary>
51  /// <returns>Returns a discard transaction subscription.</returns>
52  /// <seealso cref="BeginTransaction"/>
53  /// <seealso cref="DiscardTransaction"/>
54  IDisposable BeginDiscardTransaction();
55 
56  /// <summary>
57  /// Begins a transaction. <see cref="IActionItem"/> added after a call to BeginTransaction are stored in a temporary transaction stack,
58  /// until a call to <see cref="EndTransaction(string)"/>, <see cref="CancelTransaction"/>, or <see cref="DiscardTransaction"/> is done.
59  /// </summary>
60  void BeginTransaction();
61 
62  /// <summary>
63  /// Ends a transaction started with <see cref="BeginTransaction"/>.
64  /// </summary>
65  /// <param name="displayName"></param>
66  /// <remarks>Once the transaction is ended, an aggregate action is created with all action items that were added during the transaction. This aggregate is added to the action stack.</remarks>
67  void EndTransaction(string displayName);
68 
69  /// <summary>
70  /// Ends a transaction started with <see cref="BeginTransaction"/>.
71  /// </summary>
72  /// <param name="displayName"></param>
73  /// <param name="aggregateActionItems">A function that will aggregate an enumeration of action items into a single action item.</param>
74  /// <remarks>Once the transaction is ended, an aggregate action is created with all action items that were added during the transaction. This aggregate is added to the action stack.</remarks>
75  void EndTransaction(string displayName, Func<IReadOnlyCollection<IActionItem>, IActionItem> aggregateActionItems);
76 
77  /// <summary>
78  /// Cancels a transaction started with <see cref="BeginTransaction"/>. Every action from the cancelled transaction will be undone.
79  /// </summary>
80  /// <remarks>This method will undo every action item of the transaction and then discard them.</remarks>
81  void CancelTransaction();
82 
83  /// <summary>
84  /// Discard a transaction started with <see cref="BeginTransaction"/>.
85  /// </summary>
86  /// <remarks>This method will ends the transaction and discard every action item it contains.</remarks>
87  void DiscardTransaction();
88  }
89 }
Base interface for action items.
Definition: IActionItem.cs:10
Base interface to for an action stack.
Definition: IActionStack.cs:11
Base interface for a transactional action stack.