bool ribi::kalman::FixedLagSmootherKalmanFilterCalculationElements::IsComplete() const
{
  const std::size_t sz = GetMeasurement().size();
  return
       sz != 0
    //Others, e.g.
    //&& sz == m_innovation.size()
    //&& sz == m_innovation_covariance.size1()
    //&& sz == m_innovation_covariance.size2()
    //&& sz == m_innovation_covariance.size1()
    && sz == GetMeasurement().size()
    && sz == GetPredictedState().size()
    && sz == GetPreviousState().size();
}
/*
*******************************************************************
* Function: DeRegister
*
* Description: 
*
* Parameters: 
*
* Returns: 
*
*******************************************************************
*/
CGBLCOError CGBLLOMeasuredObjective::DeRegisterMeasurement(XString nameOfMeasurement, int regID)
{
    CGBLCOError errorType = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_OK);

    // Get the measurement 
    CGBLMeasurement *theMeasurement = NULL;
    errorType = GetMeasurement(nameOfMeasurement, theMeasurement);

    if (GBLLO_ERROR_MEASUREMENTNOTFOUND == (int)errorType)
    {
        // there is no measurement found
        errorType = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_OK,
            GBLLO_ERROR_REGISTRATIONNOTFOUND_DESC, GBLLO_ERROR_REGISTRATIONNOTFOUND);
    }
    else
    {
        errorType = theMeasurement->DeRegister(regID);
        // check if the measurement can now be deleted
        if (GBLLO_ERROR_EMPTYREGARRAY == (int)errorType)
        {
            // Delete the measurement

            // change the error type
            errorType = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_OK);
        }
    }
    
    return errorType;
}
/*
*******************************************************************
* Function: TeamRegisterMeasurement
*
* Description: 
*
* Parameters: 
*
* Returns: 
*
*******************************************************************
*/
int CGBLLOMeasuredObjective::TeamRegisterMeasurement(XString measurementName, CGBLTeamID theTeamID, 
        TGBLLOMeasurementCallback *callbackFunction, bool isATeam)
{
    // First, find the measurement to register - it is assumed that by this stage the measurement name
    // Does belong with the MO so no check is made.  The check will be made once the measurement
    // has been found
    CGBLMeasurement *theMeasurement = NULL;

    CGBLCOError errorType = GetMeasurement(measurementName, theMeasurement);

    if (GBLLO_ERROR_MEASUREMENTNOTFOUND == (int)errorType)
    {
        // We have not found a measurement, there needs to be a new one

        // First, get the measurement list from the MO Controller
        GBLMeasuredObjective::typedefs::MeasurementList *theMeasList = NULL;
        theMeasList = theMOManager->GetListOfMeasurements();
        CGBLMeasurementData *theMeas  = *theMeasList->FindPtr(measurementName);

        // Now we have the measurement data, check if it belongs in this MO
        if( (NULL != theMeas) && (theMeas->GetMOName() == theMOData->GetName()) )
        {
            // Now construt a new measurement
            theMeasurement = new CGBLMeasurement(theMeas, theContext);
        }
        else
        {
            errorType = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,
                GBLLO_ERROR_INVALIDMEASUREMENT_DESC, GBLLO_ERROR_INVALIDMEASUREMENT);
        }
    }
    int theRetVal = 0;
    if (theMeasurement != NULL)
    {
        theRetVal = theMeasurement->TeamRegister(theTeamID, callbackFunction);
    }

    return theRetVal;
}