//******************************************************************************************************
// RecordHeader.cs - Gbtc
//
// Copyright © 2012, 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:
// ----------------------------------------------------------------------------------------------------
// 04/05/2012 - Mehulbhai Thakkar, Grid Protection Alliance
// Generated original version of source code.
// 12/17/2012 - Starlynn Danyelle Gilliam
// Modified Header.
//
//******************************************************************************************************
using System;
using System.Text;
namespace GSF.PQDIF.Physical
{
///
/// The header of a PQDIF . The header is part of
/// the physical structure of a PQDIF file, and contains information
/// on how to parse the as well as how to find
/// the next record.
///
public class RecordHeader
{
#region [ Members ]
// Fields
private int m_position;
private Guid m_recordSignature;
private Guid m_recordTypeTag;
private int m_headerSize;
private int m_bodySize;
private int m_nextRecordPosition;
private uint m_checksum;
private byte[] m_reserved;
#endregion
#region [ Constructors ]
///
/// Creates a new instance of the class.
///
public RecordHeader()
{
m_recordSignature = Record.Signature;
m_reserved = new byte[16];
}
///
/// Creates a new instance of the class.
///
/// The tag which identifies the type of the record.
public RecordHeader(Guid recordTypeTag)
: this()
{
m_recordTypeTag = recordTypeTag;
}
#endregion
#region [ Properties ]
///
/// Gets or sets the position of this record.
///
public int Position
{
get
{
return m_position;
}
set
{
m_position = value;
}
}
///
/// Gets or sets the record's globally unique identifier.
///
public Guid RecordSignature
{
get
{
return m_recordSignature;
}
set
{
m_recordSignature = value;
}
}
///
/// Gets or sets the type of the record which determines
/// the logical structure of the record.
///
public RecordType TypeOfRecord
{
get
{
return Record.GetRecordType(m_recordTypeTag);
}
}
///
/// Gets or sets the tag which identifies the type of the record.
///
public Guid RecordTypeTag
{
get
{
return m_recordTypeTag;
}
set
{
m_recordTypeTag = value;
}
}
///
/// Gets or sets the size of the header, in bytes.
///
public int HeaderSize
{
get
{
return m_headerSize;
}
set
{
m_headerSize = value;
}
}
///
/// Gets or sets the size of the body, in bytes.
///
public int BodySize
{
get
{
return m_bodySize;
}
set
{
m_bodySize = value;
}
}
///
/// Gets or sets the position of the next record in the PQDIF file.
/// This value is a byte offset relative to the beginning of the file.
///
public int NextRecordPosition
{
get
{
return m_nextRecordPosition;
}
set
{
m_nextRecordPosition = value;
}
}
///
/// Optional checksum (such as a 32-bit CRC)
/// of the record body to verify decompression.
///
public uint Checksum
{
get
{
return m_checksum;
}
set
{
m_checksum = value;
}
}
///
/// Reserved to fill structure to 64 bytes. Should be filled with 0.
///
public byte[] Reserved
{
get
{
return m_reserved;
}
set
{
m_reserved = value;
}
}
#endregion
#region [ Methods ]
///
/// Returns a string representation of the record header.
///
/// A string representation of the record header.
public override string ToString()
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat("Record type: {0}", TypeOfRecord);
builder.AppendLine();
builder.AppendFormat("Header size: {0}", m_headerSize);
builder.AppendLine();
builder.AppendFormat("Body size: {0}", m_bodySize);
return builder.ToString();
}
#endregion
}
}