112 lines
3.6 KiB
C#
112 lines
3.6 KiB
C#
/*
|
|
Math.Operation.cs
|
|
|
|
24 November 2009 - Adapted from old Dave codebase to generic DTS utility.
|
|
|
|
$Log: Math.Operation.cs,v $
|
|
Revision 1.3 2007/03/28 15:58:55 Paul Hrissikopoulos
|
|
Fixed erroneous error-checking in Domain accessor.
|
|
|
|
Revision 1.2 2007/02/05 17:17:08 Paul Hrissikopoulos
|
|
Finished installing generic channel math framework + basic calculus operations.
|
|
|
|
Revision 1.1 2007/02/02 22:34:09 Paul Hrissikopoulos
|
|
Added framework for DAVE channel math operators.
|
|
|
|
Copyright © 2007
|
|
Diversified Technical Systems, Inc.
|
|
All Rights Reserved
|
|
*/
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using DTS.Common.Utilities;
|
|
|
|
namespace DTS.Common.Utilities.Math
|
|
{
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// <summary>
|
|
/// Representation of a generic operation that maps a domain to a range.
|
|
/// </summary>
|
|
///
|
|
/// <typeparam name="DomainType">
|
|
/// The input data type.
|
|
/// </typeparam>
|
|
///
|
|
/// <typeparam name="RangeType">
|
|
/// The output data type.
|
|
/// </typeparam>
|
|
///
|
|
public abstract class Operation<DomainType, RangeType>
|
|
: Exceptional
|
|
{
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// <summary>
|
|
/// Get/set the domain of the differentiation.
|
|
/// </summary>
|
|
public DomainType Domain
|
|
{
|
|
get
|
|
{
|
|
try
|
|
{
|
|
if (null == domain)
|
|
throw new NullReferenceException("value has not been set");
|
|
else return domain;
|
|
}
|
|
|
|
catch (System.Exception ex)
|
|
{
|
|
throw new Exception("encountered problem getting Domain property", ex);
|
|
}
|
|
}
|
|
|
|
set
|
|
{
|
|
try
|
|
{
|
|
if (null == value)
|
|
throw new ArgumentNullException("attempted to set value to null reference");
|
|
else domain = value;
|
|
}
|
|
|
|
catch (System.Exception ex)
|
|
{
|
|
throw new Exception("encountered problem setting Domain property", ex);
|
|
}
|
|
}
|
|
}
|
|
private DomainType domain;
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// <summary>
|
|
/// Get the result of the operation.
|
|
/// </summary>
|
|
public abstract RangeType Range { get; }
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// <summary>
|
|
/// Initialize an instance of the Math.Operation class. As a matter of style,
|
|
/// a domain is required for object creation.
|
|
/// </summary>
|
|
///
|
|
/// <param name="domain">
|
|
/// The "DomainType" domain of this mathematical operation.
|
|
/// </param>
|
|
///
|
|
public Operation(DomainType domain)
|
|
{
|
|
try { Domain = domain; }
|
|
catch (System.Exception ex)
|
|
{
|
|
throw new Exception("encountered problem constructing Math.Operation", ex);
|
|
}
|
|
}
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
}
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
}
|