#include <cmt_pattern.h>
  Collaboration diagram for Pattern:
| Public Types | |
| typedef cmt_vector< Pattern >? | PatternVector | 
| typedef cmt_vector< Pattern * >? | PatternPtrVector | 
| Public Methods | |
| ? | Pattern () | 
| ? | ~Pattern () | 
| void? | clear () | 
| void? | apply () const | 
| ? | Applies a pattern to all uses (except CMT itself) between current and the use that declared the pattern. | 
| void? | apply (Use *constext_use) const | 
| void? | apply (Use *constext_use, const Template::TemplateVector &templates) const | 
| ? | Applies a pattern to one particular use. | 
| void? | expand (Use *constext_use, const Template::TemplateVector &templates, cmt_string &line) const | 
| void? | show () const | 
| Static Public Methods | |
| void? | action (const CmtSystem::cmt_string_vector &words, Use *use) | 
| Pattern *? | find (const cmt_string &name) | 
| ? | Patterns are stored with two keys : | 
| Pattern *? | find (const cmt_string &name, Use *use) | 
| void? | add (const cmt_string &name, const CmtSystem::cmt_string_vector &words, int start_index, bool global, Use *use) | 
| int? | pattern_number () | 
| ? | Get the number of registered patterns. | 
| Pattern &? | pattern (int index) | 
| ? | Get the index'th pattern in the database. | 
| void? | clear_all () | 
| PatternVector &? | patterns () | 
| void? | apply_all_globals () | 
| ? | Applies all global patterns to all uses. | 
| void? | apply_all_globals (Use *use) | 
| ? | Applies all global patterns to a given Use. | 
| void? | show_all_names () | 
| void? | show_all () | 
| ? | this is the cmt show patterns command It just shows the pattern declarations. | 
| void? | show_all_applied_patterns () | 
| ? | this is the cmt show applied_patterns command It just shows the pattern applications. | 
| void? | show (const cmt_string &name) | 
| ? | This is the cmt show pattern | 
| Public Attributes | |
| cmt_string? | name | 
| cmt_string? | line | 
| bool? | global | 
| Use *? | use | 
| 
 | 
| ? | Definition at line 28 of file cmt_pattern.h. | 
| 
 | 
| ? | Definition at line 27 of file cmt_pattern.h. | 
| 
 | 
| ? | Definition at line 572 of file cmt_pattern.cxx. 00573 {
00574 }
 | 
| 
 | 
| ? | Definition at line 577 of file cmt_pattern.cxx. 00579 {
00580 }
 | 
| 
 | ||||||||||||
| ? | Definition at line 155 of file cmt_pattern.cxx. References add(), global, name, cmt_vector< cmt_string >::size(), and CmtSystem::testenv(). Referenced by KwdPattern::action(). 00156 {
00157   bool global = false;
00158   int start_index;
00159 
00160   if (words.size () < 2) return;
00161 
00162     //
00163     // expected syntax is:
00164     //
00165     //  pattern [-global] pattern-name any-cmt-statement
00166     //
00167     // where any-cmt-statement may contain "templates"
00168     //
00169     //       | 
| 
 | ||||||||||||||||||||||||
| ? | Definition at line 222 of file cmt_pattern.cxx. References PatternList::add(), cmt_vector< Pattern >::add(), PatternList::add_pattern(), clear(), cmt_string::find(), find(), global, line, name, cmt_string::npos, pattern(), patterns(), cmt_vector< cmt_string >::size(), and use. Referenced by action(). 00227 {
00228   static PatternVector& Patterns = patterns ();
00229 
00230   Pattern* pattern;
00231 
00232   pattern = find (name, use);
00233 
00234   if (pattern == 0)
00235     {
00236         // No pattern for the pair  | 
| 
 | ||||||||||||
| ? | Applies a pattern to one particular use. Definition at line 728 of file cmt_pattern.cxx. References expand(), SyntaxParser::parse_requirements_text(), and CmtSystem::testenv(). 00730 {
00731   cmt_string replacement;
00732 
00733   expand (context_use, templates, replacement);
00734 
00735   if (CmtSystem::testenv ("CMTTESTPATTERN"))
00736     {
00737       cout << "Pattern::apply> replacement=[" << replacement << "]" << endl;
00738     }
00739 
00740   if (replacement != "")
00741     {
00742       SyntaxParser::parse_requirements_text (replacement, "", context_use);
00743     }
00744 }
 | 
| 
 | 
| ? | Definition at line 718 of file cmt_pattern.cxx. References apply(). 00719 {
00720   static Template::TemplateVector dummy_templates;
00721 
00722   apply (context_use, dummy_templates);
00723 }
 | 
| 
 | 
| ? | Applies a pattern to all uses (except CMT itself) between current and the use that declared the pattern. Definition at line 688 of file cmt_pattern.cxx. References Use::current(), IgnorePattern::find(), Cmt::get_debug(), PatternCache::get_list(), Use::get_ordered_uses(), Use::get_package_name(), name, cmt_vector< Use * >::size(), PatternCache::update(), and use. Referenced by ApplyPattern::apply(), apply(), PatternList::apply_all_globals(), and Use::apply_global_patterns(). 00689 {
00690   Use::UsePtrVector& uses = Use::get_ordered_uses ();
00691 
00692   Use* current = &(Use::current());
00693 
00694   if (Cmt::get_debug ())
00695     {
00696       cout << "Pattern(" << name << "::apply> " << " defined in " << use->get_package_name () << endl;
00697     }
00698 
00699   if (!PatternCache::update (current, use)) return;
00700 
00701   Use::UsePtrVector& list = PatternCache::get_list ();
00702 
00703   for (int i = 0; i < list.size (); i++)
00704     {
00705       Use* u = list[i];
00706 
00707       if (Cmt::get_debug ())
00708         {
00709           cout << "Pattern(" << name << "::apply> " << " to package " << u->get_package_name () << endl;
00710         }
00711 
00712       if ((u->get_package_name () != "CMT") && 
00713           (IgnorePattern::find (name, u) == 0)) apply (u);
00714     }
00715 }
 | 
| 
 | 
| ? | Applies all global patterns to a given Use. Definition at line 466 of file cmt_pattern.cxx. References PatternList::apply_all_globals(). 00467 {
00468   PatternList::apply_all_globals ();
00469 }
 | 
| 
 | 
| ? | Applies all global patterns to all uses. Definition at line 458 of file cmt_pattern.cxx. References PatternList::apply_all_globals(). Referenced by Cmt::load(), and Cmt::reach_current_package(). 00459 {
00460   PatternList::apply_all_globals ();
00461 }
 | 
| 
 | 
| ? | Definition at line 583 of file cmt_pattern.cxx. References global, line, name, and use. Referenced by add(), and clear_all(). | 
| 
 | 
| ? | Definition at line 323 of file cmt_pattern.cxx. References cmt_vector< Pattern >::clear(), clear(), patterns(), and cmt_vector< Pattern >::size(). Referenced by Database::clear(). 00324 {
00325   static PatternVector& Patterns = patterns ();
00326 
00327   for (int i = 0; i < Patterns.size (); i++)
00328     {
00329       Pattern& p = Patterns[i];
00330       p.clear ();
00331     }
00332 
00333   Patterns.clear ();
00334 }
 | 
| 
 | ||||||||||||||||
| ? | Definition at line 747 of file cmt_pattern.cxx. References cmt_string::c_str(), Use::current(), cmt_string::erase(), cmt_string::find(), Use::get_package_name(), line, Template::name, cmt_string::npos, Use::prefix, Use::real_path, cmt_string::replace_all(), cmt_vector< Template >::size(), CmtSystem::testenv(), Template::value, and Use::version. Referenced by apply(), and ApplyPattern::show(). 00750 {
00751   if (context_use == 0) context_use = &(Use::current ());
00752 
00753   if (CmtSystem::testenv ("CMTTESTPATTERN"))
00754     {
00755       cout << "Pattern::expand1> line=[" << line << "]" << endl;
00756     }
00757 
00758   replacement = line;
00759 
00760   if (replacement != "")
00761     {
00762         // Substitute templates from the cmt statement
00763       replacement.replace_all (" | 
| 
 | ||||||||||||
| ? | Definition at line 214 of file cmt_pattern.cxx. References PatternList::find(). 00215 {
00216   Pattern* p = PatternList::find (name, use);
00217 
00218   return (p);
00219 }
 | 
| 
 | 
| ? | Patterns are stored with two keys :  thus search must done against these two keys. Definition at line 206 of file cmt_pattern.cxx. References PatternList::find_pattern(). Referenced by ApplyPattern::action(), add(), ApplyPattern::apply(), SyntaxParser::do_parse_words(), ApplyPattern::show(), and show(). 00207 {
00208   Pattern* p = PatternList::find_pattern (name);
00209 
00210   return (p);
00211 }
 | 
| 
 | 
| ? | Get the index'th pattern in the database. Definition at line 315 of file cmt_pattern.cxx. References patterns(). Referenced by add(). 00316 {
00317   static PatternVector& Patterns = patterns ();
00318 
00319   return (Patterns[index]);
00320 }
 | 
| 
 | 
| ? | Get the number of registered patterns. Definition at line 305 of file cmt_pattern.cxx. References patterns(), and cmt_vector< Pattern >::size(). 00306 {
00307   static PatternVector& Patterns = patterns ();
00308 
00309   return (Patterns.size ());
00310 }
 | 
| 
 | 
| ? | Definition at line 337 of file cmt_pattern.cxx. References Database::instance(), and Database::patterns(). Referenced by add(), Use::apply_global_patterns(), clear_all(), pattern(), pattern_number(), and show(). 00338 {
00339   static Database& db = Database::instance ();
00340   static PatternVector& Patterns = db.patterns ();
00341 
00342   return (Patterns);
00343 }
 | 
| 
 | 
| ? | Definition at line 592 of file cmt_pattern.cxx. References Use::get_package_name(), line, name, use, and Use::version. Referenced by Cmt::do_show_pattern(). | 
| 
 | 
| ? | This is the cmt show pattern  Definition at line 511 of file cmt_pattern.cxx. References Use::apply_patterns, Use::current(), find(), Use::get_ordered_uses(), Use::get_package_name(), ApplyPattern::name, CmtError::pattern_not_found, patterns(), CmtError::set(), ApplyPattern::show(), cmt_vector< ApplyPattern >::size(), cmt_vector< Use * >::size(), use, and Use::version. Referenced by PatternList::show_all_patterns(). 00512 {
00513   static PatternVector& Patterns = patterns ();
00514 
00515   int i;
00516   int j;
00517 
00518   bool found = false;
00519 
00520     // First show the definitions.
00521 
00522   Pattern* p = Pattern::find (name);
00523 
00524   if (p == 0)
00525     {
00526       CmtError::set (CmtError::pattern_not_found, name);
00527       return;
00528     }
00529 
00530   p->show ();
00531 
00532     //
00533     // Then show the packages which explicitly apply the pattern.
00534     //
00535   Use* use;
00536   ApplyPattern* apply_pattern = 0;
00537 
00538   Use::UsePtrVector& uses = Use::get_ordered_uses ();
00539 
00540   for (i = 0; i < uses.size (); i++)
00541     {
00542       use = uses[i];
00543       for (j = 0; j < use->apply_patterns.size (); j++)
00544         {
00545           apply_pattern = &(use->apply_patterns[j]);
00546             
00547           if (apply_pattern->name == name)
00548             {
00549               cout << "# applied by " << use->get_package_name () << " => " << endl;
00550               apply_pattern->show ();
00551               cout << endl;
00552             }
00553         }
00554     }
00555 
00556   use = &(Use::current ());
00557   for (j = 0; j < use->apply_patterns.size (); j++)
00558     {
00559       apply_pattern = &(use->apply_patterns[j]);
00560         
00561       if (apply_pattern->name == name)
00562         {
00563           cout << "# " << use->get_package_name () << " " << use->version << " applies pattern " << name;
00564           cout << " => " << endl;
00565           apply_pattern->show ();
00566           cout << endl;
00567         }
00568     }
00569 }
 | 
| 
 | 
| ? | this is the cmt show patterns command It just shows the pattern declarations. Definition at line 475 of file cmt_pattern.cxx. References show_all_applied_patterns(), and PatternList::show_all_patterns(). Referenced by Cmt::do_show_patterns(). 00476 {
00477   PatternList::show_all_patterns ();
00478 
00479   show_all_applied_patterns ();
00480 }
 | 
| 
 | 
| ? | this is the cmt show applied_patterns command It just shows the pattern applications. Definition at line 486 of file cmt_pattern.cxx. References Use::apply_patterns, Use::current(), Use::get_package_name(), ApplyPattern::name, ApplyPattern::show(), cmt_vector< ApplyPattern >::size(), and use. Referenced by Cmt::do_show_applied_patterns(), and show_all(). 00487 {
00488   Use* use = &(Use::current ());
00489   for (int i = 0; i < use->apply_patterns.size (); i++)
00490     {
00491       const ApplyPattern& apply_pattern = use->apply_patterns[i];
00492 
00493       cout << "# " << use->get_package_name ()
00494            << " applies pattern " << apply_pattern.name << " => " << endl;
00495       apply_pattern.show ();
00496       cout << endl;
00497     }
00498 }
 | 
| 
 | 
| ? | Definition at line 501 of file cmt_pattern.cxx. References PatternList::show_all_pattern_names(). Referenced by Cmt::do_show_pattern_names(). 00502 {
00503   PatternList::show_all_pattern_names ();
00504 }
 | 
| 
 | 
| ? | Definition at line 68 of file cmt_pattern.h. Referenced by action(), add(), ApplyPattern::apply(), PatternList::apply_all_globals(), Use::apply_global_patterns(), and clear(). | 
| 
 | 
| ? | Definition at line 67 of file cmt_pattern.h. Referenced by ApplyPattern::action(), add(), clear(), expand(), and show(). | 
| 
 | 
| ? | Definition at line 66 of file cmt_pattern.h. Referenced by action(), add(), apply(), PatternList::apply_all_globals(), clear(), show(), and PatternList::show_all_pattern_names(). | 
| 
 | 
| ? | Definition at line 69 of file cmt_pattern.h. Referenced by add(), PatternList::add_pattern(), apply(), clear(), PatternList::find(), show(), and show_all_applied_patterns(). |