Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

PatternList Class Reference

#include <cmt_pattern.h>

Collaboration diagram for PatternList:

Collaboration graph
[legend]
List of all members.

Public Types

typedef cmt_map< cmt_string,
PatternList
PatternListMap
typedef cmt_vector< PatternListPatternListVector

Public Member Functions

 PatternList ()
 PatternList (const cmt_string &name)
 ~PatternList ()
Pattern::PatternPtrVectorget_patterns ()
void add_pattern (Pattern *pattern)
void clear ()

Static Public Member Functions

PatternListfind (const cmt_string &name)
Patternfind_pattern (const cmt_string &name)
Patternfind (const cmt_string &name, Use *use)
PatternListadd (const cmt_string &name)
void clear_all ()
PatternListMappattern_list_map ()
PatternListVectorpattern_lists ()
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_patterns ()
 Show all patterns.

void show_all_pattern_names ()
 Show all pattern names.


Public Attributes

cmt_string m_name
Pattern::PatternPtrVector m_patterns

Member Typedef Documentation

typedef cmt_map<cmt_string, PatternList> PatternList::PatternListMap
 

Definition at line 76 of file cmt_pattern.h.

Referenced by add(), clear_all(), find(), pattern_list_map(), and Database::pattern_list_map().

typedef cmt_vector<PatternList> PatternList::PatternListVector
 

Definition at line 77 of file cmt_pattern.h.

Referenced by add(), apply_all_globals(), clear_all(), pattern_lists(), Database::pattern_lists(), show_all_pattern_names(), and show_all_patterns().


Constructor & Destructor Documentation

PatternList::PatternList  ) 
 

Definition at line 108 of file cmt_pattern.cxx.

00109 {
00110 }

PatternList::PatternList const cmt_string name  ) 
 

Definition at line 112 of file cmt_pattern.cxx.

00112                                                 : m_name (name)
00113 {
00114 }

PatternList::~PatternList  ) 
 

Definition at line 116 of file cmt_pattern.cxx.

References clear().

00117 {
00118   clear ();
00119 }


Member Function Documentation

PatternList * PatternList::add const cmt_string name  )  [static]
 

Definition at line 61 of file cmt_pattern.cxx.

References cmt_map< K, T >::add(), cmt_vector< T >::add(), find(), m_name, pattern_list_map(), pattern_lists(), PatternListMap, and PatternListVector.

Referenced by Pattern::add().

00062 {
00063   PatternList* list = find (name);
00064   if (list != 0) return (list);
00065 
00066   static PatternListVector& vector = pattern_lists ();
00067 
00068   PatternList& pl = vector.add ();
00069   pl.m_name = name;
00070 
00071   static PatternListMap& map = pattern_list_map ();
00072   map.add (name, pl);
00073 
00074   return (&pl);
00075 }

void PatternList::add_pattern Pattern pattern  ) 
 

Definition at line 126 of file cmt_pattern.cxx.

References m_patterns, cmt_vector< T >::push_back(), cmt_vector< T >::size(), and Pattern::use.

Referenced by Pattern::add().

00127 {
00128   for (int i = 0; i < m_patterns.size (); i++)
00129     {
00130       Pattern* p = m_patterns[i];
00131       if (p->use == pattern->use)
00132         {
00133           m_patterns[i] = pattern;
00134           return;
00135         }
00136     }
00137 
00138   m_patterns.push_back (pattern);
00139 }

void PatternList::apply_all_globals Use use  )  [static]
 

Applies all global patterns to a given Use.

Definition at line 372 of file cmt_pattern.cxx.

References Pattern::apply(), IgnorePattern::find(), Use::get_package_name(), Pattern::global, m_patterns, Pattern::name, pattern_lists(), PatternListVector, and cmt_vector< T >::size().

00373 {
00374   if (use->get_package_name () == "CMT") return;
00375 
00376   static PatternListVector& PatternLists = pattern_lists ();
00377 
00378   int i;
00379 
00380   for (i = 0; i < PatternLists.size (); i++)
00381     {
00382       PatternList& pl = PatternLists[i];
00383 
00384       int n = pl.m_patterns.size ();
00385 
00386       if (n > 0)
00387         {
00388           Pattern* p = pl.m_patterns[n-1];
00389 
00390           if ((p != 0) && (p->global)) 
00391             {
00392               if (p->global)
00393                 {
00394                   if (IgnorePattern::find (p->name, use) == 0) p->apply (use);
00395                 }
00396             }
00397         }
00398     }
00399 }

void PatternList::apply_all_globals  )  [static]
 

Applies all global patterns to all uses.

Definition at line 348 of file cmt_pattern.cxx.

References Pattern::apply(), Pattern::global, m_patterns, pattern_lists(), PatternListVector, and cmt_vector< T >::size().

Referenced by Pattern::apply_all_globals().

00349 {
00350   static PatternListVector& PatternLists = pattern_lists ();
00351 
00352   int i;
00353 
00354   for (i = 0; i < PatternLists.size (); i++)
00355     {
00356       PatternList& pl = PatternLists[i];
00357 
00358       int n = pl.m_patterns.size ();
00359 
00360       if (n > 0)
00361         {
00362           Pattern* p = pl.m_patterns[n-1];
00363 
00364           if ((p != 0) && (p->global)) p->apply ();
00365         }
00366     }
00367 }

void PatternList::clear  ) 
 

Definition at line 141 of file cmt_pattern.cxx.

References cmt_vector< T >::clear(), m_name, and m_patterns.

Referenced by clear_all(), and ~PatternList().

00142 {
00143   m_name = "";
00144   m_patterns.clear ();
00145 }

void PatternList::clear_all  )  [static]
 

Definition at line 77 of file cmt_pattern.cxx.

References cmt_map< K, T >::clear(), cmt_vector< T >::clear(), clear(), pattern_list_map(), pattern_lists(), PatternListMap, PatternListVector, and cmt_vector< T >::size().

Referenced by Database::clear().

00078 {
00079   static PatternListVector& vector = pattern_lists ();
00080   static PatternListMap& map = pattern_list_map ();
00081 
00082   for (int i = 0; i < vector.size (); i++)
00083     {
00084       PatternList& p = vector[i];
00085       p.clear ();
00086     }
00087 
00088   vector.clear ();
00089   map.clear ();
00090 }

Pattern * PatternList::find const cmt_string name,
Use use
[static]
 

Definition at line 44 of file cmt_pattern.cxx.

References find(), get_patterns(), Pattern::PatternPtrVector, cmt_vector< T >::size(), and Pattern::use.

00045 {
00046   PatternList* list = find (name);
00047   if (list == 0) return (0);
00048 
00049   Pattern::PatternPtrVector& vector = list->get_patterns ();
00050 
00051   for (int i = 0; i < vector.size (); i++)
00052     {
00053       Pattern* p = vector[i];
00054 
00055       if (p->use == use) return (p);
00056     }
00057 
00058   return (0);
00059 }

PatternList * PatternList::find const cmt_string name  )  [static]
 

Definition at line 22 of file cmt_pattern.cxx.

References cmt_map< K, T >::find(), pattern_list_map(), and PatternListMap.

Referenced by add(), Pattern::find(), find(), and find_pattern().

00023 {
00024   static PatternListMap& map = pattern_list_map ();
00025 
00026   return (map.find (name));
00027 }

Pattern * PatternList::find_pattern const cmt_string name  )  [static]
 

Definition at line 30 of file cmt_pattern.cxx.

References find(), get_patterns(), Pattern::PatternPtrVector, and cmt_vector< T >::size().

Referenced by Pattern::find().

00031 {
00032   PatternList* list = find (name);
00033   if (list == 0) return (0);
00034 
00035   Pattern::PatternPtrVector& vector = list->get_patterns ();
00036 
00037   if (vector.size () == 0) return (0);
00038 
00039   Pattern* p = vector[vector.size () - 1];
00040 
00041   return (p);
00042 }

Pattern::PatternPtrVector & PatternList::get_patterns  ) 
 

Definition at line 121 of file cmt_pattern.cxx.

References m_patterns, and Pattern::PatternPtrVector.

Referenced by find(), and find_pattern().

00122 {
00123   return (m_patterns);
00124 }

PatternList::PatternListMap & PatternList::pattern_list_map  )  [static]
 

Definition at line 92 of file cmt_pattern.cxx.

References Database::instance(), Database::pattern_list_map(), and PatternListMap.

Referenced by add(), clear_all(), and find().

00093 {
00094   static Database& db = Database::instance ();
00095   static PatternListMap& map = db.pattern_list_map ();
00096 
00097   return (map);
00098 }

PatternList::PatternListVector & PatternList::pattern_lists  )  [static]
 

Definition at line 100 of file cmt_pattern.cxx.

References Database::instance(), Database::pattern_lists(), and PatternListVector.

Referenced by add(), apply_all_globals(), clear_all(), show_all_pattern_names(), and show_all_patterns().

00101 {
00102   static Database& db = Database::instance ();
00103   static PatternListVector& vector = db.pattern_lists ();
00104 
00105   return (vector);
00106 }

void PatternList::show_all_pattern_names  )  [static]
 

Show all pattern names.

Definition at line 427 of file cmt_pattern.cxx.

References m_patterns, Pattern::name, pattern_lists(), PatternListVector, and cmt_vector< T >::size().

Referenced by Pattern::show_all_names().

00428 {
00429   bool empty = true;
00430 
00431   static PatternListVector& PatternLists = pattern_lists ();
00432 
00433   int i;
00434 
00435   for (i = 0; i < PatternLists.size (); i++)
00436     {
00437       PatternList& pl = PatternLists[i];
00438 
00439       int n = pl.m_patterns.size ();
00440 
00441       if (n > 0)
00442         {
00443           Pattern* p = pl.m_patterns[n-1];
00444 
00445           if (p != 0)
00446             {
00447               cout << p->name << " ";
00448               empty = false;
00449             }
00450         }
00451     }
00452   if (!empty) cout << endl;
00453 }

void PatternList::show_all_patterns  )  [static]
 

Show all patterns.

Definition at line 404 of file cmt_pattern.cxx.

References m_patterns, pattern_lists(), PatternListVector, Pattern::show(), and cmt_vector< T >::size().

Referenced by Pattern::show_all().

00405 {
00406   static PatternListVector& PatternLists = pattern_lists ();
00407 
00408   int i;
00409 
00410   for (i = 0; i < PatternLists.size (); i++)
00411     {
00412       PatternList& pl = PatternLists[i];
00413 
00414       int n = pl.m_patterns.size ();
00415 
00416       if (n > 0)
00417         {
00418           Pattern* p = pl.m_patterns[n-1];
00419 
00420           if (p != 0) p->show ();
00421         }
00422     }
00423 }


Member Data Documentation

cmt_string PatternList::m_name
 

Definition at line 105 of file cmt_pattern.h.

Referenced by add(), and clear().

Pattern::PatternPtrVector PatternList::m_patterns
 

Definition at line 106 of file cmt_pattern.h.

Referenced by add_pattern(), apply_all_globals(), clear(), get_patterns(), show_all_pattern_names(), and show_all_patterns().


The documentation for this class was generated from the following files:
Generated on Mon May 2 10:25:56 2005 for CMT by doxygen 1.3.5