T
- The type of motion returned by evaluation.TDerivative
- The type of the derivatives returned by evaluation.public abstract class MotionEvaluator2<T,TDerivative> extends Function3<JulianDate,T,TDerivative> implements IEvaluator1<T>, IIsTimeVarying
JulianDate
and produce
Motion2
.Modifier | Constructor and Description |
---|---|
protected |
MotionEvaluator2(EvaluatorGroup group)
Initializes a new instance.
|
protected |
MotionEvaluator2(MotionEvaluator2<T,TDerivative> existingInstance,
CopyContext context)
Initializes a new instance as a copy of an existing instance.
|
Modifier and Type | Method and Description |
---|---|
T |
evaluate(JulianDate date)
Evaluates the function.
|
abstract Motion2<T,TDerivative> |
evaluate(JulianDate date,
int order)
Evaluates the function.
|
DateMotionCollection2<T,TDerivative> |
evaluate(JulianDate start,
JulianDate stop,
Duration step,
int order)
Evaluates this evaluator at a specified fixed step over the specified interval.
|
DateMotionCollection2<T,TDerivative> |
evaluate(JulianDate start,
JulianDate stop,
Duration step,
int order,
ITrackCalculationProgress tracker)
Evaluates this evaluator at a specified fixed step over the specified interval.
|
DateMotionCollection2<T,TDerivative> |
evaluate(TimeInterval interval,
Duration step,
int order)
Evaluates this evaluator at a specified fixed step over the specified interval.
|
DateMotionCollection2<T,TDerivative> |
evaluate(TimeInterval interval,
Duration step,
int order,
ITrackCalculationProgress tracker)
Evaluates this evaluator at a specified fixed step over the specified interval.
|
TimeIntervalCollection |
getAvailabilityIntervals()
Gets a
TimeIntervalCollection over which data is available. |
abstract TimeIntervalCollection |
getAvailabilityIntervals(TimeIntervalCollection consideredIntervals)
Gets the intervals over which data is available.
|
IEvaluator |
getCachingWrapper()
Gets a version of this evaluator that caches the previously computed value so that if it is evaluated
twice at the same date the computation is done only once.
|
EvaluatorGroup |
getGroup()
Gets the group that contains this evaluator.
|
abstract boolean |
getIsTimeVarying()
Gets a value indicating whether or not the value of this evaluator changes with time.
|
abstract boolean |
isAvailable(JulianDate date)
Determines if valid data is available for the given
JulianDate . |
abstract void |
updateEvaluatorReferences(CopyContext context)
Updates the evaluator references held by this object using the reference-to-reference
mapping in the specified
CopyContext . |
clone, dispose, dispose, getIsThreadSafe, getNextSampleSuggestion
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getIsThreadSafe
clone
close, dispose
protected MotionEvaluator2(@Nonnull EvaluatorGroup group)
group
- The group that contains this evaluator.ArgumentNullException
- Thrown when group
is null
.protected MotionEvaluator2(@Nonnull MotionEvaluator2<T,TDerivative> existingInstance, @Nonnull CopyContext context)
See ICloneWithContext.clone(CopyContext)
for more information about how to implement this constructor
in a derived class.
existingInstance
- The existing instance to copy.context
- A CopyContext
that controls the depth of the copy.ArgumentNullException
- Thrown when existingInstance
or context
is null
.public abstract void updateEvaluatorReferences(CopyContext context)
CopyContext
.
The following example shows how to implement this method for an evaluator that contains a nested evaluator:
@Override
public final void updateEvaluatorReferences(CopyContext context) {
m_nestedEvaluator = context.updateReference(m_nestedEvaluator);
}
This method is called by EvaluatorGroup
and usually does not need to be
called directly by users. EvaluatorGroup
uses this method to replace references
to shared evaluators with references to caching versions of the evaluators.
To implement this method, call CopyContext.updateReference(T)
on each evaluator reference
held by your evaluator and assign the return value back to the field.
updateEvaluatorReferences
in interface IEvaluator
context
- The context that specifies the reference mapping.public abstract TimeIntervalCollection getAvailabilityIntervals(TimeIntervalCollection consideredIntervals)
getAvailabilityIntervals
in interface IAvailability
consideredIntervals
- The intervals over which availability information is needed. Note that the returned availability
intervals may indicate availability outside of these intervals of consideration.public abstract boolean isAvailable(@Nonnull JulianDate date)
JulianDate
.isAvailable
in interface IAvailability
date
- The date for which to check availability.true
if valid data is available for this date; otherwise false
.public abstract boolean getIsTimeVarying()
false
, the evaluator is assumed to return the same value for any
input JulianDate
.getIsTimeVarying
in interface IIsTimeVarying
public final EvaluatorGroup getGroup()
getGroup
in interface IEvaluator
public IEvaluator getCachingWrapper()
This method is called by EvaluatorGroup
to create a caching version of an evaluator
that is shared between multiple computations.
To implement this method in your own evaluator, construct and return a caching version of the evaluator's base class.
For example, if your evaluator implements IEvaluator1
directly, return an instance of
CachingEvaluator
. In many cases, such as when implementing a PointEvaluator
this method does not need to be overridden because the default implementation returns an appropriate
caching wrapper already. If you do not want the last value computed by your evaluator to ever be cached, or
if your evaluator does its own caching internally, this method can return this
.
Shows an example implementation in an evaluator that implements IEvaluator1
directly, where T is double.
@Override
public IEvaluator getCachingWrapper() {
return new CachingEvaluator<Double>(this);
}
getCachingWrapper
in interface IEvaluator
this
should be returned by this method.@Nonnull public final TimeIntervalCollection getAvailabilityIntervals()
TimeIntervalCollection
over which data is available.
If the availability interval is infinite, this returns
Infinite
(get
).
It is recommended that you call MotionEvaluator2.isAvailable(agi.foundation.time.JulianDate)
to determine availability instead of
calling this method and checking for yourself.
@Nonnull public abstract Motion2<T,TDerivative> evaluate(@Nonnull JulianDate date, int order)
For information about the specific function evaluated by this evaluator, see the documentation for the method that was used to create this evaluator.
Once created, an evaluator will ignore changes made to the object(s) from which it was created.
In other words, this method will always return the same result for a given date
regardless of changes made to other objects in the system. You should create a new evaluator
after making changes to definitional objects in order for those changes to be reflected in the results.
evaluate
in class Function3<JulianDate,T,TDerivative>
date
- The value with which to evaluate the function.order
- The target order to evaluate. Passing 0 evaluates the value only.
Passing 1 evaluates the value and its derivative, etc. If necessary a
result of lower or even higher order than the target may be returned.public T evaluate(@Nonnull JulianDate date)
For information about the specific function evaluated by this evaluator, see the documentation for the method that was used to create this evaluator.
Once created, an evaluator will ignore changes made to the object(s) from which it was created.
In other words, this method will always return the same result for a given JulianDate
regardless of changes made to other objects in the system. You should create a new evaluator
after making changes to definitional objects in order for those changes to be reflected in the results.
evaluate
in interface IEvaluator1<T>
evaluate
in class Function3<JulianDate,T,TDerivative>
date
- The value with which to evaluate the function.@Nonnull public final DateMotionCollection2<T,TDerivative> evaluate(@Nonnull JulianDate start, @Nonnull JulianDate stop, @Nonnull Duration step, int order)
This method takes advantage of the ThreadingPolicy
to improve performance.
The first date in the returned collection will be start
. The last date
in the collection will be stop
, so the difference between the
second-to-last date and the last date may be less than step
.
Also, these dates will always be present in the returned collection even if the duration
between them is less than step
.
start
- The start of the interval over which to evaluate.stop
- The end of the interval over which to evaluate.step
- The step size with which to sample this evaluator.order
- The target order to evaluate. Passing 0 evaluates the value only.
Passing 1 evaluates the value and its derivative, etc. If necessary a
result of lower or even higher order than the target may be returned.public final DateMotionCollection2<T,TDerivative> evaluate(@Nonnull JulianDate start, @Nonnull JulianDate stop, @Nonnull Duration step, int order, @Nullable ITrackCalculationProgress tracker)
This method takes advantage of the ThreadingPolicy
to improve performance.
The first date in the returned collection will be start
. The last date
in the collection will be stop
, so the difference between the
second-to-last date and the last date may be less than step
.
Also, these dates will always be present in the returned collection even if the duration
between them is less than step
.
start
- The start of the interval over which to evaluate.stop
- The end of the interval over which to evaluate.step
- The step size with which to sample this evaluator.order
- The target order to evaluate. Passing 0 evaluates the value only.
Passing 1 evaluates the value and its derivative, etc. If necessary a
result of lower or even higher order than the target may be returned.tracker
- The object to which progress is reported and that is able to cancel this operation before it is complete, or null
.null
if the evaluation was canceled.@Nonnull public final DateMotionCollection2<T,TDerivative> evaluate(TimeInterval interval, @Nonnull Duration step, int order)
This method takes advantage of the ThreadingPolicy
to improve performance.
If the start date of the interval is included in the interval
(IsStartIncluded
(get
)), the first date in the collection will be
the start date of the interval. If it is not included, the first date in the collection
will be step
seconds later. If the stop date of the interval is
included in the interval (IsStopIncluded
(get
)), the last date in the
collection will be the stop date of the interval. If it is not included, the last date
in the collection will be up to step
seconds before the stop date.
If neither the start nor stop date are included, and the interval is shorter than
step
, the returned collection will be empty.
interval
- The interval over which to evaluate.step
- The step size with which to sample this evaluator.order
- The target order to evaluate. Passing 0 evaluates the value only.
Passing 1 evaluates the value and its derivative, etc. If necessary a
result of lower or even higher order than the target may be returned.public final DateMotionCollection2<T,TDerivative> evaluate(TimeInterval interval, @Nonnull Duration step, int order, @Nullable ITrackCalculationProgress tracker)
This method takes advantage of the ThreadingPolicy
to improve performance.
If the start date of the interval is included in the interval
(IsStartIncluded
(get
)), the first date in the collection will be
the start date of the interval. If it is not included, the first date in the collection
will be step
seconds later. If the stop date of the interval is
included in the interval (IsStopIncluded
(get
)), the last date in the
collection will be the stop date of the interval. If it is not included, the last date
in the collection will be up to step
seconds before the stop date.
If neither the start nor stop date are included, and the interval is shorter than
step
, the returned collection will be empty.
interval
- The interval over which to evaluate.step
- The step size with which to sample this evaluator.order
- The target order to evaluate. Passing 0 evaluates the value only.
Passing 1 evaluates the value and its derivative, etc. If necessary a
result of lower or even higher order than the target may be returned.tracker
- The object to which progress is reported and that is able to cancel this operation before it is complete, or null
.null
if the evaluation was canceled.