Skip to content

Commit

Permalink
Rename RequestState to RetrievalState
Browse files Browse the repository at this point in the history
References #21
  • Loading branch information
andreashuber-lawo committed Apr 25, 2016
1 parent 77dfaff commit 653cb87
Show file tree
Hide file tree
Showing 24 changed files with 139 additions and 139 deletions.
2 changes: 1 addition & 1 deletion Lawo.EmberPlusSharp/Glow/GlowLogInterpreter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void ApplyPayload()
this.root.Read(emberReader, this.pendingInvocations, this.streamedParameters);
this.root.WriteRequest(dummyWriter, this.streamedParameters);
this.root.SetComplete();
this.root.UpdateRequestState(true);
this.root.UpdateRetrievalState(true);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Lawo.EmberPlusSharp/Lawo.EmberPlusSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
<Compile Include="Model\InvocationCollection.cs" />
<Compile Include="Model\IStreamedParameter.cs" />
<Compile Include="Model\IStreamedParameterCollection.cs" />
<Compile Include="Model\RequestState.cs" />
<Compile Include="Model\RetrievalState.cs" />
<Compile Include="Model\DynamicRoot.cs" />
<Compile Include="Model\DynamicNodeHelper.cs" />
<Compile Include="Model\DynamicNode.cs" />
Expand Down
6 changes: 3 additions & 3 deletions Lawo.EmberPlusSharp/Model/CollectionNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public TElement this[int number]

[SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", Justification = "These are actual class names.")]
internal sealed override Element ReadNewChildContents(
EmberReader reader, ElementType actualType, Context context, out RequestState childRequestState)
EmberReader reader, ElementType actualType, Context context, out RetrievalState childRetrievalState)
{
if (ReadContentsCallback == null)
{
Expand All @@ -57,7 +57,7 @@ internal sealed override Element ReadNewChildContents(
throw new ModelException(string.Format(CultureInfo.InvariantCulture, Format, this.GetPath()));
}

return ReadContentsCallback(reader, actualType, context, out childRequestState);
return ReadContentsCallback(reader, actualType, context, out childRetrievalState);
}

[SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", Justification = "Method is not public, CA bug?")]
Expand Down Expand Up @@ -93,6 +93,6 @@ private static ReadContentsMethod GetReadContentsMethod()
}

private delegate Element ReadContentsMethod(
EmberReader reader, ElementType actualType, Context context, out RequestState childRequestState);
EmberReader reader, ElementType actualType, Context context, out RetrievalState childRetrievalState);
}
}
16 changes: 8 additions & 8 deletions Lawo.EmberPlusSharp/Model/Consumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ private async Task RetrieveChildrenAsync()
if ((await Task.WhenAny(retrieveChildrenTask, Task.Delay(this.childrenRetrievalTimeout))) !=
retrieveChildrenTask)
{
this.root.UpdateRequestState(this.root.RequestState.Equals(RequestState.Complete));
this.root.UpdateRetrievalState(this.root.RetrievalState.Equals(RetrievalState.Complete));
var firstIncompleteNode = this.root.GetFirstIncompleteChild();
var message = firstIncompleteNode == null ?
"The provider failed to send all requested elements within the specified timeout." :
Expand Down Expand Up @@ -378,14 +378,14 @@ private async Task DelayAutoSend()

private async Task<bool> SendRequestAsync()
{
var rootRequestState = this.root.UpdateRequestState(false);
var rootRetrievalState = this.root.UpdateRetrievalState(false);

if (rootRequestState.Equals(RequestState.None))
if (rootRetrievalState.Equals(RetrievalState.None))
{
// There is no guarantee that the response we received is actually an answer to the previously sent
// getDirectory request. It could just as well be a parameter value update. RequestState indicates
// whether the former or the latter happened. If RequestState == RequestState.None, we have
// received at least one new node. If RequestState != RequestState.None, no new node without
// getDirectory request. It could just as well be a parameter value update. RetrievalState indicates
// whether the former or the latter happened. If RetrievalState == RetrievalState.None, we have
// received at least one new node. If RetrievalState != RetrievalState.None, no new node without
// children has been received and consequently no new getDirectory request needs to be sent.
// Of course, in the latter case the assumption is that the provider will at some point send an
// answer to our previous getDirectory request. If it doesn't, the timeout will take care of things.
Expand All @@ -395,13 +395,13 @@ private async Task<bool> SendRequestAsync()
{
// If no answer is expected from the provider due to the request, we need to update the request
// state again to see whether there's still something missing.
rootRequestState = this.root.UpdateRequestState(false);
rootRetrievalState = this.root.UpdateRetrievalState(false);
}

await this.client.SendMessageAsync(this.emberDataMessage, stream.ToArray());
}

return !rootRequestState.Equals(RequestState.Verified);
return !rootRetrievalState.Equals(RetrievalState.Verified);
}

private void ApplyChange(MessageReceivedEventArgs args)
Expand Down
4 changes: 2 additions & 2 deletions Lawo.EmberPlusSharp/Model/DynamicNodeBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ internal DynamicNodeBase()

[SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", Justification = "Method is not public, CA bug?")]
internal sealed override Element ReadNewDynamicChildContents(
EmberReader reader, ElementType actualType, Context context, out RequestState childRequestState)
EmberReader reader, ElementType actualType, Context context, out RetrievalState childRetrievalState)
{
return DynamicNodeHelper.ReadDynamicChildContents(reader, actualType, context, out childRequestState);
return DynamicNodeHelper.ReadDynamicChildContents(reader, actualType, context, out childRetrievalState);
}
}
}
8 changes: 4 additions & 4 deletions Lawo.EmberPlusSharp/Model/DynamicNodeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ internal static Element ReadDynamicChildContents(
EmberReader reader,
ElementType actualType,
Context context,
out RequestState childRequestState)
out RetrievalState childRetrievalState)
{
switch (actualType)
{
case ElementType.Parameter:
return DynamicParameter.ReadContents(reader, actualType, context, out childRequestState);
return DynamicParameter.ReadContents(reader, actualType, context, out childRetrievalState);
case ElementType.Node:
return DynamicNode.ReadContents(reader, actualType, context, out childRequestState);
return DynamicNode.ReadContents(reader, actualType, context, out childRetrievalState);
default:
return DynamicFunction.ReadContents(reader, actualType, context, out childRequestState);
return DynamicFunction.ReadContents(reader, actualType, context, out childRetrievalState);
}
}

Expand Down
4 changes: 2 additions & 2 deletions Lawo.EmberPlusSharp/Model/DynamicRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public ReadOnlyObservableCollection<IElement> DynamicChildren
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

internal sealed override Element ReadNewDynamicChildContents(
EmberReader reader, ElementType actualType, Context context, out RequestState childRequestState)
EmberReader reader, ElementType actualType, Context context, out RetrievalState childRetrievalState)
{
return DynamicNodeHelper.ReadDynamicChildContents(reader, actualType, context, out childRequestState);
return DynamicNodeHelper.ReadDynamicChildContents(reader, actualType, context, out childRetrievalState);
}

internal sealed override bool ChangeOnlineStatus(IElement child)
Expand Down
36 changes: 18 additions & 18 deletions Lawo.EmberPlusSharp/Model/Element.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ internal bool HasChanges
}
}

internal virtual RequestState RequestState
internal virtual RetrievalState RetrievalState
{
get { return RequestState.Complete; }
get { return RetrievalState.Complete; }
set { } // Intentionally empty
}

Expand Down Expand Up @@ -199,33 +199,33 @@ internal void SetConsumerValue<T>(ref T field, T newValue, [CallerMemberName] st
}
}

internal abstract RequestState ReadContents(EmberReader reader, ElementType actualType);
internal abstract RetrievalState ReadContents(EmberReader reader, ElementType actualType);

/// <summary>Recursively reads the children of an element as they appear in the message payload and returns
/// the state of this element.</summary>
/// <remarks>
/// <para>Nodes for which an empty children collection is received are marked with
/// <see cref="RequestState.Complete"/>. The same happens if the collection only contains children we're not
/// <see cref="RetrievalState.Complete"/>. The same happens if the collection only contains children we're not
/// interested in. In all other cases, the state of the node is lowered to the lowest state of the
/// interesting children appearing in the payload.</para>
/// <para>This approach ensures that any node for which incomplete interesting children have been received will
/// be visited by <see cref="UpdateRequestState"/>. This is necessary because some providers send messages with
/// be visited by <see cref="UpdateRetrievalState"/>. This is necessary because some providers send messages with
/// payloads where the same node appears multiple times. For example, the first time the state of the node may
/// be set to <see cref="RequestState.None"/>, due to the fact that there are indirect children for which a
/// be set to <see cref="RetrievalState.None"/>, due to the fact that there are indirect children for which a
/// <code>getDirectory</code> request needs to be sent. The second time the node appears only with direct and
/// indirect children that have the state <see cref="RequestState.Complete"/>. Now the state of the node cannot
/// be set to <see cref="RequestState.Complete"/> because then no <code>getDirectory</code> requests would be
/// indirect children that have the state <see cref="RetrievalState.Complete"/>. Now the state of the node cannot
/// be set to <see cref="RetrievalState.Complete"/> because then no <code>getDirectory</code> requests would be
/// issued for the children that appeared the first time.</para>
/// <para>It follows that the state of a node cannot be set to its definitive value while its children are read.
/// Instead there needs to be a second step that visits all affected nodes and updates their state, which is
/// implemented by <see cref="UpdateRequestState"/>.</para></remarks>
internal virtual RequestState ReadChildren(EmberReader reader)
/// implemented by <see cref="UpdateRetrievalState"/>.</para></remarks>
internal virtual RetrievalState ReadChildren(EmberReader reader)
{
reader.Skip();
return RequestState.Complete;
return RetrievalState.Complete;
}

internal virtual RequestState ReadQualifiedChild(
internal virtual RetrievalState ReadQualifiedChild(
EmberReader reader, ElementType actualType, int[] path, int index)
{
const string Format =
Expand All @@ -239,20 +239,20 @@ internal virtual void ReadAdditionalFields(EmberReader reader)
}

/// <summary>Recursively updates the state of all children and returns the state of this element.</summary>
/// <remarks>Only the children with a state not equal to <see cref="RequestState.Verified"/> are visited.
/// <remarks>Only the children with a state not equal to <see cref="RetrievalState.Verified"/> are visited.
/// The state of a node is set to the lowest state of its children. If a node without children has the state
/// <see cref="RequestState.Complete"/> and does not require children, the state is lifted to
/// <see cref="RequestState.Verified"/>. In all other cases, the state is left as is.</remarks>
internal virtual RequestState UpdateRequestState(bool throwForMissingRequiredChildren)
/// <see cref="RetrievalState.Complete"/> and does not require children, the state is lifted to
/// <see cref="RetrievalState.Verified"/>. In all other cases, the state is left as is.</remarks>
internal virtual RetrievalState UpdateRetrievalState(bool throwForMissingRequiredChildren)
{
return RequestState.Verified;
return RetrievalState.Verified;
}

/// <summary>Writes the payload of a message that contains appropriate requests for all elements that require
/// one.</summary>
/// <returns><c>true</c> if a provider response is expected due to the request; otherwise <c>false</c>.
/// </returns>
/// <remarks>Recursively visits all children with a state equal to <see cref="RequestState.None"/>, writes
/// <remarks>Recursively visits all children with a state equal to <see cref="RetrievalState.None"/>, writes
/// a getDirectory command for nodes that do not yet have children or a subscribe command for stream parameters
/// and changes their state accordingly.</remarks>
internal virtual bool WriteRequest(EmberWriter writer, IStreamedParameterCollection streamedParameters)
Expand Down
4 changes: 2 additions & 2 deletions Lawo.EmberPlusSharp/Model/Element1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ internal static TMostDerived Construct(Context context)
}

internal static TMostDerived ReadContents(
EmberReader reader, ElementType actualType, Context context, out RequestState requestState)
EmberReader reader, ElementType actualType, Context context, out RetrievalState retrievalState)
{
var result = Construct(context);
requestState = result.ReadContents(reader, actualType);
retrievalState = result.ReadContents(reader, actualType);
return result;
}

Expand Down
38 changes: 19 additions & 19 deletions Lawo.EmberPlusSharp/Model/ElementWithSchemas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ namespace Lawo.EmberPlusSharp.Model
public abstract class ElementWithSchemas<TMostDerived> : Element<TMostDerived>, IElementWithSchemas
where TMostDerived : ElementWithSchemas<TMostDerived>
{
/// <summary>See <see cref="RequestState"/> for more information.</summary>
/// <remarks>This field and its sibling <see cref="offlineRequestState"/> are modified by the following
/// <summary>See <see cref="RetrievalState"/> for more information.</summary>
/// <remarks>This field and its sibling <see cref="offlineRetrievalState"/> are modified by the following
/// methods, which are directly or indirectly called from
/// <see cref="Consumer{T}.CreateAsync(Lawo.EmberPlusSharp.S101.S101Client)"/>:
/// <list type="number">
/// <item><see cref="Element.UpdateRequestState"/></item>
/// <item><see cref="Element.UpdateRetrievalState"/></item>
/// <item><see cref="Element.WriteRequest"/></item>
/// <item><see cref="Element.ReadChildren"/></item>
/// <item><see cref="Element.AreRequiredChildrenAvailable"/></item>
Expand All @@ -40,8 +40,8 @@ public abstract class ElementWithSchemas<TMostDerived> : Element<TMostDerived>,
/// are changed at once in a large tree.</item>
/// </list>
/// </remarks>
private RequestState offlineRequestState = RequestState.Complete;
private RequestState onlineRequestState;
private RetrievalState offlineRetrievalState = RetrievalState.Complete;
private RetrievalState onlineRetrievalState;

private IReadOnlyList<string> schemaIdentifiers;

Expand All @@ -56,59 +56,59 @@ public IReadOnlyList<string> SchemaIdentifiers

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

internal ElementWithSchemas(RequestState onlineRequestState)
internal ElementWithSchemas(RetrievalState onlineRetrievalState)
{
this.onlineRequestState = onlineRequestState;
this.onlineRetrievalState = onlineRetrievalState;
}

/// <summary>Gets or sets the request state.</summary>
/// <summary>Gets or sets the retrieval state.</summary>
/// <remarks>This implementation has nothing to do with schemas. However, it so happens that this member has the
/// same behavior for all subclasses (parameters, nodes and matrices). If this fact ever changes, it probably
/// makes sense to move this member to its own base class (named e.g. RequestedElement).</remarks>
internal override RequestState RequestState
internal override RetrievalState RetrievalState
{
get
{
return this.IsOnline ? this.onlineRequestState : this.offlineRequestState;
return this.IsOnline ? this.onlineRetrievalState : this.offlineRetrievalState;
}

set
{
if (this.IsOnline)
{
this.onlineRequestState = value;
this.onlineRetrievalState = value;
}
else
{
this.offlineRequestState = value;
this.offlineRetrievalState = value;
}
}
}

internal override RequestState UpdateRequestState(bool throwForMissingRequiredChildren)
internal override RetrievalState UpdateRetrievalState(bool throwForMissingRequiredChildren)
{
if (!this.IsOnline || (this.RequestState.Equals(RequestState.Complete) &&
if (!this.IsOnline || (this.RetrievalState.Equals(RetrievalState.Complete) &&
this.AreRequiredChildrenAvailable(throwForMissingRequiredChildren)))
{
this.RequestState = base.UpdateRequestState(throwForMissingRequiredChildren);
this.RetrievalState = base.UpdateRetrievalState(throwForMissingRequiredChildren);
}

return this.RequestState;
return this.RetrievalState;
}

internal override void SetComplete()
{
this.RequestState = RequestState.Complete;
this.RetrievalState = RetrievalState.Complete;
base.SetComplete();
}

internal void WriteCommandCollection(
EmberWriter writer, GlowCommandNumber commandNumber, RequestState requestState)
EmberWriter writer, GlowCommandNumber commandNumber, RetrievalState retrievalState)
{
writer.WriteStartApplicationDefinedType(GlowElementCollection.Element.OuterId, GlowCommand.InnerNumber);
writer.WriteValue(GlowCommand.Number.OuterId, (long)commandNumber);
writer.WriteEndContainer();
this.RequestState = requestState;
this.RetrievalState = retrievalState;
}

internal void ReadSchemaIdentifiers(EmberReader reader)
Expand Down
2 changes: 1 addition & 1 deletion Lawo.EmberPlusSharp/Model/EnumParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ internal sealed override IReadOnlyList<KeyValuePair<string, int>> EnumMapCore
set { this.impl.EnumMapCore = value; }
}

internal sealed override RequestState ReadContents(EmberReader reader, ElementType actualType)
internal sealed override RetrievalState ReadContents(EmberReader reader, ElementType actualType)
{
return this.impl.ReadContents(base.ReadContents, reader, actualType);
}
Expand Down
Loading

0 comments on commit 653cb87

Please sign in to comment.