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

Use Class Reference

#include <cmt_use.h>

Collaboration diagram for Use:

Collaboration graph
[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 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 = "")
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)
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 ()
UseVectorall_uses ()
UsePtrVectoruses ()
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<ScopeTypesub_use_scopes
cmt_vector<Statesub_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 833 of file cmt_use.cxx.

00834 {
00835   done = false;
00836   discarded = false;
00837   auto_imports = Unspecified;
00838 
00839   clear ();
00840 }

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

Definition at line 843 of file cmt_use.cxx.

00846 {
00847   auto_imports = Unspecified;
00848   m_located = false;
00849   set (new_package, new_version, new_path);
00850 }

Use::~Use ( )
 

Definition at line 853 of file cmt_use.cxx.

00854 {
00855   clear ();
00856 }


Member Function Documentation

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

Definition at line 512 of file cmt_use.cxx.

Referenced by Cmt::select().

00513 {
00514   Use* new_use;
00515 
00516   //
00517   // complete syntax : "use <package> <version> <path>"
00518   // minimal syntax  : "use <package>"
00519   //
00520   //  o if <version> is omitted then take any version available
00521   //  o <version> can be specified using "v*" or "v<n>r*" or "v<n>r<m>p*"
00522   //
00523   //  o the notation "v*" is preferred to omission (particularly since
00524   //    omission does not permit <path>)
00525   //
00526   if (words.size () < 2) return (0);
00527 
00528   use_action_iterator it;
00529 
00530   for (int i = 1; i < words.size (); i++)
00531     {
00532       const cmt_string& w = words[i];
00533       cmt_string ew = w;
00534 
00535       Symbol::expand (ew);
00536       if (ew != w)
00537         {
00538           CmtSystem::cmt_string_vector ws;
00539 
00540           CmtSystem::split (ew, " ", ws);
00541 
00542           for (int j = 0; j < ws.size (); ++j)
00543             {
00544               const cmt_string& ww = ws[j];
00545               it.set (ww);
00546             }
00547         }
00548       else
00549         {
00550           it.set (ew);
00551         }
00552     }
00553 
00554   if (!it.ok ()) return (0);
00555 
00556   static int level = 0;
00557 
00558   level++;
00559   new_use = it.get_use (parent);
00560   level--;
00561 
00562   return (new_use);
00563 }

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 1444 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().

01451 {
01452   static UsePtrVector& Uses = uses ();
01453 
01454   bool do_need_new = false;
01455 
01456   Use* old_use = 0;
01457   Use* use = 0;
01458 
01459   do_need_new = need_new (path, package, version, &old_use);
01460 
01461   /*
01462     if (old_use != 0)
01463     {
01464     cout << "add> old_use " << old_use->package <<
01465     " " << old_use->version <<
01466     " " << old_use->path <<
01467     endl;
01468     }
01469   */
01470 
01471   if (do_need_new)
01472     {
01473       use = create (path, package, version, version_alias, path_alias);
01474     }
01475   else
01476     {
01477       // Since we don't need a new Use, it means that old_use exists !
01478       use = old_use;
01479       old_use = 0;
01480     }
01481 
01482   if (package == CmtSystem::get_home_package ())
01483     {
01484       return (use);
01485     }
01486 
01487   if (package == CmtSystem::get_user_context_package ())
01488     {
01489       return (use);
01490     }
01491 
01492   cmt_string here = CmtSystem::pwd ();
01493 
01494     //
01495     // Store the specified sub_uses. Some of them may become discarded
01496     // later on.
01497     //
01498   if (context_use != 0)
01499     {
01500       context_use->sub_uses.push_back (use);
01501       context_use->sub_use_scopes.push_back (Cmt::get_scope ());
01502       context_use->sub_use_auto_imports.push_back (specified_auto_imports);
01503 
01504       if (Cmt::get_debug ())
01505         {
01506           cout << "Use::add context(" << context_use->package << ") "
01507                << "[u:" << package
01508                << " s:" << Cmt::get_scope ()
01509                << " ai:" << specified_auto_imports
01510                << "]" << endl;
01511         }
01512     }
01513 
01514   /*
01515    *   Now we have a Use object. If it is a new one, we have to
01516    *    1) understand if it exists physically
01517    *    2) it is better than the old ones.
01518    *
01519    *   Here, we may have :
01520    *    1) old_use = 0 
01521    *         there was no Use object before for this package
01522    *         the existing one is fine
01523    *
01524    *    2) old_use != 0 
01525    *         we have created a new Use (which has to be validated)
01526    */
01527 
01528   bool found = use->move_to ();
01529 
01530   if (Cmt::get_debug ())
01531     {
01532       cout << "add> use " << use->package 
01533            << " " << use->version
01534            << " " << use->path
01535            << " found=" << found
01536            << endl;
01537     }
01538       
01539   if (!found)
01540     {
01541       if (!Cmt::get_quiet ())
01542         {
01543           cerr << "#(Warning) package " << use->package <<
01544             " " << use->version << " " << use->path << 
01545             " not found" <<
01546             endl;
01547         }
01548 
01549       CmtError::set (CmtError::package_not_found, use->package);
01550       use = 0;
01551     }
01552 
01553   if ((old_use != 0) && (use != old_use))
01554     {
01555       /*
01556        *    There was another version of this Use. But a new one was created due to 
01557        *   some criteria.
01558        *    New we are going to apply the version strategy to make the final selection.
01559        */
01560 
01561       /*
01562         if (CmtSystem::getenv ("CMTTESTUSEWILDCARDS") != "")
01563         {
01564         cout << "select? [" << use << "] vs old_use[" << old_use << "] " << old_use->package <<
01565         " " << old_use->version <<
01566         " " << old_use->path <<
01567         endl;
01568         }
01569       */
01570 
01571       if (!found)
01572         {
01573           /*
01574            *  This new Use does not correspond to any physical package.
01575            *  let's simply discard it 
01576            */
01577 
01578           use->discard ();
01579           use = old_use;
01580           found = use->move_to ();
01581         }
01582       else
01583         {
01584             //
01585             //  This new version is different from the old one
01586             // thus we have to choose
01587             //
01588           VersionSelector& selector = VersionSelector::instance ();
01589           Use* selected_use = selector.operate (old_use, use);
01590 
01591             //
01592             // Some situations managed by selector.operate happen
01593             // to fail discarding the rejected Use.
01594             //
01595           if (use != selected_use) 
01596             {
01597               use->discard ();
01598             }
01599           
01600           use = selected_use;
01601 
01602           /*
01603            *   current directory is moved to the selected one
01604            */
01605           found = use->move_to ();
01606         }
01607     }
01608 
01609     //
01610     // The following statement is no longer considered as useful.
01611     // It is commented. But we should clarify why it was really needed!
01612     //
01613     //use->undiscard ();
01614 
01615   if (found)
01616     {
01617       bool registered = false;
01618       const Use& cu = Use::current ();
01619 
01620       //
01621       // A pointer to this new object is also added or replaced.
01622       //
01623       if ((use != &cu) && (package == cu.package))
01624         {
01625             // This is a recursive call to the current package!!
01626           registered = true;
01627           use->done = true;
01628         }
01629       else
01630         {
01631           for (int i = 0; i < Uses.size(); i++)
01632             {
01633               Use* u = Uses[i];
01634               
01635               if (u->package == package)
01636                 {
01637                   registered = true;
01638                   Uses[i] = use;
01639                   break;
01640                 }
01641             }
01642         }
01643       
01644       if (!registered) Uses.push_back (use);
01645 
01646       if (!use->done && Cmt::get_recursive ())
01647         {
01648           use->done = true;
01649 
01650           /*
01651             if (CmtSystem::getenv ("CMTTESTUSEWILDCARDS") != "")
01652             {
01653             for (int use_index = 0; use_index < Uses.size (); use_index++)
01654             {
01655             Use* u = (Use*) Uses[use_index];
01656             cout << "  use[" << use_index << "] p=" << u->package <<
01657             " v=" << u->version <<
01658             " discarded=" << u->discarded <<
01659             " selected=" << u->selected <<
01660             endl;
01661             }
01662             
01663             cout << "parsing at " << CmtSystem::pwd () << endl;
01664             }
01665           */
01666           
01673           //Cmt::parse_requirements ("uses.log", use);
01674           
01675           if (Cmt::get_debug ())
01676             {
01677               cout << "Parsing requirements file at " << CmtSystem::pwd () << endl;
01678             }
01679           
01680           Cmt::parse_requirements ("requirements", use);
01681         }
01682     }
01683 
01684   CmtSystem::cd (here);
01685 
01686   return (use);
01687 }

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

Definition at line 2121 of file cmt_use.cxx.

Referenced by clear_all(), create(), current(), find(), and need_new().

02122 {
02123   static Database& db = Database::instance ();
02124   static UseVector& AllUses = db.all_uses ();
02125 
02126   return (AllUses);
02127 }

void Use::apply_global_patterns ( )
 

Definition at line 1756 of file cmt_use.cxx.

01757 {
01758   int i;
01759 
01760   Pattern::PatternVector& vector = Pattern::patterns ();
01761 
01762   for (i = 0; i < vector.size (); i++)
01763     {
01764       Pattern& p = vector[i];
01765 
01766       if (p.global)
01767         {
01768           p.apply (this);
01769         }
01770     }
01771 }

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

Definition at line 566 of file cmt_use.cxx.

Referenced by Cmt::select().

00567 {
00568   if (author != "") author += "\n";
00569   for (int i = 1; i < words.size (); i++)
00570     {
00571       const cmt_string& w = words[i];
00572       
00573       if (i > 1) author += " ";
00574       author += w;
00575     }
00576 }

void Use::change_path ( const cmt_string & new_path )
 

Definition at line 926 of file cmt_use.cxx.

Referenced by Cmt::configure(), Cmt::do_config(), move_to(), Cmt::select(), and select_alternate().

00927 {
00928   // 
00929   // This methods changes real_path after an actual location
00930   // where this package/version has been found.
00931   //
00932 
00933   real_path = "";
00934 
00935   if (new_path != "")
00936     {
00937       if ((path.size () > 0) &&
00938           (!CmtSystem::absolute_path (path)))
00939         {
00940           real_path = new_path;
00941           real_path += CmtSystem::file_separator ();
00942           real_path += path;
00943         }
00944       else
00945         {
00946           real_path = new_path;
00947         }
00948       // real_path.replace_all ("\\", "/");
00949     }
00950   
00951   m_located = true;
00952 }

void Use::clear ( ) [private]
 

Definition at line 859 of file cmt_use.cxx.

Referenced by Use(), clear_all(), set(), and ~Use().

00860 {
00861   specified_path = "";
00862   path      = "";
00863   package   = "";
00864   version   = "";
00865   author    = "";
00866   manager   = "";
00867   real_path = "";
00868 
00869   prefix    = "";
00870   style     = mgr_style;
00871   scope     = Cmt::get_scope ();
00872   done      = false;
00873   discarded = false;
00874   selected  = false;
00875   auto_imports = Unspecified;
00876 
00877   includes.clear ();
00878   include_path = "";
00879   scripts.clear ();
00880   apply_patterns.clear ();
00881   ignore_patterns.clear ();
00882 
00883   sub_uses.clear ();
00884   sub_use_scopes.clear ();
00885   sub_use_auto_imports.clear ();
00886 
00887   alternate_versions.clear ();
00888   alternate_paths.clear ();
00889 
00890   version_alias = "";
00891   path_alias    = "";
00892 
00893   m_located = false;
00894   m_has_native_version = false;
00895 }

void Use::clear_all ( ) [static]
 

Definition at line 750 of file cmt_use.cxx.

Referenced by Database::clear().

00751 {
00752   static UsePtrVector& Uses = uses ();
00753   static UseVector& AllUses = all_uses ();
00754 
00755   int use_index;
00756 
00757   for (use_index = 0; use_index < AllUses.size (); use_index++)
00758     {
00759       Use& use = AllUses[use_index];
00760       use.clear ();
00761     }
00762 
00763   Uses.clear ();
00764   AllUses.clear ();
00765 }

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

Definition at line 2113 of file cmt_use.cxx.

02114 {
02115   const Use& use = Use::current ();
02116 
02117   return (use);
02118 }

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 1409 of file cmt_use.cxx.

Referenced by add().

01414 {
01415   static UseVector& AllUses = all_uses ();
01416 
01417   // We first look in the database.
01418   for (int use_index = 0; use_index < AllUses.size (); use_index++)
01419     {
01420       Use& use = AllUses[use_index];
01421 
01422       if (use.package == package)
01423         {
01424           if ((use.specified_version == version) && 
01425               (use.specified_path == path)) return (&use);
01426         }
01427     }
01428 
01429   // We now really create a new Use entry.
01430 
01431   Use& use_object = AllUses.add ();
01432   use_object.set (package, version, path, version_alias, path_alias);
01433 
01434   return (&use_object);
01435 }

Use & Use::current ( ) [static]
 

Definition at line 2098 of file cmt_use.cxx.

Referenced by 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_lock(), Cmt::do_remove_library_links(), Cmt::do_show_author(), Cmt::do_show_include_dirs(), Cmt::do_show_manager(), Cmt::do_unlock(), Pattern::expand(), 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().

02099 {
02100   static UseVector& AllUses = all_uses ();
02101   static Use* current_use = 0;
02102 
02103   if ((current_use == 0) || (AllUses.size () == 0))
02104     {
02105       Use& use_object = AllUses.add ();
02106       current_use = &use_object;
02107     }
02108 
02109   return (*current_use);
02110 }

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 1690 of file cmt_use.cxx.

Referenced by add(), LastChoiceSelector::operate(), FirstChoiceSelector::operate(), BestFitNoCheckSelector::operate(), BestFitSelector::operate(), and select_clients().

01691 {
01692   discarded = true;
01693 }

void Use::fill_includes_macro ( cmt_string & buffer ) const
 

Definition at line 1780 of file cmt_use.cxx.

Referenced by Cmt::set_standard_macros().

01781 {
01782   if (include_path == "")
01783     {
01784       buffer += "$(ppcmd)\"$(";
01785       buffer += package;
01786       buffer += "_root)";
01787       buffer += CmtSystem::file_separator ();
01788       buffer += "src\" ";
01789     }
01790   else if (include_path != "none")
01791     {
01792       buffer += "$(ppcmd)\"";
01793       buffer += include_path;
01794       buffer += "\" ";
01795     }
01796   
01797   for (int i = 0; i < includes.size (); i++)
01798     {
01799       Include& incl = includes[i];
01800       
01801       buffer += "$(ppcmd)\"";
01802       buffer += incl.name;
01803       buffer += "\" ";
01804     }
01805 }

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

Definition at line 1808 of file cmt_use.cxx.

Referenced by fill_macro_all(), and Cmt::set_standard_macros().

01809 {
01810   buffer += " $(";
01811   buffer += package;
01812   buffer += "_";
01813   buffer += suffix;
01814   buffer += ") ";
01815 }

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

Definition at line 808 of file cmt_use.cxx.

Referenced by Cmt::set_standard_macros().

00809 {
00810   UsePtrVector& Uses = uses ();
00811 
00812   buffer = "macro_append use_";
00813   buffer += suffix;
00814   buffer += " \" ";
00815   (Use::current()).fill_macro (buffer, suffix);
00816 
00817   for (int number = 0; number < Uses.size (); number++)
00818     {
00819       Use* use = Uses[number];
00820       
00821       if (use->package == "CMT") continue;
00822       if (use->package == "methods") continue;
00823       if (use->discarded) continue;
00824       if (use->auto_imports == Off) continue;
00825 
00826       use->fill_macro (buffer, suffix);
00827     }
00828   
00829   buffer += "\"";
00830 }

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

Definition at line 592 of file cmt_use.cxx.

Referenced by Fragment::locate(), need_new(), Cmt::set_standard_macros(), and show_all().

00595 {
00596   static UsePtrVector& Uses = uses ();
00597   static UseVector& AllUses = all_uses ();
00598 
00599   int use_index;
00600 
00601   if (AllUses.size () == 0) return (0);
00602 
00603   for (use_index = 0; use_index < Uses.size (); use_index++)
00604     {
00605       Use& use = (*Uses[use_index]);
00606 
00607       if (use.package == package)
00608         {
00609             // If the version argument is omitted then
00610             // take the first registered version
00611           if (version == "") return (&use);
00612           
00613             // Otherwise compare against specified_version and path
00614             //if ((use.specified_version == version) && 
00615             //  (use.specified_path == path)) return (&use);
00616           
00617             // what about comparing wild cards?
00618 
00619           if (use.specified_version == version) return (&use);
00620         }
00621     }
00622 
00623   return (0);
00624 }

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

Definition at line 1912 of file cmt_use.cxx.

Referenced by Pattern::apply().

01913 {
01914   bool found = false;
01915   bool cycle = false;
01916 
01917   static int level = 0;
01918   static UsePtrVector stack;
01919 
01920   if (level == 0)
01921     {
01922       stack.clear ();
01923     }
01924 
01925   for (int k = 0; k < stack.size (); k++)
01926     {
01927       Use* u = stack[k];
01928       if (u == this) return (false);
01929     }
01930 
01931   if (stack.size () <= level)
01932     {
01933       stack.push_back (this);
01934     }
01935   else
01936     {
01937       stack[level] = this;
01938     }
01939 
01940     // First figure out whether 'to' is used by 'this'.
01941 
01942   if (Cmt::get_debug ())
01943     {
01944       cout << "Use::get_paths." << level << ">" << package << " list[" << list.size () << "]" << endl;
01945     }
01946 
01947   if (this == to)
01948     {
01949       found = true;
01950     }
01951   else
01952     {
01953       for (int n = 0; n < sub_uses.size (); n++)
01954         {
01955           Use* use = sub_uses[n];
01956 
01957           if (use == 0) continue;
01958 
01959           if (use->discarded)
01960             {
01961               Use* u;
01962 
01963               u = use->get_selected_version ();
01964               if (u == 0) continue;
01965 
01966               use = u;
01967             }
01968 
01969           cycle = false;
01970       
01971             // This use must not be already in the list (protection against cycles)
01972 
01973           for (int m = 0; m < list.size (); m++)
01974             {
01975               Use* u = list[m];
01976               if (u == use)
01977                 {
01978                   cycle = true;
01979                   break;
01980                 }
01981             }
01982 
01983           if (cycle) 
01984             {
01985               found = true;
01986               continue;
01987             }
01988 
01989           level++;
01990           bool r = use->get_paths (to, list);
01991           level--;
01992 
01993           if (r)
01994             {
01995               found = true;
01996             }
01997         }
01998     }
01999 
02000   if (found)
02001     {
02002       cycle = false;
02003 
02004       for (int m = 0; m < list.size (); m++)
02005         {
02006           Use* u = list[m];
02007           if (u == this)
02008             {
02009               cycle = true;
02010               break;
02011             }
02012         }
02013 
02014       if (!cycle)
02015         {
02016           list.push_back (this);
02017         }
02018     }
02019 
02020   return (found);  
02021 }

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 1821 of file cmt_use.cxx.

Referenced by get_paths().

01822 {
01823   static Use::UsePtrVector& Uses = uses ();
01824 
01825     //cout << "get_selected_version for package " << package << endl;
01826 
01827   if (!discarded) return (this);
01828 
01829   for (int i = 0; i < Uses.size (); i++)
01830     {
01831       Use* u = Uses[i];
01832       if (u == 0) continue;
01833       if (u->discarded) continue;
01834       if (u->package == package) 
01835         {
01836             //cout << "  got a version" << endl;
01837           return (u);
01838         }
01839     }
01840 
01841   return (0);
01842 }

bool Use::has_native_version ( ) const
 

Definition at line 1906 of file cmt_use.cxx.

01907 {
01908   return (m_has_native_version);
01909 }

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 1725 of file cmt_use.cxx.

Referenced by select_clients().

01727 {
01728   // A package is client of itself
01729   if ((package == used_package) &&
01730       (version == used_version)) return (true);
01731 
01732   if (discarded) return (false);
01733 
01734   int i;
01735 
01736   for (i = 0; i < sub_uses.size (); i++)
01737     {
01738       Use* use = sub_uses[i];
01739       if (use == 0) continue;
01740 
01741       if ((use->package == used_package) &&
01742           (use->version == used_version)) return (true);
01743 
01744       /*
01745         if (use->is_client (used_package, used_version))
01746         {
01747         return (true);
01748         }
01749       */
01750     }
01751 
01752   return (false);
01753 }

bool Use::is_selected ( ) [private]
 

Definition at line 1714 of file cmt_use.cxx.

Referenced by select_clients().

01715 {
01716   return (selected);
01717 }

bool Use::located ( ) const
 

Definition at line 2024 of file cmt_use.cxx.

Referenced by Cmt::do_broadcast(), Cmt::do_build_library_links(), Cmt::do_remove_library_links(), Cmt::set_standard_macros(), and show_all().

02025 {
02026   return (m_located);
02027 }

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

Definition at line 579 of file cmt_use.cxx.

Referenced by Cmt::select().

00580 {
00581   if (manager != "") manager += "\n";
00582   for (int i = 1; i < words.size (); i++)
00583     {
00584       const cmt_string& w = words[i];
00585       
00586       if (i > 1) manager += " ";
00587       manager += w;
00588     }
00589 }

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

Definition at line 631 of file cmt_use.cxx.

Referenced by show_all().

00632 {
00633   static UsePtrVector& Uses = uses ();
00634 
00635   int use_index;
00636   Use* use;
00637   int found = 0;
00638 
00639   if (Uses.size () == 0) return;
00640   if (use1 == 0) return;
00641 
00642   //
00643   // On se positionne sur le pointeur.
00644   //
00645   for (use_index = 0; use_index < Uses.size (); use_index++)
00646     {
00647       use = Uses[use_index];
00648 
00649       if (use == use1)
00650         {
00651           found = 1;
00652           break;
00653         }
00654     }
00655 
00656   if (!found) return;
00657 
00658   //
00659   // On deplace tous les pointeurs d'une case en arriere
00660   //
00661   for (use_index++;
00662        use_index < Uses.size ();
00663        use_index++)
00664     {
00665       Uses[use_index - 1] = Uses[use_index];
00666     }
00667 
00668   //
00669   // use1 est donc replace en derniere position
00670   //
00671   {
00672     Uses[Uses.size () - 1] = use1;
00673   }
00674 }

bool Use::move_to ( )
 

Definition at line 1122 of file cmt_use.cxx.

Referenced by add(), and Cmt::reach_current_package().

01123 {
01124   if (m_located)
01125     {
01126       //
01127       // The real path where this version/package can be found 
01128       // has already been resolved. We thus first go there.
01129       //
01130 
01131       if (Cmt::get_debug ())
01132         {
01133           cout << "move_to1> " << real_path << endl;
01134         }
01135 
01136       reach_package (real_path);
01137 
01138       return (true);
01139     }
01140 
01141   cmt_string expanded_path = path;
01142 
01143   //
01144   // Try here.
01145   //
01146   if (expanded_path == "")
01147     {
01148       if (reach_package (""))
01149         {
01150           if (Cmt::get_debug ())
01151             {
01152               cout << "move_to2> " << expanded_path << endl;
01153             }
01154 
01155           change_path (expanded_path);
01156 
01157           return (true);
01158         }
01159       else if (alternate_versions.size () > 0)
01160         {
01161           if (select_alternate ()) 
01162             {
01163               if (Cmt::get_debug ())
01164                 {
01165                   cout << "move_to5> " << real_path << endl;
01166                 }
01167               
01168               return (true);
01169             }
01170         }
01171     }
01172       
01173   //
01174   // If the path specified in this use is a true absolute path,
01175   // then we search the package from there first.
01176   //
01177   if (CmtSystem::absolute_path (expanded_path))
01178     {
01179       if (reach_package (expanded_path))
01180         {
01181           if (Cmt::get_debug ())
01182             {
01183               cout << "move_to3> " << expanded_path << endl;
01184             }
01185 
01186           change_path (expanded_path);
01187 
01188           return (true);
01189         }
01190       else if (alternate_versions.size () > 0)
01191         {
01192           if (select_alternate ()) 
01193             {
01194               if (Cmt::get_debug ())
01195                 {
01196                   cout << "move_to5> " << real_path << endl;
01197                 }
01198               
01199               return (true);
01200             }
01201         }
01202     }
01203       
01204   //
01205   // Second try is among the CMTPATHs
01206   //
01207       
01208   static const CmtSystem::cmt_string_vector& search_path = Cmt::get_cmt_path ();
01209   int path_index = 0;
01210       
01211   for (path_index = 0; path_index < search_path.size (); path_index++)
01212     {
01213       const cmt_string& next_path = search_path[path_index];
01214       
01215       alternate_versions.clear ();
01216       alternate_paths.clear ();
01217 
01218       if (reach_package (next_path))
01219         {
01220           if (Cmt::get_debug ())
01221             {
01222               cout << "move_to4> " << next_path << endl;
01223             }
01224 
01225           change_path (next_path);
01226 
01227           return (true);
01228         }
01229       else if (alternate_versions.size () > 0)
01230         {
01231           if (select_alternate ()) 
01232             {
01233               if (Cmt::get_debug ())
01234                 {
01235                   cout << "move_to5> " << real_path << endl;
01236                 }
01237               
01238               return (true);
01239             }
01240         }
01241     }
01242   
01243 
01244   return (false);
01245 }

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

Definition at line 1343 of file cmt_use.cxx.

Referenced by add().

01347 {
01348   bool has_wild_card = (version.find ("*") != cmt_string::npos);
01349 
01350   static UsePtrVector& Uses = uses ();
01351   static UseVector& AllUses = all_uses ();
01352 
01353   bool result = true;
01354   Use* found = 0;
01355 
01356   int use_index;
01357 
01358   if (old_use != 0) *old_use = 0;
01359   if (AllUses.size () == 0) return (true);
01360 
01361   for (use_index = 0; use_index < Uses.size (); use_index++)
01362     {
01363       Use& use = (*Uses[use_index]);
01364 
01365       if (use.package != package) continue;
01366 
01367       found = &use;
01368 
01369       /*
01370         cerr << "Use::need_new> (" << package
01371         << ") requested version=" << version
01372         << " vs existing=" << use->version
01373         << " (specified as " << use->specified_version
01374         << ")" << endl;
01375       */
01376 
01377       bool use_has_wild_card = (use.specified_version.find ("*") != cmt_string::npos);
01378 
01379       if (has_wild_card && !use_has_wild_card)
01380         {
01381           //cerr << "  ... requested wildcarded loses against existing explicit" << endl;
01382           result = false;
01383           break;
01384         }
01385 
01386       if ((version == use.specified_version) &&
01387           (path == use.specified_path))
01388         {
01389           // exactly same version and path!
01390           result = false;
01391           break;
01392         }
01393 
01394       // requested explicit wins against existing wildcarded
01395       // In any case when paths are different, consider the new one.
01396       // Now paths are identical (thus versions are different).
01397     }
01398 
01399   if (old_use != 0) *old_use = found;
01400   return (result);
01401 }

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

Definition at line 955 of file cmt_use.cxx.

Referenced by move_to(), and select_alternate().

00956 {
00957   //cerr << "Use::reach_package> (" << package << " " << version << ")from " << from_path << endl;
00958 
00959   //
00960   // We try to reach a package/version starting from from_path
00961   //
00962 
00963   // check if from_path is at least real
00964   if ((from_path != "") && !CmtSystem::cd (from_path)) return (0);
00965 
00966   // check in case from_path is a new search path 
00967   if (from_path != real_path)
00968     {
00969       // Move to that prefix only if it is a relative path.
00970       if ((path.size () > 0) && (!CmtSystem::absolute_path (path)))
00971         {
00972           if (!CmtSystem::cd (path))
00973             {
00974               return (0);
00975             }
00976         }
00977     }
00978 
00979   // Special treatment for CMTHOME package...
00980   if (package == CmtSystem::get_home_package ())
00981     {
00982       discarded = 1;
00983       if (!CmtSystem::test_file ("requirements"))
00984         {
00985           return (0);
00986         }
00987       else
00988         {
00989           return (1);
00990         }
00991     }
00992 
00993   // Special treatment for CMTUSERCONTEXT package...
00994   if (package == CmtSystem::get_user_context_package ())
00995     {
00996       discarded = 1;
00997       if (!CmtSystem::test_file ("requirements"))
00998         {
00999           return (0);
01000         }
01001       else
01002         {
01003           return (1);
01004         }
01005     }
01006 
01007   // Now from_path exists, try if the package exists there
01008   if (!CmtSystem::cd (package))
01009     {
01010       return (0);
01011     }
01012 
01013   if (!CmtSystem::cd (version))
01014     {
01015       //
01016       // The specified version cannot be found per-se
01017       // There are alternate possibilities when it contains wild cards
01018       //
01019       if ((version == "") ||
01020           (version.find ("*") != cmt_string::npos))
01021         {
01022           static CmtSystem::cmt_string_vector versions;
01023           static cmt_string name;
01024 
01025           name = ".";
01026           name += CmtSystem::file_separator ();
01027           if (version == "") name += "*";
01028           else name += version;
01029 
01030           CmtSystem::scan_dir (name, versions);
01031           
01032           int i;
01033           
01034           for (i = 0; i < versions.size (); i++)
01035             {
01036               const cmt_string& vers = versions[i];
01037               
01038               if (Cmt::get_debug ())
01039                 {
01040                   cout << "     ... version " << vers << " exists" << endl;
01041                 }
01042 
01043               CmtSystem::basename (vers, name);
01044               
01045               int v;
01046               int r;
01047               int p;
01048               
01049               if (CmtSystem::is_version_directory (name, v, r, p))
01050                 {
01051                   /*
01052                     This check is not sufficient !! We need to check in addition
01053                     that the selected directory is really the start of a true CMT
01054                     package (ie with either /mgr/requirements or /cmt/requirements below)
01055                   */
01056 
01057                   cmt_string req;
01058 
01059                   req = name;
01060                   req += CmtSystem::file_separator ();
01061                   req += "mgr";
01062                   req += CmtSystem::file_separator ();
01063                   req += "requirements";
01064 
01065                   if (!CmtSystem::test_file (req))
01066                     {
01067                       req = name;
01068                       req += CmtSystem::file_separator ();
01069                       req += "cmt";
01070                       req += CmtSystem::file_separator ();
01071                       req += "requirements";
01072 
01073                       if (!CmtSystem::test_file (req)) continue;
01074                     }
01075 
01076                   cmt_string& new_v = alternate_versions.add ();
01077                   new_v = name;
01078                   cmt_string& new_p = alternate_paths.add ();
01079                   new_p = from_path;
01080                 }
01081             }
01082         }
01083 
01084       if (Cmt::get_debug ())
01085         {
01086           cout << "  ... end of version scan" << endl;
01087         }
01088 
01089         //
01090         //  We have now the list of possible alternate versions. However
01091         // we return that the expected package/version was not found (yet).
01092         //
01093 
01094       return (0);
01095     }
01096 
01097   //cerr << "  ... version " << version << " exists" << endl;
01098 
01099   // Now we have met the exact specified version!
01100   if (!CmtSystem::test_file ("cmt/requirements"))
01101     {
01102       if (!CmtSystem::test_file ("mgr/requirements"))
01103         {
01104           return (0);
01105         }
01106       else
01107         {
01108           CmtSystem::cd ("mgr");
01109           style = mgr_style;
01110         }
01111     }
01112   else
01113     {
01114       CmtSystem::cd ("cmt");
01115       style = cmt_style;
01116     }
01117 
01118   return (1);
01119 }

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 681 of file cmt_use.cxx.

Referenced by use_action_iterator::get_use().

00682 {
00683   static UsePtrVector& Uses = uses ();
00684 
00685   int use_index;
00686   int index1 = -1;
00687   int index2 = -1;
00688   Use* use;
00689 
00690   if (Uses.size () == 0) return;
00691   if (use1 == use2) return;
00692 
00693   //
00694   // First locate the two use objects into the Uses vector.
00695   //   -> index1 and index 2
00696   //
00697   for (use_index = 0; use_index < Uses.size (); use_index++)
00698     {
00699       use = (Use*) Uses[use_index];
00700 
00701       if (use == use1) index1 = use_index;
00702       if (use == use2) index2 = use_index;
00703     }
00704 
00705   if (Cmt::get_debug ())
00706     {
00707       cout << "Use::reorder> 1=" << index1 << " 2=" << index2 << endl;
00708     }
00709 
00710   //
00711   // Both objects must be installed in Uses before acting.
00712   //
00713   if (index1 == -1) return;
00714   if (index2 == -1) return;
00715 
00716   if (index2 < index1)
00717     {
00718       //
00719       // 2 is already before 1 so job is finished
00720       //
00721       return;
00722     }
00723   else
00724     {
00725       //
00726       // before : <a a a 1 b b b 2 c c c>
00727       //                 ^       ^
00728       //                 i1      i2
00729       //
00730       //  1) move "1 b b b" by one place to the right
00731       // thus :   <a a a 1 1 b b b c c c>
00732       //
00733       //  2) move "2" to [i1]
00734       //
00735       // after  : <a a a 2 1 b b b c c c>
00736       //
00737 
00738       use = use2;
00739 
00740       for (use_index = index2 - 1; use_index >= index1; use_index--)
00741         {
00742           Uses[use_index + 1] = Uses[use_index];
00743         }
00744 
00745       Uses[index1] = use;
00746     }
00747 }

void Use::select ( ) [private]
 

Definition at line 1702 of file cmt_use.cxx.

Referenced by select_clients().

01703 {
01704   selected = true;
01705 }

bool Use::select_alternate ( ) [private]
 

Definition at line 1248 of file cmt_use.cxx.

Referenced by move_to().

01249 {
01250   int i;
01251 
01252   int v0 = 0;
01253   int r0 = 0;
01254   int p0 = 0;
01255 
01256   int v = 0;
01257   int r = 0;
01258   int p = 0;
01259 
01260   int selected_index = -1;
01261 
01262   for (i = 0; i < alternate_versions.size (); i++)
01263     {
01264       cmt_string& name = alternate_versions[i];
01265 
01266         /*
01267       if (CmtSystem::getenv ("CMTTESTUSEWILDCARDS") != "")
01268         {
01269           cout << "select_alternate[" << this << "]> package " << package << 
01270               " sv=" << specified_version << 
01271               " v=" << version << 
01272               " av[" << i << "]=" << name << endl;
01273         }
01274         */
01275 
01276       if (i == 0)
01277         {
01278           CmtSystem::is_version_directory (name, v0, r0, p0);
01279           selected_index = 0;
01280         }
01281       else
01282         {
01283           CmtSystem::is_version_directory (name, v, r, p);
01284 
01285           if (v > v0)
01286             {
01287               selected_index = i;
01288               v0 = v;
01289               r0 = r;
01290               p0 = p;
01291             }
01292           else if (v == v0)
01293             {
01294               if (r > r0)
01295                 {
01296                   selected_index = i;
01297                   r0 = r;
01298                   p0 = p;
01299                 }
01300               else if (r == r0)
01301                 {
01302                   if (p > p0)
01303                     {
01304                       selected_index = i;
01305                       p0 = p;
01306                     }
01307                 }
01308             }
01309         }
01310     }
01311 
01312   if (selected_index >= 0)
01313     {
01314       if (CmtSystem::cd (alternate_paths[selected_index]))
01315         {
01316           version = alternate_versions[selected_index];
01317           if (reach_package (alternate_paths[selected_index]))
01318             {
01319                 /*
01320               if (CmtSystem::getenv ("CMTTESTUSEWILDCARDS") != "")
01321                 {
01322                   cout << "select_alternate2> package " << package << 
01323                       " sv=" << specified_version << 
01324                       " v=" << version << endl;
01325                 }
01326                 */
01327 
01328               if (Cmt::get_debug ())
01329                 {
01330                   cout << "select_alternate> " << alternate_paths[selected_index] << endl;
01331                 }
01332 
01333               change_path (alternate_paths[selected_index]);
01334               return (true);
01335             }
01336         }
01337     }
01338 
01339   return (false);
01340 }

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 898 of file cmt_use.cxx.

Referenced by Use(), Cmt::configure(), create(), Cmt::do_config(), Cmt::parse_arguments(), and Cmt::select().

00903 {
00904   clear ();
00905 
00906   package           = new_package;
00907   specified_path    = new_path;
00908   // specified_path.replace_all ("\\", "/");
00909 
00910   specified_version = new_version;
00911   version           = new_version;
00912   path              = specified_path;
00913   Symbol::expand (path);
00914   real_path         = "";
00915   style             = mgr_style;
00916   scope             = Cmt::get_scope ();
00917   done              = false;
00918   discarded         = false;
00919   Cmt::build_prefix (new_package, prefix);
00920 
00921   version_alias = new_version_alias;
00922   path_alias    = new_path_alias;
00923 }

void Use::set_auto_imports ( State new_state )
 

Definition at line 1844 of file cmt_use.cxx.

Referenced by use_action_iterator::get_use().

01845 {
01846   if (Cmt::get_debug ())
01847     {
01848       cout << "Use::set_auto_imports>(" << package << ") " 
01849            << auto_imports << " -> " << new_state << endl;
01850     }
01851 
01852   if (auto_imports == new_state) return;
01853   
01854   State old_state = auto_imports;
01855   
01856   auto_imports = new_state;
01857 
01858     // We propagate only when we switch from Off to On
01859 
01860   if ((old_state == Off) && (new_state == On))
01861     {
01862       cmt_string s;
01863       static const cmt_string state_text[] = {"Unspecified", "Off", "On"};
01864 
01865       if (Cmt::get_debug ())
01866         {
01867           s = "Use::set_auto_imports>(";
01868           s += package;
01869           s += ") ";
01870 
01871           cout << s << endl;
01872         }
01873 
01874       for (int i = 0; i < sub_uses.size (); i++)
01875         {
01876           Use* u = sub_uses[i];
01877           State state = sub_use_auto_imports[i];
01878           
01879           if (Cmt::get_debug ())
01880             {
01881               s += " ";
01882               s += u->package;
01883               s += "(";
01884               s += state_text[state];
01885               s += ")";
01886             }
01887 
01888           if (state == Unspecified)
01889             {
01890               u->set_auto_imports (On);
01891             }
01892         }
01893           
01894       if (Cmt::get_debug ())
01895         {
01896           cout << s << endl;
01897         }
01898     }
01899 }

void Use::set_include_path ( const cmt_string & new_path )
 

Definition at line 1774 of file cmt_use.cxx.

Referenced by Cmt::select().

01775 {
01776   include_path = new_path;
01777 }

void Use::set_native_version ( bool state )
 

Definition at line 1901 of file cmt_use.cxx.

Referenced by Symbol::action().

01902 {
01903   m_has_native_version = state;
01904 }

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 2030 of file cmt_use.cxx.

Referenced by show_all().

02031 {
02032   int n;
02033   Use* use;
02034   static int level = 0;
02035 
02036   if (skip_discarded && discarded) return;
02037 
02038   if (level > 0)
02039     {
02040       cout << "# ";
02041       for (n = 0; n < (level-1); n++) cout << "  ";
02042 
02043       cout << "use " << package << " " << specified_version;
02044 
02045       if (specified_path != "") cout << " " << specified_path;
02046 
02047       if (version_alias != "")
02048         {
02049           cout << " | " << version_alias << " " << path_alias;
02050         }
02051 
02052       if (scope == ScopeUnspecified) cout << " unspecified";
02053       else if (scope != ScopePublic) cout << " (private)";
02054       //else cout << " private";
02055 
02056       if (auto_imports == Off) cout << " (no_auto_imports)";
02057 
02058       if (m_has_native_version)
02059         {
02060           cmt_string n = package;
02061           n += "_native_version";
02062 
02063           Symbol* s = Symbol::find (n);
02064           if (s != 0)
02065             {
02066               cmt_string value = s->resolve_macro_value ();
02067               cout << " (native_version=" << value << ")";
02068             }
02069         }
02070 
02071       cout << endl;
02072     }
02073 
02074   if (selected) return;
02075   selected = true;
02076 
02077   level++;
02078   for (n = 0; n < sub_uses.size (); n++)
02079     {
02080       use = sub_uses[n];
02081       if (use == 0) continue;
02082 
02083       ScopeType saved_scope = use->scope;
02084       State saved_state = use->auto_imports;
02085 
02086       use->scope = sub_use_scopes[n];
02087       use->auto_imports = sub_use_auto_imports[n];
02088 
02089       use->show_sub_uses (skip_discarded);
02090 
02091       use->scope = saved_scope;
02092       use->auto_imports = saved_state;
02093     }
02094   level--;
02095 }

void Use::undiscard ( )
 

Definition at line 1696 of file cmt_use.cxx.

Referenced by KeepAllSelector::operate(), LastChoiceSelector::operate(), FirstChoiceSelector::operate(), BestFitNoCheckSelector::operate(), BestFitSelector::operate(), and undiscard_all().

01697 {
01698   discarded = false;
01699 }

void Use::undiscard_all ( ) [static]
 

Definition at line 788 of file cmt_use.cxx.

Referenced by select_clients().

00789 {
00790   static UsePtrVector& Uses = uses ();
00791 
00792   int use_index;
00793 
00794   if (Uses.size () == 0) return;
00795 
00796   for (use_index = 0; use_index < Uses.size (); use_index++)
00797     {
00798       Use* use = Uses[use_index];
00799 
00800       if (use != 0)
00801         {
00802           use->undiscard ();
00803         }
00804     }
00805 }

void Use::unselect ( ) [private]
 

Definition at line 1708 of file cmt_use.cxx.

Referenced by show_all(), and unselect_all().

01709 {
01710   selected = false;
01711 }

void Use::unselect_all ( ) [static]
 

Definition at line 768 of file cmt_use.cxx.

Referenced by select_clients(), and show_all().

00769 {
00770   static UsePtrVector& Uses = uses ();
00771 
00772   int use_index;
00773 
00774   if (Uses.size () == 0) return;
00775 
00776   for (use_index = 0; use_index < Uses.size (); use_index++)
00777     {
00778       Use* use = Uses[use_index];
00779 
00780       if (use != 0)
00781         {
00782           use->unselect ();
00783         }
00784     }
00785 }

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

Definition at line 2130 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(), fill_macro_all(), find(), Pattern::find(), 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(), Cmt::set_standard_macros(), Pattern::show(), show_all(), undiscard_all(), and unselect_all().

02131 {
02132   static Database& db = Database::instance ();
02133   static UsePtrVector& Uses = db.uses ();
02134 
02135   return (Uses);
02136 }


Member Data Documentation

CmtSystem::cmt_string_vector Use::alternate_paths [private]
 

Definition at line 131 of file cmt_use.h.

CmtSystem::cmt_string_vector Use::alternate_versions [private]
 

Definition at line 130 of file cmt_use.h.

ApplyPattern::ApplyPatternVector Use::apply_patterns
 

Definition at line 103 of file cmt_use.h.

cmt_string Use::author
 

Definition at line 83 of file cmt_use.h.

State Use::auto_imports
 

Definition at line 98 of file cmt_use.h.

bool Use::discarded
 

Definition at line 95 of file cmt_use.h.

bool Use::done
 

Definition at line 93 of file cmt_use.h.

IgnorePattern::IgnorePatternVector Use::ignore_patterns
 

Definition at line 104 of file cmt_use.h.

cmt_string Use::include_path
 

Definition at line 101 of file cmt_use.h.

Include::IncludeVector Use::includes
 

Definition at line 100 of file cmt_use.h.

bool Use::m_has_native_version [private]
 

Definition at line 124 of file cmt_use.h.

bool Use::m_located [private]
 

Definition at line 123 of file cmt_use.h.

cmt_string Use::manager
 

Definition at line 84 of file cmt_use.h.

cmt_string Use::package
 

Definition at line 78 of file cmt_use.h.

cmt_string Use::path
 

Definition at line 86 of file cmt_use.h.

cmt_string Use::path_alias
 

Definition at line 82 of file cmt_use.h.

cmt_string Use::prefix
 

Definition at line 91 of file cmt_use.h.

cmt_string Use::real_path
 

Definition at line 88 of file cmt_use.h.

ScopeType Use::scope
 

Definition at line 92 of file cmt_use.h.

Script::ScriptVector Use::scripts
 

Definition at line 102 of file cmt_use.h.

bool Use::selected
 

Definition at line 96 of file cmt_use.h.

cmt_string Use::specified_path
 

Definition at line 80 of file cmt_use.h.

cmt_string Use::specified_version
 

Definition at line 79 of file cmt_use.h.

CmtDirStyle Use::style
 

Definition at line 89 of file cmt_use.h.

cmt_vector< State > Use::sub_use_auto_imports [private]
 

Definition at line 128 of file cmt_use.h.

cmt_vector< ScopeType > Use::sub_use_scopes [private]
 

Definition at line 127 of file cmt_use.h.

UsePtrVector Use::sub_uses [private]
 

Definition at line 126 of file cmt_use.h.

cmt_string Use::version
 

Definition at line 87 of file cmt_use.h.

cmt_string Use::version_alias
 

Definition at line 81 of file cmt_use.h.


The documentation for this class was generated from the following files:
Generated at Thu Apr 11 16:51:01 2002 for CMT by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000