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

# Use Class Reference

`#include <cmt_use.h>`

Collaboration diagram for Use:

[legend]
List of all members.

## Public Types
typedef cmt_vector<Use> | UseVector
typedef cmt_vector<Use*> | UsePtrVector
## Public Methods
| Use ()
| Use (const cmt_string& new_package, const cmt_string& new_version, const cmt_string& new_path)
| ~Use ()
void | set (const cmt_string& new_package, const cmt_string& new_version, const cmt_string& new_path, const cmt_string& new_version_alias = "", const cmt_string& new_path_alias = "")
void | author_action (const CmtSystem::cmt_string_vector& words)
void | manager_action (const CmtSystem::cmt_string_vector& words)
bool | move_to ()
void | discard ()
| Get the previous set of effective use statements that might have been obtained in a previous build. More...
void | undiscard ()
void | apply_global_patterns ()
void | set_include_path (const cmt_string& new_path)
void | get_full_path (cmt_string& s) const
| Compute the full real path of a found package. More...
cmt_string | get_full_path () const
| Compute the full real path of a found package. More...
void | reduce_path (cmt_string& s) const
| Considering a given path, try and reduce the part of it that corresponds to the full path of this package into its normal form ${<PACKAGE>ROOT} The argument is modified if the pattern is exactly found. More...
void | fill_includes_macro (cmt_string& buffer) const
void | fill_macro (cmt_string& buffer, const cmt_string& suffix) const
bool | get_paths (Use* to, UsePtrVector& list)
bool | located () const
void | change_path (const cmt_string& path)
void | set_auto_imports (State new_state)
void | set_native_version (bool state)
bool | has_native_version () const
## Public Attributes
cmt_string | package
cmt_string | specified_version
cmt_string | specified_path
cmt_string | version_alias
cmt_string | path_alias
cmt_string | author
cmt_string | manager
cmt_string | path
cmt_string | version
cmt_string | real_path
CmtDirStyle | style
cmt_string | prefix
ScopeType | scope
bool | done
bool | discarded
bool | selected
State | auto_imports
Include::IncludeVector | includes
cmt_string | include_path
Script::ScriptVector | scripts
ApplyPattern::ApplyPatternVector | apply_patterns
IgnorePattern::IgnorePatternVector | ignore_patterns
## Static Public Methods
Use* | action (const CmtSystem::cmt_string_vector& words, Use* use)
Use* | find (const cmt_string& package, const cmt_string& version = "", const cmt_string& path = "")
int | find_index (const cmt_string& package, const cmt_string& version, const cmt_string& path)
void | set_auto_imports_state (int use_index, cmt_vector<bool>& auto_imports_states)
| 1) Given a Use object identified by its index in the uses() array, 2) Given a vector of states containing the auto_imports states of all Uses,. More...
Use* | add (const cmt_string& path, const cmt_string& package, const cmt_string& version, const cmt_string& version_alias, const cmt_string& path_alias, Use* context_use, State specified_auto_imports = Unspecified)
void | move (Use* use1)
| Here, use points to a Use object which had been declared as no_auto_imports. More...
void | reorder (Use* use1, Use* use2)
| Reorder use1 versus use2 in the UsePtrVector list, so that the order reflects the fact that use2 makes use of use1. More...
void | select_clients (const cmt_string& package, const cmt_string& version)
| Mark all clients of the current package. More...
void | show_all (bool skip_discarded = false)
void | show_all (const cmt_string& prefix, bool skip_discarded = false)
Use& | current ()
const Use& | const_current ()
UseVector& | all_uses ()
UsePtrVector& | uses ()
void | clear_all ()
void | unselect_all ()
void | undiscard_all ()
void | fill_macro_all (cmt_string& buffer, const cmt_string& suffix)
## Private Methods
void | clear ()
int | reach_package (const cmt_string& current_path)
void | select ()
void | unselect ()
bool | is_selected ()
bool | is_client (const cmt_string& package, const cmt_string& version)
| Check if the package makes use of the specified package/version. More...
void | show_sub_uses (bool skip_discarded = false)
bool | select_alternate ()
Use* | get_selected_version ()
| This function tries to get the replacement of a Use when it has been discarded by a better match to version constraints. More...
## Private Attributes
bool | m_located
bool | m_has_native_version
UsePtrVector | sub_uses
cmt_vector<ScopeType> | sub_use_scopes
cmt_vector<State> | sub_use_auto_imports
CmtSystem::cmt_string_vector | alternate_versions
CmtSystem::cmt_string_vector | alternate_paths
## Static Private Methods
Use* | create (const cmt_string& path, const cmt_string& package, const cmt_string& version, const cmt_string& version_alias, const cmt_string& path_alias)
bool | need_new (const cmt_string& path, const cmt_string& package, const cmt_string& version, Use** old_use)

## Member Typedef Documentation

typedef cmt_vector<Use*> Use::UsePtrVector

| Definition at line 12 of file cmt_use.h.

typedef cmt_vector<Use> Use::UseVector

| Definition at line 11 of file cmt_use.h.

## Constructor & Destructor Documentation

Use::Use ( | )

| Definition at line 934 of file cmt_use.cxx.
    00935 {
    00936   done = false;
    00937   discarded = false;
    00938   auto_imports = Unspecified;
    00939
    00940   clear ();
    00941 }

Use::Use ( | const cmt_string & new_package,
| const cmt_string & new_version,
| const cmt_string & new_path )

| Definition at line 944 of file cmt_use.cxx.
    00947 {
    00948   auto_imports = Unspecified;
    00949   m_located = false;
    00950   set (new_package, new_version, new_path);
    00951 }

Use::~Use ( | )

| Definition at line 954 of file cmt_use.cxx.
    00955 {
    00956   clear ();
    00957 }

## Member Function Documentation

Use * Use::action ( | const CmtSystem::cmt_string_vector & words,
| Use * parent )`[static]`

| Definition at line 525 of file cmt_use.cxx. Referenced by Cmt::select().
    00526 {
    00527   Use* new_use;
    00528
    00529   //
    00530   // complete syntax : "use <package> <version> <path>"
    00531   // minimal syntax  : "use <package>"
    00532   //
    00533   //  o if <version> is omitted then take any version available
    00534   //  o <version> can be specified using "v*" or "v<n>r*" or "v<n>r<m>p*"
    00535   //
    00536   //  o the notation "v*" is preferred to omission (particularly since
    00537   //    omission does not permit <path>)
    00538   //
    00539   if (words.size () < 2) return (0);
    00540
    00541   use_action_iterator it;
    00542
    00543   for (int i = 1; i < words.size (); i++)
    00544     {
    00545       const cmt_string& w = words[i];
    00546       cmt_string ew = w;
    00547
    00548       Symbol::expand (ew);
    00549       if (ew != w)
    00550         {
    00551           CmtSystem::cmt_string_vector ws;
    00552
    00553           CmtSystem::split (ew, " ", ws);
    00554
    00555           for (int j = 0; j < ws.size (); ++j)
    00556             {
    00557               const cmt_string& ww = ws[j];
    00558               it.set (ww);
    00559             }
    00560         }
    00561       else
    00562         {
    00563           it.set (ew);
    00564         }
    00565     }
    00566
    00567   if (!it.ok ()) return (0);
    00568
    00569   static int level = 0;
    00570
    00571   level++;
    00572   new_use = it.get_use (parent);
    00573   level--;
    00574
    00575   return (new_use);
    00576 }

Use * Use::add ( | const cmt_string & path,
| const cmt_string & package,
| const cmt_string & version,
| const cmt_string & version_alias,
| const cmt_string & path_alias,
| Use * context_use,
| State specified_auto_imports = Unspecified )`[static]`

| Definition at line 1548 of file cmt_use.cxx. Referenced by use_action_iterator::get_use(), Cmt::use_cmt(), Cmt::use_home_requirements(), and Cmt::use_user_context_requirements().
    01555 {
    01556   static UsePtrVector& Uses = uses ();
    01557
    01558   bool do_need_new = false;
    01559
    01560   Use* old_use = 0;
    01561   Use* use = 0;
    01562
    01563   do_need_new = need_new (path, package, version, &old_use);
    01564
    01565   /*
    01566     if (old_use != 0)
    01567     {
    01568     cout << "add> old_use " << old_use->package <<
    01569     " " << old_use->version <<
    01570     " " << old_use->path <<
    01571     endl;
    01572     }
    01573   */
    01574
    01575   if (do_need_new)
    01576     {
    01577       use = create (path, package, version, version_alias, path_alias);
    01578     }
    01579   else
    01580     {
    01581       // Since we don't need a new Use, it means that old_use exists !
    01582       use = old_use;
    01583       old_use = 0;
    01584     }
    01585
    01586   if (package == CmtSystem::get_home_package ())
    01587     {
    01588       return (use);
    01589     }
    01590
    01591   if (package == CmtSystem::get_user_context_package ())
    01592     {
    01593       return (use);
    01594     }
    01595
    01596   cmt_string here = CmtSystem::pwd ();
    01597
    01598     //
    01599     // Store the specified sub_uses. Some of them may become discarded
    01600     // later on.
    01601     //
    01602   if (context_use != 0)
    01603     {
    01604       context_use->sub_uses.push_back (use);
    01605       context_use->sub_use_scopes.push_back (Cmt::get_scope ());
    01606       context_use->sub_use_auto_imports.push_back (specified_auto_imports);
    01607
    01608       if (Cmt::get_debug ())
    01609         {
    01610           cout << "Use::add context(" << context_use->package << ") "
    01611                << "[u:" << package
    01612                << " s:" << Cmt::get_scope ()
    01613                << " ai:" << specified_auto_imports
    01614                << "]" << endl;
    01615         }
    01616     }
    01617
    01618   /*
    01619    *   Now we have a Use object. If it is a new one, we have to
    01620    *    1) understand if it exists physically
    01621    *    2) it is better than the old ones.
    01622    *
    01623    *   Here, we may have :
    01624    *    1) old_use = 0
    01625    *         there was no Use object before for this package
    01626    *         the existing one is fine
    01627    *
    01628    *    2) old_use != 0
    01629    *         we have created a new Use (which has to be validated)
    01630    */
    01631
    01632   bool found = use->move_to ();
    01633
    01634   if (Cmt::get_debug ())
    01635     {
    01636       cout << "add> use " << use->package
    01637            << " " << use->version
    01638            << " " << use->path
    01639            << " found=" << found
    01640            << endl;
    01641     }
    01642
    01643   if (!found)
    01644     {
    01645       if (!Cmt::get_quiet ())
    01646         {
    01647           cerr << "#(Warning) package " << use->package <<
    01648             " " << use->version << " " << use->path <<
    01649             " not found" <<
    01650             endl;
    01651         }
    01652
    01653       CmtError::set (CmtError::package_not_found, use->package);
    01654       use = 0;
    01655     }
    01656
    01657   if ((old_use != 0) && (use != old_use))
    01658     {
    01659       /*
    01660        *    There was another version of this Use. But a new one was created due to
    01661        *   some criteria.
    01662        *    New we are going to apply the version strategy to make the final selection.
    01663        */
    01664
    01665       /*
    01666         if (CmtSystem::getenv ("CMTTESTUSEWILDCARDS") != "")
    01667         {
    01668         cout << "select? [" << use << "] vs old_use[" << old_use << "] " << old_use->package <<
    01669         " " << old_use->version <<
    01670         " " << old_use->path <<
    01671         endl;
    01672         }
    01673       */
    01674
    01675       if (!found)
    01676         {
    01677           /*
    01678            *  This new Use does not correspond to any physical package.
    01679            *  let's simply discard it
    01680            */
    01681
    01682           if (use != 0) use->discard ();
    01683           use = old_use;
    01684           found = use->move_to ();
    01685         }
    01686       else
    01687         {
    01688             //
    01689             //  This new version is different from the old one
    01690             // thus we have to choose
    01691             //
    01692           VersionSelector& selector = VersionSelector::instance ();
    01693           Use* selected_use = selector.operate (old_use, use);
    01694
    01695             //
    01696             // Some situations managed by selector.operate happen
    01697             // to fail discarding the rejected Use.
    01698             //
    01699           if (use != selected_use)
    01700             {
    01701               use->discard ();
    01702             }
    01703
    01704           use = selected_use;
    01705
    01706           /*
    01707            *   current directory is moved to the selected one
    01708            */
    01709           found = use->move_to ();
    01710         }
    01711     }
    01712
    01713     //
    01714     // The following statement is no longer considered as useful.
    01715     // It is commented. But we should clarify why it was really needed!
    01716     //
    01717     //use->undiscard ();
    01718
    01719   if (found)
    01720     {
    01721       bool registered = false;
    01722       const Use& cu = Use::current ();
    01723
    01724       //
    01725       // A pointer to this new object is also added or replaced.
    01726       //
    01727       if ((use != &cu) && (package == cu.package))
    01728         {
    01729             // This is a recursive call to the current package!!
    01730           registered = true;
    01731           use->done = true;
    01732         }
    01733       else
    01734         {
    01735           for (int i = 0; i < Uses.size(); i++)
    01736             {
    01737               Use* u = Uses[i];
    01738
    01739               if (u->package == package)
    01740                 {
    01741                   registered = true;
    01742                   Uses[i] = use;
    01743                   break;
    01744                 }
    01745             }
    01746         }
    01747
    01748       if (!registered) Uses.push_back (use);
    01749
    01750       if (!use->done && Cmt::get_recursive ())
    01751         {
    01752           use->done = true;
    01753
    01754           /*
    01755             if (CmtSystem::getenv ("CMTTESTUSEWILDCARDS") != "")
    01756             {
    01757             for (int use_index = 0; use_index < Uses.size (); use_index++)
    01758             {
    01759             Use* u = (Use*) Uses[use_index];
    01760             cout << "  use[" << use_index << "] p=" << u->package <<
    01761             " v=" << u->version <<
    01762             " discarded=" << u->discarded <<
    01763             " selected=" << u->selected <<
    01764             endl;
    01765             }
    01766
    01767             cout << "parsing at " << CmtSystem::pwd () << endl;
    01768             }
    01769           */
    01770
    01777           //Cmt::parse_requirements ("uses.log", use);
    01778
    01779           if (Cmt::get_debug ())
    01780             {
    01781               cout << "Parsing requirements file at " << CmtSystem::pwd () << endl;
    01782             }
    01783
    01784           Cmt::parse_requirements ("requirements", use);
    01785         }
    01786     }
    01787
    01788   CmtSystem::cd (here);
    01789
    01790   return (use);
    01791 }

Use::UseVector & Use::all_uses ( | )`[static]`

| Definition at line 2300 of file cmt_use.cxx. Referenced by clear_all(), create(), current(), find(), find_index(), and need_new().
    02301 {
    02302   static Database& db = Database::instance ();
    02303   static UseVector& AllUses = db.all_uses ();
    02304
    02305   return (AllUses);
    02306 }

void Use::apply_global_patterns ( | )

| Definition at line 1860 of file cmt_use.cxx.
    01861 {
    01862   int i;
    01863
    01864   Pattern::PatternVector& vector = Pattern::patterns ();
    01865
    01866   for (i = 0; i < vector.size (); i++)
    01867     {
    01868       Pattern& p = vector[i];
    01869
    01870       if (p.global)
    01871         {
    01872           p.apply (this);
    01873         }
    01874     }
    01875 }

void Use::author_action ( | const CmtSystem::cmt_string_vector & words )

| Definition at line 579 of file cmt_use.cxx. Referenced by Cmt::select().
    00580 {
    00581   if (author != "") author += "\n";
    00582   for (int i = 1; i < words.size (); i++)
    00583     {
    00584       const cmt_string& w = words[i];
    00585
    00586       if (i > 1) author += " ";
    00587       author += w;
    00588     }
    00589 }

void Use::change_path ( | const cmt_string & new_path )

| Definition at line 1027 of file cmt_use.cxx. Referenced by Cmt::configure(), Cmt::do_config(), move_to(), Cmt::select(), and select_alternate().
    01028 {
    01029   //
    01030   // This methods changes real_path after an actual location
    01031   // where this package/version has been found.
    01032   //
    01033
    01034   real_path = "";
    01035
    01036   if (new_path != "")
    01037     {
    01038       if ((path.size () > 0) &&
    01039           (!CmtSystem::absolute_path (path)))
    01040         {
    01041           real_path = new_path;
    01042           real_path += CmtSystem::file_separator ();
    01043           real_path += path;
    01044         }
    01045       else
    01046         {
    01047           real_path = new_path;
    01048         }
    01049       // real_path.replace_all ("\\", "/");
    01050     }
    01051
    01052   m_located = true;
    01053 }

void Use::clear ( | )`[private]`

| Definition at line 960 of file cmt_use.cxx. Referenced by Use(), clear_all(), set(), and ~Use().
    00961 {
    00962   specified_path = "";
    00963   path      = "";
    00964   package   = "";
    00965   version   = "";
    00966   author    = "";
    00967   manager   = "";
    00968   real_path = "";
    00969
    00970   prefix    = "";
    00971   style     = mgr_style;
    00972   scope     = Cmt::get_scope ();
    00973   done      = false;
    00974   discarded = false;
    00975   selected  = false;
    00976   auto_imports = Unspecified;
    00977
    00978   includes.clear ();
    00979   include_path = "";
    00980   scripts.clear ();
    00981   apply_patterns.clear ();
    00982   ignore_patterns.clear ();
    00983
    00984   sub_uses.clear ();
    00985   sub_use_scopes.clear ();
    00986   sub_use_auto_imports.clear ();
    00987
    00988   alternate_versions.clear ();
    00989   alternate_paths.clear ();
    00990
    00991   version_alias = "";
    00992   path_alias    = "";
    00993
    00994   m_located = false;
    00995   m_has_native_version = false;
    00996 }

void Use::clear_all ( | )`[static]`

| Definition at line 851 of file cmt_use.cxx. Referenced by Database::clear().
    00852 {
    00853   static UsePtrVector& Uses = uses ();
    00854   static UseVector& AllUses = all_uses ();
    00855
    00856   int use_index;
    00857
    00858   for (use_index = 0; use_index < AllUses.size (); use_index++)
    00859     {
    00860       Use& use = AllUses[use_index];
    00861       use.clear ();
    00862     }
    00863
    00864   Uses.clear ();
    00865   AllUses.clear ();
    00866 }

const Use & Use::const_current ( | )`[static]`

| Definition at line 2292 of file cmt_use.cxx.
    02293 {
    02294   const Use& use = Use::current ();
    02295
    02296   return (use);
    02297 }

Use * Use::create ( | const cmt_string & path,
| const cmt_string & package,
| const cmt_string & version,
| const cmt_string & version_alias,
| const cmt_string & path_alias )`[static, private]`

| Definition at line 1513 of file cmt_use.cxx. Referenced by add().
    01518 {
    01519   static UseVector& AllUses = all_uses ();
    01520
    01521   // We first look in the database.
    01522   for (int use_index = 0; use_index < AllUses.size (); use_index++)
    01523     {
    01524       Use& use = AllUses[use_index];
    01525
    01526       if (use.package == package)
    01527         {
    01528           if ((use.specified_version == version) &&
    01529               (use.specified_path == path)) return (&use);
    01530         }
    01531     }
    01532
    01533   // We now really create a new Use entry.
    01534
    01535   Use& use_object = AllUses.add ();
    01536   use_object.set (package, version, path, version_alias, path_alias);
    01537
    01538   return (&use_object);
    01539 }

Use & Use::current ( | )`[static]`

| Definition at line 2277 of file cmt_use.cxx. Referenced by StandardMacroBuilder::StandardMacroBuilder(), Script::action(), IgnorePattern::action(), ApplyPattern::action(), Include::action(), add(), Script::add(), Include::add(), Script::all_print(), ApplyPattern::apply(), Pattern::apply(), Generator::build_dependencies(), Cmt::configure(), const_current(), Cmt::do_broadcast(), Cmt::do_build_library_links(), Cmt::do_config(), Cmt::do_remove_library_links(), Cmt::do_show_author(), Cmt::do_show_include_dirs(), Cmt::do_show_manager(), Pattern::expand(), StandardMacroBuilder::fill_for_includes(), StandardMacroBuilder::fill_for_use_stamps(), fill_macro_all(), Script::find(), IgnorePattern::find(), Pattern::find(), Include::find(), use_action_iterator::get_use(), Cmt::load(), Cmt::parse_arguments(), Cmt::parse_requirements(), Cmt::parse_requirements_text(), MakefileGenerator::prepare_use_context(), Fragment::print(), Include::print_all(), Include::print_filters(), Cmt::reach_current_package(), TriggerGenerator::run(), UseAnalyzer::run(), Cmt::select(), Cmt::set_standard_macros(), ApplyPattern::show(), Pattern::show(), show_all(), Pattern::show_all(), and Pattern::show_all_applied_patterns().
    02278 {
    02279   static UseVector& AllUses = all_uses ();
    02280   static Use* current_use = 0;
    02281
    02282   if ((current_use == 0) || (AllUses.size () == 0))
    02283     {
    02284       Use& use_object = AllUses.add ();
    02285       current_use = &use_object;
    02286     }
    02287
    02288   return (*current_use);
    02289 }

void Use::discard ( | )

| Get the previous set of effective use statements that might have been obtained in a previous build. This is stored in uses.log. Ignored if file does not exist. Definition at line 1794 of file cmt_use.cxx. Referenced by add(), LastChoiceSelector::operate(), FirstChoiceSelector::operate(), BestFitNoCheckSelector::operate(), BestFitSelector::operate(), and select_clients().
    01795 {
    01796   discarded = true;
    01797 }

void Use::fill_includes_macro ( | cmt_string & buffer ) const

| Definition at line 1935 of file cmt_use.cxx. Referenced by StandardMacroBuilder::fill_for_all_constituents(), and StandardMacroBuilder::fill_for_use_includes().
    01936 {
    01937   if (include_path == "")
    01938     {
    01939       buffer += "$(ppcmd)\"$(";
    01940       buffer += package;
    01941       buffer += "_root)";
    01942       buffer += CmtSystem::file_separator ();
    01943       buffer += "src\" ";
    01944     }
    01945   else if (include_path != "none")
    01946     {
    01947       buffer += "$(ppcmd)\"";
    01948       buffer += include_path;
    01949       buffer += "\" ";
    01950     }
    01951
    01952   for (int i = 0; i < includes.size (); i++)
    01953     {
    01954       Include& incl = includes[i];
    01955
    01956       buffer += "$(ppcmd)\"";
    01957       buffer += incl.name;
    01958       buffer += "\" ";
    01959     }
    01960 }

void Use::fill_macro ( | cmt_string & buffer,
| const cmt_string & suffix ) const

| Definition at line 1963 of file cmt_use.cxx. Referenced by StandardMacroBuilder::fill_for_all_constituents(), StandardMacroBuilder::fill_for_use_libraries(), StandardMacroBuilder::fill_for_use_stamps(), and fill_macro_all().
    01964 {
    01965   buffer += " $(";
    01966   buffer += package;
    01967   buffer += "_";
    01968   buffer += suffix;
    01969   buffer += ") ";
    01970 }

void Use::fill_macro_all ( | cmt_string & buffer,
| const cmt_string & suffix )`[static]`

| Definition at line 909 of file cmt_use.cxx. Referenced by StandardMacroBuilder::fill_for_use_cflags(), StandardMacroBuilder::fill_for_use_cppflags(), StandardMacroBuilder::fill_for_use_fflags(), StandardMacroBuilder::fill_for_use_linkopts(), StandardMacroBuilder::fill_for_use_pp_cflags(), StandardMacroBuilder::fill_for_use_pp_cppflags(), and StandardMacroBuilder::fill_for_use_pp_fflags().
    00910 {
    00911   UsePtrVector& Uses = uses ();
    00912
    00913   buffer = "macro_append use_";
    00914   buffer += suffix;
    00915   buffer += " \" ";
    00916   (Use::current()).fill_macro (buffer, suffix);
    00917
    00918   for (int number = 0; number < Uses.size (); number++)
    00919     {
    00920       Use* use = Uses[number];
    00921
    00922       if (use->package == "CMT") continue;
    00923       if (use->package == "methods") continue;
    00924       if (use->discarded) continue;
    00925       if (use->auto_imports == Off) continue;
    00926
    00927       use->fill_macro (buffer, suffix);
    00928     }
    00929
    00930   buffer += "\"";
    00931 }

Use * Use::find ( | const cmt_string & package,
| const cmt_string & version = "",
| const cmt_string & path = "" )`[static]`

| Definition at line 605 of file cmt_use.cxx. Referenced by Fragment::locate(), need_new(), and show_all().
    00608 {
    00609   static UsePtrVector& Uses = uses ();
    00610   static UseVector& AllUses = all_uses ();
    00611
    00612   int use_index;
    00613
    00614   if (AllUses.size () == 0) return (0);
    00615
    00616   for (use_index = 0; use_index < Uses.size (); use_index++)
    00617     {
    00618       Use& use = (*Uses[use_index]);
    00619
    00620       if (use.package == package)
    00621         {
    00622             // If the version argument is omitted then
    00623             // take the first registered version
    00624           if (version == "") return (&use);
    00625
    00626             // Otherwise compare against specified_version and path
    00627             //if ((use.specified_version == version) &&
    00628             //  (use.specified_path == path)) return (&use);
    00629
    00630             // what about comparing wild cards?
    00631
    00632           if (use.specified_version == version) return (&use);
    00633         }
    00634     }
    00635
    00636   return (0);
    00637 }

int Use::find_index ( | const cmt_string & package,
| const cmt_string & version,
| const cmt_string & path )`[static]`

| Definition at line 640 of file cmt_use.cxx. Referenced by StandardMacroBuilder::fill_for_all_constituents().
    00643 {
    00644   static UsePtrVector& Uses = uses ();
    00645   static UseVector& AllUses = all_uses ();
    00646
    00647   int use_index;
    00648
    00649   if (AllUses.size () == 0) return (-1);
    00650
    00651   for (use_index = 0; use_index < Uses.size (); use_index++)
    00652     {
    00653       Use& use = (*Uses[use_index]);
    00654
    00655       if (use.package == package)
    00656         {
    00657           // If the version argument is omitted then
    00658           // take the first registered version
    00659           if (version == "") return (use_index);
    00660
    00661           // Otherwise compare against specified_version and path
    00662           //if ((use.specified_version == version) &&
    00663           //  (use.specified_path == path)) return (&use);
    00664
    00665           // what about comparing wild cards?
    00666
    00667           if (use.specified_version == version) return (use_index);
    00668         }
    00669     }
    00670
    00671   return (-1);
    00672 }

cmt_string Use::get_full_path ( | ) const

| Compute the full real path of a found package. Takes the structuring style into account Definition at line 1906 of file cmt_use.cxx. Referenced by StandardMacroBuilder::fill_for_use_ROOT(), and reduce_path().
    01907 {
    01908   cmt_string result;
    01909
    01910   get_full_path (result);
    01911
    01912   return (result);
    01913 }

void Use::get_full_path ( | cmt_string & s ) const

| Compute the full real path of a found package. Takes the structuring style into account Result is used to fill in the referenced string Result does NOT include the trailing file_separator Definition at line 1890 of file cmt_use.cxx. Referenced by Fragment::locate().
    01891 {
    01892   if (real_path == "") s = CmtSystem::pwd ();
    01893   else s = real_path;
    01894
    01895   s += CmtSystem::file_separator ();
    01896   s += package;
    01897
    01898   s += CmtSystem::file_separator ();
    01899   s += version;
    01900 }

bool Use::get_paths ( | Use * to,
| UsePtrVector & list )

| Definition at line 2067 of file cmt_use.cxx. Referenced by Pattern::apply().
    02068 {
    02069   bool found = false;
    02070   bool cycle = false;
    02071
    02072   static int level = 0;
    02073   static UsePtrVector stack;
    02074
    02075   if (level == 0)
    02076     {
    02077       stack.clear ();
    02078     }
    02079
    02080   // Protect against cycles.
    02081   for (int k = 0; k < stack.size (); k++)
    02082     {
    02083       Use* u = stack[k];
    02084       if (u == this)
    02085         {
    02086           if (Cmt::get_debug ())
    02087             {
    02088               cout << "Use::get_paths." << level << ">" << package << " cycle " << endl;
    02089             }
    02090
    02091           return (false);
    02092         }
    02093     }
    02094
    02095   // Save this to the protection stack.
    02096   if (stack.size () <= level)
    02097     {
    02098       stack.push_back (this);
    02099     }
    02100   else
    02101     {
    02102       stack[level] = this;
    02103     }
    02104
    02105     // First figure out whether 'to' is used by 'this'.
    02106
    02107   if (Cmt::get_debug ())
    02108     {
    02109       cout << "Use::get_paths." << level << ">" << package << " to=" << to->package << " list[" << list.size () << "]" << endl;
    02110     }
    02111
    02112   if (this == to)
    02113     {
    02114       found = true;
    02115     }
    02116   else
    02117     {
    02118       for (int n = 0; n < sub_uses.size (); n++)
    02119         {
    02120           Use* use = sub_uses[n];
    02121
    02122           if (use == 0) continue;
    02123
    02124           if (Cmt::get_debug ())
    02125             {
    02126               cout << "  Use::get_paths." << level << "> try1 sub=" << use->package << endl;
    02127             }
    02128
    02129           if (use->discarded)
    02130             {
    02131               Use* u;
    02132
    02133               u = use->get_selected_version ();
    02134               if (u == 0) continue;
    02135
    02136               use = u;
    02137             }
    02138
    02139           cycle = false;
    02140
    02141             // This use must not be already in the list (protection against cycles)
    02142
    02143           for (int m = 0; m < list.size (); m++)
    02144             {
    02145               Use* u = list[m];
    02146               if (u == use)
    02147                 {
    02148                   cycle = true;
    02149                   break;
    02150                 }
    02151             }
    02152
    02153           if (cycle)
    02154             {
    02155               found = true;
    02156               continue;
    02157             }
    02158
    02159           if (Cmt::get_debug ())
    02160             {
    02161               cout << "  Use::get_paths." << level << "> try2 sub=" << use->package << endl;
    02162             }
    02163
    02164           level++;
    02165           bool r = use->get_paths (to, list);
    02166           level--;
    02167
    02168           if (r)
    02169             {
    02170               found = true;
    02171             }
    02172         }
    02173     }
    02174
    02175   if (found)
    02176     {
    02177       cycle = false;
    02178
    02179       for (int m = 0; m < list.size (); m++)
    02180         {
    02181           Use* u = list[m];
    02182           if (u == this)
    02183             {
    02184               cycle = true;
    02185               break;
    02186             }
    02187         }
    02188
    02189       if (!cycle)
    02190         {
    02191           if (Cmt::get_debug ())
    02192             {
    02193               cout << "Use::get_paths." << level << "> push " << package << endl;
    02194             }
    02195           list.push_back (this);
    02196         }
    02197     }
    02198
    02199   return (found);
    02200 }

Use * Use::get_selected_version ( | )`[private]`

| This function tries to get the replacement of a Use when it has been discarded by a better match to version constraints. Definition at line 1976 of file cmt_use.cxx. Referenced by get_paths().
    01977 {
    01978   static Use::UsePtrVector& Uses = uses ();
    01979
    01980     //cout << "get_selected_version for package " << package << endl;
    01981
    01982   if (!discarded) return (this);
    01983
    01984   for (int i = 0; i < Uses.size (); i++)
    01985     {
    01986       Use* u = Uses[i];
    01987       if (u == 0) continue;
    01988       if (u->discarded) continue;
    01989       if (u->package == package)
    01990         {
    01991             //cout << "  got a version" << endl;
    01992           return (u);
    01993         }
    01994     }
    01995
    01996   return (0);
    01997 }

bool Use::has_native_version ( | ) const

| Definition at line 2061 of file cmt_use.cxx.
    02062 {
    02063   return (m_has_native_version);
    02064 }

bool Use::is_client ( | const cmt_string & used_package,
| const cmt_string & used_version )`[private]`

| Check if the package makes use of the specified package/version. The seach only considers the first level of uses (thus it is NOT recursive) Definition at line 1829 of file cmt_use.cxx. Referenced by select_clients().
    01831 {
    01832   // A package is client of itself
    01833   if ((package == used_package) &&
    01834       (version == used_version)) return (true);
    01835
    01836   if (discarded) return (false);
    01837
    01838   int i;
    01839
    01840   for (i = 0; i < sub_uses.size (); i++)
    01841     {
    01842       Use* use = sub_uses[i];
    01843       if (use == 0) continue;
    01844
    01845       if ((use->package == used_package) &&
    01846           (use->version == used_version)) return (true);
    01847
    01848       /*
    01849         if (use->is_client (used_package, used_version))
    01850         {
    01851         return (true);
    01852         }
    01853       */
    01854     }
    01855
    01856   return (false);
    01857 }

bool Use::is_selected ( | )`[private]`

| Definition at line 1818 of file cmt_use.cxx. Referenced by select_clients().
    01819 {
    01820   return (selected);
    01821 }

bool Use::located ( | ) const

| Definition at line 2203 of file cmt_use.cxx. Referenced by Cmt::do_broadcast(), Cmt::do_build_library_links(), Cmt::do_remove_library_links(), StandardMacroBuilder::fill_for_use_ROOT(), StandardMacroBuilder::fill_for_use_requirements(), StandardMacroBuilder::fill_for_use_root(), and show_all().
    02204 {
    02205   return (m_located);
    02206 }

void Use::manager_action ( | const CmtSystem::cmt_string_vector & words )

| Definition at line 592 of file cmt_use.cxx. Referenced by Cmt::select().
    00593 {
    00594   if (manager != "") manager += "\n";
    00595   for (int i = 1; i < words.size (); i++)
    00596     {
    00597       const cmt_string& w = words[i];
    00598
    00599       if (i > 1) manager += " ";
    00600       manager += w;
    00601     }
    00602 }

void Use::move ( | Use * use1 )`[static]`

| Here, use points to a Use object which had been declared as no_auto_imports. But we need to switch it On. Therefore, 1) the state in auto_imports_states has to be set On 2) the operation has to be recursively propagated to all sub_uses which also had no_auto_imports. (only to those) Definition at line 732 of file cmt_use.cxx. Referenced by show_all().
    00733 {
    00734   static UsePtrVector& Uses = uses ();
    00735
    00736   int use_index;
    00737   Use* use;
    00738   int found = 0;
    00739
    00740   if (Uses.size () == 0) return;
    00741   if (use1 == 0) return;
    00742
    00743   //
    00744   // On se positionne sur le pointeur.
    00745   //
    00746   for (use_index = 0; use_index < Uses.size (); use_index++)
    00747     {
    00748       use = Uses[use_index];
    00749
    00750       if (use == use1)
    00751         {
    00752           found = 1;
    00753           break;
    00754         }
    00755     }
    00756
    00757   if (!found) return;
    00758
    00759   //
    00760   // On deplace tous les pointeurs d'une case en arriere
    00761   //
    00762   for (use_index++;
    00763        use_index < Uses.size ();
    00764        use_index++)
    00765     {
    00766       Uses[use_index - 1] = Uses[use_index];
    00767     }
    00768
    00769   //
    00770   // use1 est donc replace en derniere position
    00771   //
    00772   {
    00773     Uses[Uses.size () - 1] = use1;
    00774   }
    00775 }

bool Use::move_to ( | )

| Definition at line 1226 of file cmt_use.cxx. Referenced by add(), and Cmt::reach_current_package().
    01227 {
    01228   if (m_located)
    01229     {
    01230       //
    01231       // The real path where this version/package can be found
    01232       // has already been resolved. We thus first go there.
    01233       //
    01234
    01235       if (Cmt::get_debug ())
    01236         {
    01237           cout << "move_to1> " << real_path << endl;
    01238         }
    01239
    01240       reach_package (real_path);
    01241
    01242       return (true);
    01243     }
    01244
    01245   cmt_string expanded_path = path;
    01246
    01247   //
    01248   // Try here.
    01249   //
    01250   if (expanded_path == "")
    01251     {
    01252       if (reach_package (""))
    01253         {
    01254           if (Cmt::get_debug ())
    01255             {
    01256               cout << "move_to2> " << expanded_path << endl;
    01257             }
    01258
    01259           change_path (expanded_path);
    01260
    01261           return (true);
    01262         }
    01263       else if (alternate_versions.size () > 0)
    01264         {
    01265           if (select_alternate ())
    01266             {
    01267               if (Cmt::get_debug ())
    01268                 {
    01269                   cout << "move_to5> " << real_path << endl;
    01270                 }
    01271
    01272               return (true);
    01273             }
    01274         }
    01275     }
    01276
    01277   //
    01278   // If the path specified in this use is a true absolute path,
    01279   // then we search the package from there first.
    01280   //
    01281   if (CmtSystem::absolute_path (expanded_path))
    01282     {
    01283       if (reach_package (expanded_path))
    01284         {
    01285           if (Cmt::get_debug ())
    01286             {
    01287               cout << "move_to3> " << expanded_path << endl;
    01288             }
    01289
    01290           change_path (expanded_path);
    01291
    01292           return (true);
    01293         }
    01294       else if (alternate_versions.size () > 0)
    01295         {
    01296           if (select_alternate ())
    01297             {
    01298               if (Cmt::get_debug ())
    01299                 {
    01300                   cout << "move_to5> " << real_path << endl;
    01301                 }
    01302
    01303               return (true);
    01304             }
    01305         }
    01306     }
    01307
    01308   //
    01309   // Second try is among the CMTPATHs
    01310   //
    01311
    01312   static const CmtSystem::cmt_string_vector& search_path = Cmt::get_cmt_path ();
    01313   int path_index = 0;
    01314
    01315   for (path_index = 0; path_index < search_path.size (); path_index++)
    01316     {
    01317       const cmt_string& next_path = search_path[path_index];
    01318
    01319       alternate_versions.clear ();
    01320       alternate_paths.clear ();
    01321
    01322       if (reach_package (next_path))
    01323         {
    01324           if (Cmt::get_debug ())
    01325             {
    01326               cout << "move_to4> " << next_path << endl;
    01327             }
    01328
    01329           change_path (next_path);
    01330
    01331           return (true);
    01332         }
    01333       else if (alternate_versions.size () > 0)
    01334         {
    01335           if (select_alternate ())
    01336             {
    01337               if (Cmt::get_debug ())
    01338                 {
    01339                   cout << "move_to5> " << real_path << endl;
    01340                 }
    01341
    01342               return (true);
    01343             }
    01344         }
    01345     }
    01346
    01347
    01348   return (false);
    01349 }

bool Use::need_new ( | const cmt_string & path,
| const cmt_string & package,
| const cmt_string & version,
| Use ** old_use )`[static, private]`

| Definition at line 1447 of file cmt_use.cxx. Referenced by add().
    01451 {
    01452   bool has_wild_card = (version.find ("*") != cmt_string::npos);
    01453
    01454   static UsePtrVector& Uses = uses ();
    01455   static UseVector& AllUses = all_uses ();
    01456
    01457   bool result = true;
    01458   Use* found = 0;
    01459
    01460   int use_index;
    01461
    01462   if (old_use != 0) *old_use = 0;
    01463   if (AllUses.size () == 0) return (true);
    01464
    01465   for (use_index = 0; use_index < Uses.size (); use_index++)
    01466     {
    01467       Use& use = (*Uses[use_index]);
    01468
    01469       if (use.package != package) continue;
    01470
    01471       found = &use;
    01472
    01473       /*
    01474         cerr << "Use::need_new> (" << package
    01475         << ") requested version=" << version
    01476         << " vs existing=" << use->version
    01477         << " (specified as " << use->specified_version
    01478         << ")" << endl;
    01479       */
    01480
    01481       bool use_has_wild_card = (use.specified_version.find ("*") != cmt_string::npos);
    01482
    01483       if (has_wild_card && !use_has_wild_card)
    01484         {
    01485           //cerr << "  ... requested wildcarded loses against existing explicit" << endl;
    01486           result = false;
    01487           break;
    01488         }
    01489
    01490       if ((version == use.specified_version) &&
    01491           (path == use.specified_path))
    01492         {
    01493           // exactly same version and path!
    01494           result = false;
    01495           break;
    01496         }
    01497
    01498       // requested explicit wins against existing wildcarded
    01499       // In any case when paths are different, consider the new one.
    01500       // Now paths are identical (thus versions are different).
    01501     }
    01502
    01503   if (old_use != 0) *old_use = found;
    01504   return (result);
    01505 }

int Use::reach_package ( | const cmt_string & from_path )`[private]`

| Definition at line 1056 of file cmt_use.cxx. Referenced by move_to(), and select_alternate().
    01057 {
    01058   //cerr << "Use::reach_package> (" << package << " " << version << ")from " << from_path << endl;
    01059
    01060   //
    01061   // We try to reach a package/version starting from from_path
    01062   //
    01063
    01064   // check if from_path is at least real
    01065   if ((from_path != "") && !CmtSystem::cd (from_path)) return (0);
    01066
    01067   // check in case from_path is a new search path
    01068   if (from_path != real_path)
    01069     {
    01070       // Move to that prefix only if it is a relative path.
    01071       if ((path.size () > 0) && (!CmtSystem::absolute_path (path)))
    01072         {
    01073           if (!CmtSystem::cd (path))
    01074             {
    01075               return (0);
    01076             }
    01077         }
    01078     }
    01079
    01080   // Special treatment for CMTHOME package...
    01081   if (package == CmtSystem::get_home_package ())
    01082     {
    01083       discarded = 1;
    01084       if (!CmtSystem::test_file ("requirements"))
    01085         {
    01086           return (0);
    01087         }
    01088       else
    01089         {
    01090           return (1);
    01091         }
    01092     }
    01093
    01094   // Special treatment for CMTUSERCONTEXT package...
    01095   if (package == CmtSystem::get_user_context_package ())
    01096     {
    01097       discarded = 1;
    01098       if (!CmtSystem::test_file ("requirements"))
    01099         {
    01100           return (0);
    01101         }
    01102       else
    01103         {
    01104           return (1);
    01105         }
    01106     }
    01107
    01108   // Now from_path exists, try if the package exists there
    01109   if (!CmtSystem::cd (package))
    01110     {
    01111       return (0);
    01112     }
    01113
    01114   if (!CmtSystem::cd (version))
    01115     {
    01116       //
    01117       // The specified version cannot be found per-se
    01118       // There are alternate possibilities when it contains wild cards
    01119       //
    01120       if ((version == "") ||
    01121           (version.find ("*") != cmt_string::npos))
    01122         {
    01123           static CmtSystem::cmt_string_vector versions;
    01124           static cmt_string name;
    01125
    01126           name = ".";
    01127           name += CmtSystem::file_separator ();
    01128           if (version == "") name += "*";
    01129           else name += version;
    01130
    01131           CmtSystem::scan_dir (name, versions);
    01132
    01133           int i;
    01134           bool found = false;
    01135
    01136           for (i = 0; i < versions.size (); i++)
    01137             {
    01138               const cmt_string& vers = versions[i];
    01139
    01140               if (Cmt::get_debug ())
    01141                 {
    01142                   cout << "     ... version " << vers << " exists" << endl;
    01143                 }
    01144
    01145               CmtSystem::basename (vers, name);
    01146
    01147               int v;
    01148               int r;
    01149               int p;
    01150
    01151               if (CmtSystem::is_version_directory (name, v, r, p))
    01152                 {
    01153                   /*
    01154                     This check is not sufficient !! We need to check in addition
    01155                     that the selected directory is really the start of a true CMT
    01156                     package (ie with either /mgr/requirements or /cmt/requirements below)
    01157                   */
    01158
    01159                   cmt_string req;
    01160
    01161                   req = name;
    01162                   req += CmtSystem::file_separator ();
    01163                   req += "mgr";
    01164                   req += CmtSystem::file_separator ();
    01165                   req += "requirements";
    01166
    01167                   if (!CmtSystem::test_file (req))
    01168                     {
    01169                       req = name;
    01170                       req += CmtSystem::file_separator ();
    01171                       req += "cmt";
    01172                       req += CmtSystem::file_separator ();
    01173                       req += "requirements";
    01174
    01175                       if (!CmtSystem::test_file (req)) continue;
    01176                     }
    01177
    01178                   cmt_string& new_v = alternate_versions.add ();
    01179                   new_v = name;
    01180                   cmt_string& new_p = alternate_paths.add ();
    01181                   new_p = from_path;
    01182
    01183                   found = true;
    01184                 }
    01185             }
    01186         }
    01187
    01188       if (Cmt::get_debug ())
    01189         {
    01190           cout << "  ... end of version scan" << endl;
    01191         }
    01192
    01193         //
    01194         //  We have now the list of possible alternate versions. However
    01195         // we return that the expected package/version was not found (yet).
    01196         //
    01197
    01198       return (0);
    01199     }
    01200
    01201   //cerr << "  ... version " << version << " exists" << endl;
    01202
    01203   // Now we have met the exact specified version!
    01204   if (!CmtSystem::test_file ("cmt/requirements"))
    01205     {
    01206       if (!CmtSystem::test_file ("mgr/requirements"))
    01207         {
    01208           return (0);
    01209         }
    01210       else
    01211         {
    01212           CmtSystem::cd ("mgr");
    01213           style = mgr_style;
    01214         }
    01215     }
    01216   else
    01217     {
    01218       CmtSystem::cd ("cmt");
    01219       style = cmt_style;
    01220     }
    01221
    01222   return (1);
    01223 }

void Use::reduce_path ( | cmt_string & s ) const

| Considering a given path, try and reduce the part of it that corresponds to the full path of this package into its normal form ${<PACKAGE>ROOT} The argument is modified if the pattern is exactly found. Definition at line 1921 of file cmt_use.cxx. Referenced by Fragment::print().
    01922 {
    01923   cmt_string pattern;
    01924   get_full_path (pattern);
    01925   pattern += CmtSystem::file_separator ();
    01926
    01927   cmt_string replacement = "${";
    01928   replacement += prefix;
    01929   replacement += "ROOT}";
    01930
    01931   s.replace (pattern, replacement);
    01932 }

void Use::reorder ( | Use * use1,
| Use * use2 )`[static]`

| Reorder use1 versus use2 in the UsePtrVector list, so that the order reflects the fact that use2 makes use of use1. The result should be that use1 appears before use2 in the list. Definition at line 782 of file cmt_use.cxx. Referenced by use_action_iterator::get_use().
    00783 {
    00784   static UsePtrVector& Uses = uses ();
    00785
    00786   int use_index;
    00787   int index1 = -1;
    00788   int index2 = -1;
    00789   Use* use;
    00790
    00791   if (Uses.size () == 0) return;
    00792   if (use1 == use2) return;
    00793
    00794   //
    00795   // First locate the two use objects into the Uses vector.
    00796   //   -> index1 and index 2
    00797   //
    00798   for (use_index = 0; use_index < Uses.size (); use_index++)
    00799     {
    00800       use = (Use*) Uses[use_index];
    00801
    00802       if (use == use1) index1 = use_index;
    00803       if (use == use2) index2 = use_index;
    00804     }
    00805
    00806   if (Cmt::get_debug ())
    00807     {
    00808       cout << "Use::reorder> 1=" << index1 << " 2=" << index2 << endl;
    00809     }
    00810
    00811   //
    00812   // Both objects must be installed in Uses before acting.
    00813   //
    00814   if (index1 == -1) return;
    00815   if (index2 == -1) return;
    00816
    00817   if (index2 < index1)
    00818     {
    00819       //
    00820       // 2 is already before 1 so job is finished
    00821       //
    00822       return;
    00823     }
    00824   else
    00825     {
    00826       //
    00827       // before : <a a a 1 b b b 2 c c c>
    00828       //                 ^       ^
    00829       //                 i1      i2
    00830       //
    00831       //  1) move "1 b b b" by one place to the right
    00832       // thus :   <a a a 1 1 b b b c c c>
    00833       //
    00834       //  2) move "2" to [i1]
    00835       //
    00836       // after  : <a a a 2 1 b b b c c c>
    00837       //
    00838
    00839       use = use2;
    00840
    00841       for (use_index = index2 - 1; use_index >= index1; use_index--)
    00842         {
    00843           Uses[use_index + 1] = Uses[use_index];
    00844         }
    00845
    00846       Uses[index1] = use;
    00847     }
    00848 }

void Use::select ( | )`[private]`

| Definition at line 1806 of file cmt_use.cxx. Referenced by select_clients().
    01807 {
    01808   selected = true;
    01809 }

bool Use::select_alternate ( | )`[private]`

| Definition at line 1352 of file cmt_use.cxx. Referenced by move_to().
    01353 {
    01354   int i;
    01355
    01356   int v0 = 0;
    01357   int r0 = 0;
    01358   int p0 = 0;
    01359
    01360   int v = 0;
    01361   int r = 0;
    01362   int p = 0;
    01363
    01364   int selected_index = -1;
    01365
    01366   for (i = 0; i < alternate_versions.size (); i++)
    01367     {
    01368       cmt_string& name = alternate_versions[i];
    01369
    01370         /*
    01371       if (CmtSystem::getenv ("CMTTESTUSEWILDCARDS") != "")
    01372         {
    01373           cout << "select_alternate[" << this << "]> package " << package <<
    01374               " sv=" << specified_version <<
    01375               " v=" << version <<
    01376               " av[" << i << "]=" << name << endl;
    01377         }
    01378         */
    01379
    01380       if (i == 0)
    01381         {
    01382           CmtSystem::is_version_directory (name, v0, r0, p0);
    01383           selected_index = 0;
    01384         }
    01385       else
    01386         {
    01387           CmtSystem::is_version_directory (name, v, r, p);
    01388
    01389           if (v > v0)
    01390             {
    01391               selected_index = i;
    01392               v0 = v;
    01393               r0 = r;
    01394               p0 = p;
    01395             }
    01396           else if (v == v0)
    01397             {
    01398               if (r > r0)
    01399                 {
    01400                   selected_index = i;
    01401                   r0 = r;
    01402                   p0 = p;
    01403                 }
    01404               else if (r == r0)
    01405                 {
    01406                   if (p > p0)
    01407                     {
    01408                       selected_index = i;
    01409                       p0 = p;
    01410                     }
    01411                 }
    01412             }
    01413         }
    01414     }
    01415
    01416   if (selected_index >= 0)
    01417     {
    01418       if (CmtSystem::cd (alternate_paths[selected_index]))
    01419         {
    01420           version = alternate_versions[selected_index];
    01421           if (reach_package (alternate_paths[selected_index]))
    01422             {
    01423                 /*
    01424               if (CmtSystem::getenv ("CMTTESTUSEWILDCARDS") != "")
    01425                 {
    01426                   cout << "select_alternate2> package " << package <<
    01427                       " sv=" << specified_version <<
    01428                       " v=" << version << endl;
    01429                 }
    01430                 */
    01431
    01432               if (Cmt::get_debug ())
    01433                 {
    01434                   cout << "select_alternate> " << alternate_paths[selected_index] << endl;
    01435                 }
    01436
    01437               change_path (alternate_paths[selected_index]);
    01438               return (true);
    01439             }
    01440         }
    01441     }
    01442
    01443   return (false);
    01444 }

void Use::select_clients ( | const cmt_string & package,
| const cmt_string & version )`[static]`

| Mark all clients of the current package. Definition at line 148 of file cmt_use.cxx.
    00150 {
    00151   static UsePtrVector& Uses = uses ();
    00152
    00153   int number;
    00154   Use* use = 0;
    00155
    00156   unselect_all ();
    00157   undiscard_all ();
    00158
    00159   for (number = Uses.size () - 1; number >= 0; number--)
    00160     {
    00161       use = Uses[number];
    00162       if (use == 0) continue;
    00163       if (use->is_selected ()) continue;
    00164       use->select ();
    00165       if (!use->is_client (package, version)) use->discard ();
    00166     }
    00167 }

void Use::set ( | const cmt_string & new_package,
| const cmt_string & new_version,
| const cmt_string & new_path,
| const cmt_string & new_version_alias = "",
| const cmt_string & new_path_alias = "" )

| Definition at line 999 of file cmt_use.cxx. Referenced by Use(), Cmt::configure(), create(), Cmt::do_config(), Cmt::parse_arguments(), and Cmt::select().
    01004 {
    01005   clear ();
    01006
    01007   package           = new_package;
    01008   specified_path    = new_path;
    01009   // specified_path.replace_all ("\\", "/");
    01010
    01011   specified_version = new_version;
    01012   version           = new_version;
    01013   path              = specified_path;
    01014   Symbol::expand (path);
    01015   real_path         = "";
    01016   style             = mgr_style;
    01017   scope             = Cmt::get_scope ();
    01018   done              = false;
    01019   discarded         = false;
    01020   Cmt::build_prefix (new_package, prefix);
    01021
    01022   version_alias = new_version_alias;
    01023   path_alias    = new_path_alias;
    01024 }

void Use::set_auto_imports ( | State new_state )

| Definition at line 1999 of file cmt_use.cxx. Referenced by use_action_iterator::get_use().
    02000 {
    02001   if (Cmt::get_debug ())
    02002     {
    02003       cout << "Use::set_auto_imports>(" << package << ") "
    02004            << auto_imports << " -> " << new_state << endl;
    02005     }
    02006
    02007   if (auto_imports == new_state) return;
    02008
    02009   State old_state = auto_imports;
    02010
    02011   auto_imports = new_state;
    02012
    02013     // We propagate only when we switch from Off to On
    02014
    02015   if ((old_state == Off) && (new_state == On))
    02016     {
    02017       cmt_string s;
    02018       static const cmt_string state_text[] = {"Unspecified", "Off", "On"};
    02019
    02020       if (Cmt::get_debug ())
    02021         {
    02022           s = "Use::set_auto_imports>(";
    02023           s += package;
    02024           s += ") ";
    02025
    02026           cout << s << endl;
    02027         }
    02028
    02029       for (int i = 0; i < sub_uses.size (); i++)
    02030         {
    02031           Use* u = sub_uses[i];
    02032           State state = sub_use_auto_imports[i];
    02033
    02034           if (Cmt::get_debug ())
    02035             {
    02036               s += " ";
    02037               s += u->package;
    02038               s += "(";
    02039               s += state_text[state];
    02040               s += ")";
    02041             }
    02042
    02043           if (state == Unspecified)
    02044             {
    02045               u->set_auto_imports (On);
    02046             }
    02047         }
    02048
    02049       if (Cmt::get_debug ())
    02050         {
    02051           cout << s << endl;
    02052         }
    02053     }
    02054 }

void Use::set_auto_imports_state ( | int use_index,
| cmt_vector< bool >& auto_imports_states )`[static]`

| 1) Given a Use object identified by its index in the uses() array, 2) Given a vector of states containing the auto_imports states of all Uses,. we want to switch to 'On' the auto_imports states of all sub_uses of the argument that were Off. Definition at line 682 of file cmt_use.cxx. Referenced by StandardMacroBuilder::fill_for_all_constituents().
    00684 {
    00685   // check if this is already done (recursivity ending)
    00686   if (auto_imports_states[use_index]) return;
    00687
    00688   Use::UsePtrVector& Uses = Use::uses ();
    00689   Use* use = Uses[use_index];
    00690
    00691   // Is this a mistake? we only have to deal with Use objects that were
    00692   // actually turned Off
    00693   if (use->auto_imports != Off) return;
    00694
    00705   auto_imports_states[use_index] = true;
    00706
    00707   for (int i = 0; i < use->sub_uses.size (); i++)
    00708     {
    00709       Use* u = use->sub_uses[i];
    00710
    00711       if (u->sub_use_auto_imports[i] == Off)
    00712         {
    00713           int j;
    00714
    00715           // first find the index of this use.
    00716
    00717           for (j = 0; j < Uses.size(); j++)
    00718             {
    00719               if (u == Uses[j]) break;
    00720             }
    00721
    00722           set_auto_imports_state (j, auto_imports_states);
    00723         }
    00724     }
    00725 }

void Use::set_include_path ( | const cmt_string & new_path )

| Definition at line 1878 of file cmt_use.cxx. Referenced by Cmt::select().
    01879 {
    01880   include_path = new_path;
    01881 }

void Use::set_native_version ( | bool state )

| Definition at line 2056 of file cmt_use.cxx. Referenced by Symbol::action().
    02057 {
    02058   m_has_native_version = state;
    02059 }

void Use::show_all ( | const cmt_string & prefix,
| bool skip_discarded = false )`[static]`

| Definition at line 176 of file cmt_use.cxx.
    00177 {
    00178   static UsePtrVector& Uses = uses ();
    00179
    00180   Use* use;
    00181   int number;
    00182
    00183   unselect_all ();
    00184
    00185   use = &(current ());
    00186   use->unselect ();
    00187   if (!Cmt::get_quiet ()) use->show_sub_uses (skip_discarded);
    00188
    00189   if (Uses.size () > 0)
    00190     {
    00191       if (!Cmt::get_quiet ())
    00192         {
    00193           cout << "#\n";
    00194           cout << "# Selection :\n";
    00195         }
    00196
    00197       //
    00198       //  First move the CMT package to the end of the use set.
    00199       //  (ie. used by everybody)
    00200       //
    00201       use = Use::find ("CMT");
    00202       Use::move (use);
    00203
    00204       for (number = Uses.size () - 1; number >= 0; number--)
    00205         {
    00206           use = Uses[number];
    00207
    00208           if (use->discarded) continue;
    00209
    00210           if (!use->located ())
    00211             {
    00212               if (!Cmt::get_quiet ())
    00213                 {
    00214                   cout << "# package " << use->package <<
    00215                       " " << use->version << " " << use->path <<
    00216                       " not found" <<
    00217                       endl;
    00218                 }
    00219               CmtError::set (CmtError::package_not_found, use->package);
    00220             }
    00221           else
    00222             {
    00223               static const cmt_string empty;
    00224               cmt_string p = use->real_path;
    00225               if (use->path != "")
    00226                 {
    00227                   p.replace (use->path, empty);
    00228                 }
    00229
    00230               cout << prefix << use->package <<
    00231                   " " << use->version <<
    00232                   " " << use->path;
    00233
    00234               if (!Cmt::get_quiet ())
    00235                 {
    00236                   if (p != "") cout << " (" << p << ")";
    00237                   if (use->auto_imports == Off) cout << " (no_auto_imports)";
    00238                 }
    00239
    00240               cout << endl;
    00241             }
    00242         }
    00243
    00244       if (Cmt::get_cmt_home () != "")
    00245         {
    00246           cout << prefix << CmtSystem::get_home_package () <<
    00247               " " << Cmt::get_cmt_home () <<
    00248               endl;
    00249         }
    00250
    00251       if (Cmt::get_cmt_user_context () != "")
    00252         {
    00253           cout << prefix << CmtSystem::get_user_context_package () <<
    00254               " " << Cmt::get_cmt_user_context () <<
    00255               endl;
    00256         }
    00257     }
    00258 }

void Use::show_all ( | bool skip_discarded = false )`[static]`

| Definition at line 170 of file cmt_use.cxx. Referenced by Cmt::do_show_uses().
    00171 {
    00172   show_all ("use ", skip_discarded);
    00173 }

void Use::show_sub_uses ( | bool skip_discarded = false )`[private]`

| Definition at line 2209 of file cmt_use.cxx. Referenced by show_all().
    02210 {
    02211   int n;
    02212   Use* use;
    02213   static int level = 0;
    02214
    02215   if (skip_discarded && discarded) return;
    02216
    02217   if (level > 0)
    02218     {
    02219       cout << "# ";
    02220       for (n = 0; n < (level-1); n++) cout << "  ";
    02221
    02222       cout << "use " << package << " " << specified_version;
    02223
    02224       if (specified_path != "") cout << " " << specified_path;
    02225
    02226       if (version_alias != "")
    02227         {
    02228           cout << " | " << version_alias << " " << path_alias;
    02229         }
    02230
    02231       if (scope == ScopeUnspecified) cout << " unspecified";
    02232       else if (scope != ScopePublic) cout << " (private)";
    02233       //else cout << " private";
    02234
    02235       if (auto_imports == Off) cout << " (no_auto_imports)";
    02236
    02237       if (m_has_native_version)
    02238         {
    02239           cmt_string n = package;
    02240           n += "_native_version";
    02241
    02242           Symbol* s = Symbol::find (n);
    02243           if (s != 0)
    02244             {
    02245               cmt_string value = s->resolve_macro_value ();
    02246               cout << " (native_version=" << value << ")";
    02247             }
    02248         }
    02249
    02250       cout << endl;
    02251     }
    02252
    02253   if (selected) return;
    02254   selected = true;
    02255
    02256   level++;
    02257   for (n = 0; n < sub_uses.size (); n++)
    02258     {
    02259       use = sub_uses[n];
    02260       if (use == 0) continue;
    02261
    02262       ScopeType saved_scope = use->scope;
    02263       State saved_state = use->auto_imports;
    02264
    02265       use->scope = sub_use_scopes[n];
    02266       use->auto_imports = sub_use_auto_imports[n];
    02267
    02268       use->show_sub_uses (skip_discarded);
    02269
    02270       use->scope = saved_scope;
    02271       use->auto_imports = saved_state;
    02272     }
    02273   level--;
    02274 }

void Use::undiscard ( | )

| Definition at line 1800 of file cmt_use.cxx. Referenced by KeepAllSelector::operate(), LastChoiceSelector::operate(), FirstChoiceSelector::operate(), BestFitNoCheckSelector::operate(), BestFitSelector::operate(), and undiscard_all().
    01801 {
    01802   discarded = false;
    01803 }

void Use::undiscard_all ( | )`[static]`

| Definition at line 889 of file cmt_use.cxx. Referenced by select_clients().
    00890 {
    00891   static UsePtrVector& Uses = uses ();
    00892
    00893   int use_index;
    00894
    00895   if (Uses.size () == 0) return;
    00896
    00897   for (use_index = 0; use_index < Uses.size (); use_index++)
    00898     {
    00899       Use* use = Uses[use_index];
    00900
    00901       if (use != 0)
    00902         {
    00903           use->undiscard ();
    00904         }
    00905     }
    00906 }

void Use::unselect ( | )`[private]`

| Definition at line 1812 of file cmt_use.cxx. Referenced by show_all(), and unselect_all().
    01813 {
    01814   selected = false;
    01815 }

void Use::unselect_all ( | )`[static]`

| Definition at line 869 of file cmt_use.cxx. Referenced by select_clients(), and show_all().
    00870 {
    00871   static UsePtrVector& Uses = uses ();
    00872
    00873   int use_index;
    00874
    00875   if (Uses.size () == 0) return;
    00876
    00877   for (use_index = 0; use_index < Uses.size (); use_index++)
    00878     {
    00879       Use* use = Uses[use_index];
    00880
    00881       if (use != 0)
    00882         {
    00883           use->unselect ();
    00884         }
    00885     }
    00886 }

Use::UsePtrVector & Use::uses ( | )`[static]`

| Definition at line 2309 of file cmt_use.cxx. Referenced by add(), Script::all_print(), Script::all_print_clean(), Pattern::apply(), Generator::build_make_setup(), Generator::build_readme(), clear_all(), Cmt::do_broadcast(), Cmt::do_build_library_links(), Cmt::do_remove_library_links(), StandardMacroBuilder::fill_for_all_constituents(), StandardMacroBuilder::fill_for_fincludes(), StandardMacroBuilder::fill_for_includes(), StandardMacroBuilder::fill_for_use_cflags(), StandardMacroBuilder::fill_for_use_cppflags(), StandardMacroBuilder::fill_for_use_fflags(), StandardMacroBuilder::fill_for_use_fincludes(), StandardMacroBuilder::fill_for_use_includes(), StandardMacroBuilder::fill_for_use_libraries(), StandardMacroBuilder::fill_for_use_linkopts(), StandardMacroBuilder::fill_for_use_pp_cflags(), StandardMacroBuilder::fill_for_use_pp_cppflags(), StandardMacroBuilder::fill_for_use_pp_fflags(), StandardMacroBuilder::fill_for_use_requirements(), StandardMacroBuilder::fill_for_use_stamps(), StandardMacroBuilder::fill_for_uses(), fill_macro_all(), find(), Pattern::find(), find_index(), get_selected_version(), use_action_iterator::get_use(), move(), need_new(), MakefileGenerator::prepare_use_context(), Cmt::print(), Include::print_all(), Cmt::print_clean(), Include::print_filters(), reorder(), UseAnalyzer::run(), select_clients(), set_auto_imports_state(), Cmt::set_standard_macros(), Pattern::show(), show_all(), undiscard_all(), and unselect_all().
    02310 {
    02311   static Database& db = Database::instance ();
    02312   static UsePtrVector& Uses = db.uses ();
    02313
    02314   return (Uses);
    02315 }

## Member Data Documentation

CmtSystem::cmt_string_vector Use::alternate_paths`[private]`

| Definition at line 139 of file cmt_use.h.

CmtSystem::cmt_string_vector Use::alternate_versions`[private]`

| Definition at line 138 of file cmt_use.h.

ApplyPattern::ApplyPatternVector Use::apply_patterns

| Definition at line 111 of file cmt_use.h.

cmt_string Use::author

| Definition at line 91 of file cmt_use.h.

State Use::auto_imports

| Definition at line 106 of file cmt_use.h.

bool Use::discarded

| Definition at line 103 of file cmt_use.h.

bool Use::done

| Definition at line 101 of file cmt_use.h.

IgnorePattern::IgnorePatternVector Use::ignore_patterns

| Definition at line 112 of file cmt_use.h.

cmt_string Use::include_path

| Definition at line 109 of file cmt_use.h.

Include::IncludeVector Use::includes

| Definition at line 108 of file cmt_use.h.

bool Use::m_has_native_version`[private]`

| Definition at line 132 of file cmt_use.h.

bool Use::m_located`[private]`

| Definition at line 131 of file cmt_use.h.

cmt_string Use::manager

| Definition at line 92 of file cmt_use.h.

cmt_string Use::package

| Definition at line 86 of file cmt_use.h.

cmt_string Use::path

| Definition at line 94 of file cmt_use.h.

cmt_string Use::path_alias

| Definition at line 90 of file cmt_use.h.

cmt_string Use::prefix

| Definition at line 99 of file cmt_use.h.

cmt_string Use::real_path

| Definition at line 96 of file cmt_use.h.

ScopeType Use::scope

| Definition at line 100 of file cmt_use.h.

Script::ScriptVector Use::scripts

| Definition at line 110 of file cmt_use.h.

bool Use::selected

| Definition at line 104 of file cmt_use.h.

cmt_string Use::specified_path

| Definition at line 88 of file cmt_use.h.

cmt_string Use::specified_version

| Definition at line 87 of file cmt_use.h.

CmtDirStyle Use::style

| Definition at line 97 of file cmt_use.h.

cmt_vector< State > Use::sub_use_auto_imports`[private]`

| Definition at line 136 of file cmt_use.h.

cmt_vector< ScopeType > Use::sub_use_scopes`[private]`

| Definition at line 135 of file cmt_use.h.

UsePtrVector Use::sub_uses`[private]`

| Definition at line 134 of file cmt_use.h.

cmt_string Use::version

| Definition at line 95 of file cmt_use.h.

cmt_string Use::version_alias

| Definition at line 89 of file cmt_use.h.

The documentation for this class was generated from the following files:

- cmt_use.h
- cmt_use.cxx