Beispiel #1
0
//! Add to A whatever is missing with respect to B, and vice versa
void Pulsar::PatchTime::operate (Archive* A, Archive* B) try
{
  A->expert()->sort();
  B->expert()->sort();

  contemporaneity_policy->set_archives (A, B);

  unsigned isubA = 0;
  unsigned isubB = 0;

  while (isubA < A->get_nsubint() && isubB < B->get_nsubint())
  {
    Integration* subA = A->get_Integration (isubA);
    Integration* subB = B->get_Integration (isubB);

    double ratio = contemporaneity_policy->evaluate (subA, subB);

    if (ratio < minimum_contemporaneity)
    {
      // one of the archives requires an empty sub-integration

#if 0
    cerr << "mismatch ratio=" << ratio << " isubA=" << isubA << " isubB=" << isubB
         << " A::nsubint=" << A->get_nsubint()
         << " B::nsubint=" << B->get_nsubint() << endl;

    cerr << "A::epoch=" << subA->get_epoch().printdays(13) << endl;
    cerr << "B::epoch=" << subB->get_epoch().printdays(13) << endl;
#endif

      if (subA->get_epoch() > subB->get_epoch())
      {
	if (Archive::verbose > 2)
          cerr << "Pulsar::PatchTime::operate A requires an empty sub-integration isubA=" << isubA << endl;
	insert (A, isubA, subB->get_epoch()); isubB++; isubA++;
      }
      else
      {
	if (Archive::verbose > 2)
          cerr << "Pulsar::PatchTime::operate B requires an empty sub-integration isubB=" << isubB << endl;
	insert (B, isubB, subA->get_epoch()); isubA++; isubB++;
      }
    }
    else
    {
      // A and B are contemporaneous
      isubA++;
      isubB++;
    }
  }

  if (isubA < A->get_nsubint())
    tail (A, B, isubA);
  else if (isubB < B->get_nsubint())
    tail (B, A, isubB);
}
catch (Error& error)
{
  throw error += "Pulsar::PatchTime::operate";
}