Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ListBuildStep.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;
5 using System.Collections.Generic;
6 using System.ComponentModel;
7 using System.Linq;
8 
9 namespace SiliconStudio.BuildEngine
10 {
11  [Description("Step list")]
12  public class ListBuildStep : EnumerableBuildStep, IList<BuildStep>
13  {
14  private readonly List<BuildStep> children;
15 
16  public ListBuildStep()
17  : base(new List<BuildStep>())
18  {
19  children = (List<BuildStep>)Steps;
20  }
21 
23  : base(new List<BuildStep>(steps))
24  {
25  children = (List<BuildStep>)Steps;
26  }
27 
28  public override BuildStep Clone()
29  {
30  return new ListBuildStep(children.Select(x => x.Clone()));
31  }
32 
33  /// <inheritdoc/>
34  public override string ToString()
35  {
36  return "Build step list (" + Count + " items)";
37  }
38 
39  /// <inheritdoc/>
40  public int Count
41  {
42  get { return children.Count; }
43  }
44 
45  /// <inheritdoc/>
46  IEnumerator IEnumerable.GetEnumerator()
47  {
48  return GetEnumerator();
49  }
50 
51  /// <inheritdoc/>
52  public IEnumerator<BuildStep> GetEnumerator()
53  {
54  return children.GetEnumerator();
55  }
56 
57  public CommandBuildStep Add(Command command)
58  {
59  var commandBuildStep = new CommandBuildStep(command);
60  Add(commandBuildStep);
61  return commandBuildStep;
62  }
63 
65  {
66  var commandBuildSteps = commands.Select(x => new CommandBuildStep(x) ).ToArray();
67  foreach (var commandBuildStep in commandBuildSteps)
68  {
69  Add(commandBuildStep);
70  }
71  return commandBuildSteps;
72  }
73 
74  /// <inheritdoc/>
75  public void Add(BuildStep buildStep)
76  {
77  if (Status != ResultStatus.NotProcessed)
78  throw new InvalidOperationException("Unable to add a build step to an already processed ListBuildStep.");
79 
80  buildStep.Parent = this;
81  children.Add(buildStep);
82  }
83 
84  /// <inheritdoc/>
85  public void Clear()
86  {
87  children.Clear();
88  }
89 
90  /// <inheritdoc/>
91  public bool Contains(BuildStep item)
92  {
93  return children.Contains(item);
94  }
95 
96  /// <inheritdoc/>
97  public void CopyTo(BuildStep[] array, int arrayIndex)
98  {
99  children.CopyTo(array, arrayIndex);
100  }
101 
102  /// <inheritdoc/>
103  public bool Remove(BuildStep item)
104  {
105  item.Parent = null;
106  return children.Remove(item);
107  }
108 
109  /// <inheritdoc/>
110  public int IndexOf(BuildStep item)
111  {
112  return children.IndexOf(item);
113  }
114 
115  /// <inheritdoc/>
116  public void Insert(int index, BuildStep item)
117  {
118  item.Parent = this;
119  children.Insert(index, item);
120  }
121 
122  /// <inheritdoc/>
123  public void RemoveAt(int index)
124  {
125  children[index].Parent = null;
126  children.RemoveAt(index);
127  }
128 
129  /// <inheritdoc/>
130  public BuildStep this[int index]
131  {
132  get { return children[index]; }
133  set { children[index] = value; value.Parent = this; }
134  }
135 
136  /// <inheritdoc/>
137  bool ICollection<BuildStep>.IsReadOnly
138  {
139  get { return ((IList<BuildStep>)children).IsReadOnly; }
140  }
141  }
142 }
IEnumerable< CommandBuildStep > Add(IEnumerable< Command > commands)
A BuildStep that can spawn multiple BuildStep. Input and output tracking and merging will be performe...
void CopyTo(BuildStep[] array, int arrayIndex)
ResultStatus
Status of a command.
Definition: ResultStatus.cs:8
void Insert(int index, BuildStep item)
override BuildStep Clone()
Clone this Build Step.
CommandBuildStep Add(Command command)
ListBuildStep(IEnumerable< BuildStep > steps)
IEnumerator< BuildStep > GetEnumerator()