public class NumericalPropagatorState extends Object implements ITimeBasedState, IEquatableDefinition
state
representing every propagated value in a particular
NumericalPropagator
.Modifier | Constructor and Description |
---|---|
|
NumericalPropagatorState(double[] state,
JulianDate currentDate,
NumericalPropagatorState oldState)
|
|
NumericalPropagatorState(JulianDate epoch,
Iterable<? extends PropagationStateElement> integrationElements,
Iterable<? extends AuxiliaryStateElement> auxiliaryElements)
Initialize a new instance.
|
|
NumericalPropagatorState(JulianDate epoch,
Iterable<? extends PropagationStateElement> integrationElements,
Iterable<? extends AuxiliaryStateElement> auxiliaryElements,
EvaluatorGroup group)
Initialize a new instance.
|
protected |
NumericalPropagatorState(NumericalPropagatorState existingInstance,
CopyContext context)
Initializes a new instance as a copy of an existing instance.
|
Modifier and Type | Method and Description |
---|---|
Object |
clone(CopyContext context)
Clones this object using the specified context.
|
List<String> |
getAuxiliaryElements()
Gets names of the auxiliary elements.
|
List<String> |
getAvailableElements()
Gets the names of all of the elements in this state.
|
PropagationStateConverter |
getConverter()
Gets the
PropagationStateConverter . |
JulianDate |
getCurrentDate()
Gets the
JulianDate that this state is valid. |
double[] |
getCurrentState()
Gets a copy of the raw state.
|
int |
getDefinitionHashCode()
Gets a hash code representing the definition of this object.
|
JulianDate |
getEpoch()
Gets the epoch that the propagated started from.
|
List<String> |
getIntegrationElements()
Gets names of the integration elements.
|
boolean |
getIsThreadSafe()
Gets a value indicating whether the methods on this instance are safe to call from
multiple threads simultaneously.
|
<T> Motion1<T> |
getMotion(String elementIdentification)
Gets the
Motion1 stored in this state specified by the elementIdentification . |
Motion1<double[]> |
getMotionOfDoubleArray(String elementIdentification)
Gets the motion of the specified
elementIdentification as an array of doubles. |
PropagationEvaluationInformation |
getPropagationParameter()
Gets the
PropagationEvaluationInformation based on the CurrentState (get ), Epoch (get ),
and CurrentDate (get / set ) of this state. |
<T> T |
getValue(String elementIdentification)
Gets the value specified by the
elementIdentification . |
boolean |
isSameDefinition(Object other)
Determines if this object has the same definition as another object.
|
<T> void |
modifyMotion(String elementIdentification,
Motion1<T> newValue)
Modifies this instance of
ITimeBasedState with the Motion1 of the
specified elementIdentification updated. |
<T> void |
modifyValue(String elementIdentification,
T newValue)
|
void |
setCurrentDate(JulianDate value)
Sets the
JulianDate that this state is valid. |
String |
toString()
Returns a string representation of the object.
|
public NumericalPropagatorState(@Nonnull double[] state, @Nonnull JulianDate currentDate, @Nonnull NumericalPropagatorState oldState)
oldState
except for the
CurrentState
(get
) and CurrentDate
(get
/ set
).state
- The new current state.currentDate
- The date of the current state.oldState
- The state to use to initialize all other properties.public NumericalPropagatorState(@Nonnull JulianDate epoch, @Nonnull Iterable<? extends PropagationStateElement> integrationElements, @Nonnull Iterable<? extends AuxiliaryStateElement> auxiliaryElements)
epoch
- The time at which the initial values of the elements are valid at.integrationElements
- The PropagationStateElement
that will be propagated.auxiliaryElements
- The AuxiliaryStateElement
that will be computed along the
integrationElements
during propagation.public NumericalPropagatorState(@Nonnull JulianDate epoch, @Nonnull Iterable<? extends PropagationStateElement> integrationElements, @Nonnull Iterable<? extends AuxiliaryStateElement> auxiliaryElements, @Nonnull EvaluatorGroup group)
epoch
- The time at which the initial values of the elements are valid at.integrationElements
- The PropagationStateElement
that will be propagated.auxiliaryElements
- The AuxiliaryStateElement
that will be computed along the
integrationElements
during propagation.group
- The EvaluatorGroup
to use when creating this state.protected NumericalPropagatorState(@Nonnull NumericalPropagatorState 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 final Object clone(CopyContext context)
This method should be implemented to call a copy constructor on the class of the
object being cloned. The copy constructor should take the CopyContext
as a parameter
in addition to the existing instance to copy. The copy constructor should first call
CopyContext.addObjectMapping(T, T)
to identify the newly constructed instance
as a copy of the existing instance. It should then copy all fields, using
CopyContext.updateReference(T)
to copy any reference fields.
A typical implementation of ICloneWithContext
:
public static class MyClass implements ICloneWithContext {
public MyClass(MyClass existingInstance, CopyContext context) {
context.addObjectMapping(existingInstance, this);
someReference = context.updateReference(existingInstance.someReference);
}
@Override
public final Object clone(CopyContext context) {
return new MyClass(this, context);
}
private Object someReference;
}
In general, all fields that are reference types should be copied with a call to
CopyContext.updateReference(T)
. There are a couple of exceptions:
If one of these exceptions applies, the CopyContext
should be given an opportunity
to update the reference before the reference is copied explicitly. Use
CopyContext.updateReference(T)
to update the reference. If CopyContext.updateReference(T)
returns
the original object, indicating that the context does not have a replacement registered,
then copy the object manually by invoking a Clone method, a copy constructor, or by manually
constructing a new instance and copying the values.
alwaysCopy = context.updateReference(existingInstance.alwaysCopy);
if (existingInstance.alwaysCopy != null && alwaysCopy == existingInstance.alwaysCopy) {
alwaysCopy = (AlwaysCopy) existingInstance.alwaysCopy.clone(context);
}
If you are implementing an evaluator (a class that implements IEvaluator
), the
IEvaluator.updateEvaluatorReferences(agi.foundation.infrastructure.CopyContext)
method shares some responsibilities with the
copy context constructor. Code duplication can be avoided by doing the following:
CopyContext.updateReference(T)
. You should still call CopyContext.updateReference(T)
on any references to
non-evaluators.
IEvaluator.updateEvaluatorReferences(agi.foundation.infrastructure.CopyContext)
as the last line in the constructor and pass it the
same CopyContext
passed to the constructor.
IEvaluator.updateEvaluatorReferences(agi.foundation.infrastructure.CopyContext)
as normal. See the reference documentation for
IEvaluator.updateEvaluatorReferences(agi.foundation.infrastructure.CopyContext)
for more information on implementing that method.
public MyClass(MyClass existingInstance, CopyContext context) {
super(existingInstance, context);
someReference = context.updateReference(existingInstance.someReference);
evaluatorReference = existingInstance.evaluatorReference;
updateEvaluatorReferences(context);
}
@Override
public void updateEvaluatorReferences(CopyContext context) {
evaluatorReference = context.updateReference(evaluatorReference);
}
@Override
public Object clone(CopyContext context) {
return new MyClass(this, context);
}
private Object someReference;
private IEvaluator evaluatorReference;
clone
in interface ICloneWithContext
context
- The context to use to perform the copy.public final boolean isSameDefinition(Object other)
This method is very similar to Object.equals(Object)
except that it explicitly considers
the "definitions" of the two objects for objects that do not typically act like values. The definition of
an object typically includes all of the fields of the object.
isSameDefinition
in interface IEquatableDefinition
other
- The other instance to compare to this one.true
if this object has the same definition as the specified one.
false
if the other object is null
, a different type
than this one, or if this object and the specified one have different definitions.public final int getDefinitionHashCode()
This method is very similar to Object.hashCode()
except that it explicitly includes
the "definition" of the object even if the object does not typically act like a value. The definition of
an object typically includes all of the fields of the object. The value returned by this method should
NOT change. This means that two objects for which NumericalPropagatorState.isSameDefinition(java.lang.Object)
returns true
will not necessarily have the same hash code if one or the other was changed after the hash code was first
obtained.
getDefinitionHashCode
in interface IEquatableDefinition
public final boolean getIsThreadSafe()
If this property is true
, all methods and properties are guaranteed to be thread safe.
Conceptually, an object that returns true
for this method acts as if there is a lock
protecting each method and property such that only one thread at a time can be inside any method or
property in the class. In reality, such locks are generally not used and are in fact discouraged. However,
the user must not experience any exceptions or inconsistent behavior that would not be experienced if such
locks were used.
If this property is false
, the behavior when using this class from multiple threads
simultaneously is undefined and may include inconsistent results and exceptions. Clients wishing to use
multiple threads should call CopyForAnotherThread.copy(T)
to get a separate instance of the
object for each thread.
getIsThreadSafe
in interface IThreadAware
public final <T> T getValue(String elementIdentification)
elementIdentification
.getValue
in interface ITimeBasedState
T
- The type of the stored value (Cartesian
, double
, etc...).elementIdentification
- The name of the value in this state.elementIdentification
in this state.public final <T> void modifyValue(String elementIdentification, T newValue)
modifyValue
in interface ITimeBasedState
T
- The type that the value described by the elementIdentification
is.elementIdentification
- The name of the element to change.newValue
- The new value for the elementIdentification
.@Nonnull public final <T> Motion1<T> getMotion(String elementIdentification)
Motion1
stored in this state specified by the elementIdentification
.public final <T> void modifyMotion(String elementIdentification, @Nonnull Motion1<T> newValue)
ITimeBasedState
with the Motion1
of the
specified elementIdentification
updated.modifyMotion
in interface ITimeBasedState
T
- The type that the Motion1
described by the elementIdentification
is.elementIdentification
- The name of the element to change.newValue
- The new values for the elementIdentification
.@Nonnull public final JulianDate getCurrentDate()
JulianDate
that this state is valid.getCurrentDate
in interface ITimeBasedState
public final void setCurrentDate(@Nonnull JulianDate value)
JulianDate
that this state is valid.setCurrentDate
in interface ITimeBasedState
public final List<String> getAvailableElements()
getAvailableElements
in interface ITimeBasedState
@Nonnull public final PropagationEvaluationInformation getPropagationParameter()
PropagationEvaluationInformation
based on the CurrentState
(get
), Epoch
(get
),
and CurrentDate
(get
/ set
) of this state. This is useful for when you need to evaluate an
evaluator
outside of propagation that was parameterized in a NumericalPropagator
.@Nonnull public final List<String> getAuxiliaryElements()
@Nonnull public final List<String> getIntegrationElements()
public final PropagationStateConverter getConverter()
PropagationStateConverter
.@Nonnull public final double[] getCurrentState()
@Nonnull public final JulianDate getEpoch()
public String toString()
java.lang.Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
@Nonnull public final Motion1<double[]> getMotionOfDoubleArray(String elementIdentification)
elementIdentification
as an array of doubles.elementIdentification
- The name of the element to retrieve.double