//******************************************************************************************************
// BufferBlockMeasurement.cs - Gbtc
//
// Copyright © 2010, Grid Protection Alliance. All Rights Reserved.
//
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may
// not use this file except in compliance with the License. You may obtain a copy of the License at:
//
// http://www.opensource.org/licenses/MIT
//
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
// License for the specific language governing permissions and limitations.
//
// Code Modification History:
// ----------------------------------------------------------------------------------------------------
// 01/17/2013 - J. Ritchie Carroll
// Generated original version of source code.
//
//******************************************************************************************************
using System;
namespace GSF.TimeSeries
{
///
/// Represents a byte buffer that can be transported through the system as a .
///
public class BufferBlockMeasurement : Measurement
{
#region [ Members ]
// Members
private byte[] m_buffer;
private readonly int m_length;
#endregion
#region [ Constructors ]
///
/// Creates a new .
///
public BufferBlockMeasurement()
{
// Value of measurement should be indeterminate since this a buffer
base.Value = double.NaN;
}
///
/// Creates a new from an existing buffer.
///
/// is null.
///
/// or is less than 0 -or-
/// and will exceed length.
///
public BufferBlockMeasurement(byte[] buffer, int startIndex, int length)
: this()
{
// Validate buffer parameters
buffer.ValidateParameters(startIndex, length);
// We don't hold on to source buffer (we don't own it), so we instantiate a new one
m_buffer = new byte[length];
// Copy buffer contents onto our local buffer
System.Buffer.BlockCopy(buffer, startIndex, m_buffer, 0, length);
m_length = length;
}
#endregion
#region [ Properties ]
///
/// Cached buffer image.
///
public byte[] Buffer
{
get
{
return m_buffer;
}
}
///
/// Valid length of cached buffer image.
///
public int Length
{
get
{
return m_length;
}
}
#endregion
}
}