// MonoGame - Copyright (C) The MonoGame Team
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
using System;
using System.Collections;
using System.Collections.Generic;
namespace Microsoft.Xna.Framework.Content.Pipeline.Graphics
{
///
/// Provides methods and properties for maintaining a vertex channel.
/// A vertex channel is a list of arbitrary data with one value for each vertex. Channels are stored inside a GeometryContent and identified by name.
///
public abstract class VertexChannel : IList, ICollection, IEnumerable
{
string name;
///
/// Allows overriding classes to implement the list, and for properties/methods in this class to access it.
///
internal abstract IList Items
{
get;
}
///
/// Gets the number of elements in the vertex channel
///
public int Count
{
get
{
return Items.Count;
}
}
///
/// Gets the type of data contained in this channel.
///
public abstract Type ElementType { get; }
///
/// Gets or sets the element at the specified index.
///
public Object this[int index]
{
get
{
return Items[index];
}
set
{
Items[index] = value;
}
}
///
/// Gets the name of the vertex channel.
///
public string Name
{
get
{
return name;
}
internal set
{
name = value;
}
}
///
/// Gets a value indicating whether access to the collection is synchronized (thread safe).
///
bool System.Collections.ICollection.IsSynchronized
{
get
{
return false;
}
}
///
/// Gets an object that can be used to synchronize access to the collection.
///
Object System.Collections.ICollection.SyncRoot
{
get
{
return this;
}
}
///
/// Gets a value indicating whether this list has a fixed size.
///
bool System.Collections.IList.IsFixedSize
{
get
{
return false;
}
}
///
/// Gets a value indicating whether this object is read-only.
///
bool System.Collections.IList.IsReadOnly
{
get
{
return false;
}
}
///
/// Creates an instance of VertexChannel.
///
/// Name of the channel.
internal VertexChannel(string name)
{
Name = name;
}
///
/// Determines whether the specified element is in the channel.
///
/// Element being searched for.
/// true if the element is present; false otherwise.
public bool Contains(Object value)
{
return Items.Contains(value);
}
///
/// Copies the elements of the channel to an array, starting at the specified index.
///
/// Array that will receive the copied channel elements.
/// Starting index for copy operation.
public void CopyTo(Array array, int index)
{
((ICollection)Items).CopyTo(array, index);
}
///
/// Gets an enumerator interface for reading channel content.
///
/// Enumeration of the channel content.
public IEnumerator GetEnumerator()
{
return Items.GetEnumerator();
}
///
/// Gets the index of the specified item.
///
/// Item whose index is to be retrieved.
/// Index of specified item.
public int IndexOf(Object value)
{
return Items.IndexOf(value);
}
///
/// Reads channel content and automatically converts it to the specified vector format.
///
/// Target vector format of the converted data.
/// The converted data.
public abstract IEnumerable ReadConvertedContent();
///
/// Adds a new element to the end of the collection.
///
/// The element to add.
/// Index of the element.
int IList.Add(Object value)
{
return Items.Add(value);
}
///
/// Removes all elements from the collection.
///
void IList.Clear()
{
Items.Clear();
}
///
/// Inserts an element into the collection at the specified position.
///
/// Index at which to insert the element.
/// The element to insert.
void IList.Insert(int index, Object value)
{
Items.Insert(index, value);
}
///
/// Inserts the range of values from the enumerable into the channel.
///
/// The zero-based index at which the new elements should be inserted.
/// The data to insert into the channel.
internal abstract void InsertRange(int index, IEnumerable data);
///
/// Removes a specified element from the collection.
///
/// The element to remove.
void IList.Remove(Object value)
{
Items.Remove(value);
}
///
/// Removes the element at the specified index position.
///
/// Index of the element to remove.
void IList.RemoveAt(int index)
{
Items.RemoveAt(index);
}
///
/// Removes a range of values from the channel.
///
/// The zero-based starting index of the range of elements to remove.
/// The number of elements to remove.
internal abstract void RemoveRange(int index, int count);
}
}