Main Page ? Class Hierarchy ? Compound List ? File List ? Compound Members ? File Members ?

BestFitSelector Class Reference

Inheritance diagram for BestFitSelector

[legend]
Collaboration diagram for BestFitSelector:

[legend]
List of all members.

Public Methods

Use*? operate (Use* ref_use, Use* new_use)

Member Function Documentation

Use * BestFitSelector::operate ( Use * ref_use,
Use * new_use?) [virtual]
?

Reimplemented from VersionSelector.

Definition at line 3244 of file cmt_use.cxx.

03245 {
03246   Use* selected = ref_use;
03247 
03248   int old_v = -1;
03249   int old_r = -1;
03250   int old_p = -1;
03251   cmt_string old_pp;
03252 
03253   int new_v = -1;
03254   int new_r = -1;
03255   int new_p = -1;
03256   cmt_string new_pp;
03257 
03258   int alias_v = -1;
03259   int alias_r = -1;
03260   int alias_p = -1;
03261   cmt_string alias_pp;
03262 
03263   enum { no_alias, new_has_alias, ref_has_alias } has_alias = no_alias;
03264 
03265   cmt_string ref_version = ref_use->version;
03266   if (ref_version == "v0") ref_version = ref_use->specified_version;
03267 
03268   cmt_string new_version = new_use->version;
03269   if (new_version == "v0") new_version = new_use->specified_version;
03270 
03271   CmtSystem::is_version_directory (ref_version, old_v, old_r, old_p);
03272   old_pp = ref_use->path;
03273 
03274   CmtSystem::is_version_directory (new_version, new_v, new_r, new_p);
03275   new_pp = new_use->path;
03276 
03277   if (new_use->version_alias != "")
03278     {
03279       has_alias = new_has_alias;
03280       CmtSystem::is_version_directory (new_use->version_alias, 
03281                                        alias_v, alias_r, alias_p);
03282       alias_pp = new_use->path_alias;
03283     }
03284   else if (ref_use->version_alias != "")
03285     {
03286       has_alias = ref_has_alias;
03287       CmtSystem::is_version_directory (ref_use->version_alias, 
03288                                        alias_v, alias_r, alias_p);
03289       alias_pp = ref_use->path_alias;
03290     }
03291 
03292   ref_use->undiscard ();
03293   new_use->undiscard ();
03294 
03295   if (new_v != old_v)
03296     {
03297       if (has_alias != no_alias)
03298         {
03299           if (has_alias == new_has_alias)
03300             {
03301               new_v = alias_v;
03302               new_r = alias_r;
03303               new_p = alias_p;
03304               new_pp = alias_pp;
03305             }
03306           else if (has_alias == ref_has_alias)
03307             {
03308               old_v = alias_v;
03309               old_r = alias_r;
03310               old_p = alias_p;
03311               old_pp = alias_pp;
03312             }
03313         }
03314     }
03315 
03316   if ((new_v != -1) && (old_v != -1) && (new_v != old_v))
03317     {
03318       /*
03319       if (!Cmt::get_quiet ())
03320         {
03321           cout << "# Required version " << new_version <<
03322             " of package " << ref_use->get_package_name () <<
03323             " incompatible with selected version " << ref_version <<
03324             endl;
03325         }
03326       */
03327 
03328       CmtError::set (CmtError::version_conflict, "BestFitSelector::operate> ");
03329 
03330       if (ref_use != new_use) new_use->discard ();
03331     }
03332   else if ((new_v == -1) || (old_v == -1))
03333     {
03334       //
03335       // we plan to discard new_use, but if it was specified as explicit 
03336       // and ref_use was wildcarded then new_use will win !!
03337       //
03338       // So then we'll have to understand where are the wild
03339       // cards... If they are on v or r, then we consider them.
03340       // 
03341       //
03342 
03343 
03344       if ((old_v == -1) && (new_v != -1))
03345         {
03346           /*
03347           if (!Cmt::get_quiet ())
03348             {
03349               cout << "# Select version " << new_version <<
03350                 " of package " << ref_use->get_package_name () <<
03351                 " instead of existing " << ref_version <<
03352                 endl;
03353             }
03354           */
03355 
03356           if (ref_use->real_path != new_use->real_path) 
03357             {
03358               if (ref_use != new_use) ref_use->discard ();
03359               selected = new_use;
03360               selected->done = false; // Will read the new requirements
03361             }
03362           else
03363             {
03364               if (ref_use != new_use) new_use->discard ();
03365               ref_use->version = new_version;
03366             }
03367         }
03368       else
03369         {
03370           /*
03371           if (!Cmt::get_quiet ())
03372             cout << "# keep version " << ref_version <<
03373               " of package " << ref_use->get_package_name () <<
03374               " (ignore version " << new_version << ")" <<
03375               endl;
03376           */
03377 
03378           if (ref_use != new_use) new_use->discard ();
03379         }
03380     }
03381   else if ((new_r == -1) || (old_r == -1) || (new_r < old_r))
03382     {
03383       //
03384       // we plan to discard new_use, but if it was specified as explicit 
03385       // and ref_use was wildcarded then new_use will win !!
03386       //
03387       // So then we'll have to understand where are the wild
03388       // cards... If they are on v or r, then we consider them.
03389       // 
03390       //
03391 
03392 
03393       if ((old_r == -1) && (new_r != -1))
03394         {
03395           // old has wild card and new has not => new wins
03396 
03397           /*
03398           if (!Cmt::get_quiet ())
03399             {
03400               cout << "# Select release " << new_version
03401                    << " of package " << ref_use->get_package_name ()
03402                    << " instead of existing " << ref_version
03403                    << endl;
03404             }
03405           */
03406 
03407           if (ref_use->real_path != new_use->real_path) 
03408             {
03409               if (ref_use != new_use) ref_use->discard ();
03410               selected = new_use;
03411               selected->done = false; // Will read the new requirements
03412             }
03413           else
03414             {
03415               // Just adapt version with new one.
03416 
03417               if (ref_use != new_use) new_use->discard ();
03418               ref_use->version = new_version;
03419             }
03420         }
03421       else
03422         {
03423           /*
03424           if (!Cmt::get_quiet ())
03425             cout << "# keep release " << ref_version <<
03426               " of package " << ref_use->get_package_name () <<
03427               " (ignore release " << new_version << ")" <<
03428               endl;
03429           */
03430 
03431           if (ref_use != new_use) new_use->discard ();
03432         }
03433     }
03434   else if (new_r > old_r)
03435     {
03436       /*
03437       if (!Cmt::get_quiet ())
03438         {
03439           cout << "# Select release " << new_version <<
03440             " of package " << ref_use->get_package_name () <<
03441             " instead of existing " << ref_version <<
03442             endl;
03443         }
03444       */
03445 
03446       if (ref_use != new_use) ref_use->discard ();
03447       selected = new_use;
03448       selected->done = false; // Will read the new requirements
03449     }
03450   else if ((new_p == -1) || (old_p == -1) || (new_p < old_p))
03451     {
03452       //
03453       // we plan to discard new_use, but if it was specified as explicit 
03454       // and ref_use was wildcarded then new_use will win !!
03455       //
03456 
03457 
03458       if ((old_p == -1) && (new_p != -1))
03459         {
03460           /*
03461           if (!Cmt::get_quiet ())
03462             {
03463               cout << "# Select patch " << new_version <<
03464                 " of package " << ref_use->get_package_name () <<
03465                 " instead of existing " << ref_version <<
03466                 endl;
03467             }
03468           */
03469 
03470           if (ref_use->real_path != new_use->real_path) 
03471             {
03472               if (ref_use != new_use) ref_use->discard ();
03473               selected = new_use;
03474               selected->done = false; // Will read the new requirements
03475             }
03476           else
03477             {
03478               if (ref_use != new_use) new_use->discard ();
03479               ref_use->version = new_version;
03480             }
03481         }
03482       else
03483         {
03484           /*
03485           if (!Cmt::get_quiet ())
03486             cout << "# keep patch " << ref_version <<
03487               " of package " << ref_use->get_package_name () <<
03488               " (ignore version " << new_version << ")" <<
03489               endl;
03490           */
03491 
03492           if (ref_use != new_use) new_use->discard ();
03493         }
03494     }
03495   else if (new_p > old_p)
03496     {
03497       /*
03498       if (!Cmt::get_quiet ())
03499         {
03500           cout << "# Select patch " << new_version <<
03501             " of package " << ref_use->get_package_name () <<
03502             " instead of existing " << ref_version <<
03503             endl;
03504         }
03505       */
03506 
03507       if (ref_use != new_use) ref_use->discard ();
03508       selected = new_use;
03509       selected->done = false; // Will read the new requirements
03510     }
03511   else if (new_pp != old_pp) // same version-r-p but from different path
03512     {
03513       if (ref_use != new_use) ref_use->discard ();
03514       selected = new_use;
03515       selected->done = false; // Will read the new requirements
03516     }
03517 
03518   return (selected);
03519 }

The documentation for this class was generated from the following file:
Generated at Mon Aug 11 12:55:56 2003 for CMT by 1.2.3 written by , ??1997-2000