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

DependencyAnalyzer Class Reference

Inheritance diagram for DependencyAnalyzer:

[legend]
Collaboration diagram for DependencyAnalyzer:

[legend]
List of all members.

Public Methods

? DependencyAnalyzer (const cmt_string &package_name, Constituent &constituent_ref)
void? begin ()
void? filter (const cmt_string &line)
virtual void? end ()

Protected Methods

void? add_trigger (const cmt_string &name)
void? add_use (Libmap &libmap)

Protected Attributes

CmtSystem::cmt_string_vector? include_dirs
cmt_vector< Libmap * >? uses
CmtSystem::cmt_string_vector? triggers
Constituent &? constituent
cmt_string? package
cmt_string? package_upper

Constructor & Destructor Documentation

DependencyAnalyzer::DependencyAnalyzer (? const cmt_string &? ? package_name,
Constituent &? ? constituent_ref
)?
?

Definition at line 381 of file cmt_triggers.cxx.

References CmtSystem::execute(), include_dirs, package_upper, cmt_string::replace_all(), cmt_string::size(), and CmtSystem::split().

00382                                                                       :
00383         package (package_name),
00384         constituent (constituent_ref)
00385 {
00386   cmt_string dirs;
00387 
00388   int pos;
00389   char c;
00390 
00391   package_upper = package;
00392 
00393   for (pos = 0; pos < package_upper.size (); pos++)
00394     {
00395       c = package_upper[pos];
00396       package_upper[pos] = toupper (c);
00397     }
00398 
00399   CmtSystem::execute ("cmt show include_dirs", dirs);
00400   dirs.replace_all ("\n", "");
00401   CmtSystem::split (dirs, " ", include_dirs);
00402 }


Member Function Documentation

void DependencyAnalyzer::add_trigger (? const cmt_string &? ? name )? [protected]
?

Definition at line 539 of file cmt_triggers.cxx.

References cmt_vector< cmt_string >::add(), cmt_vector< cmt_string >::size(), and triggers.

Referenced by filter().

00540 {
00541   for (int i = 0; i < triggers.size (); i++)
00542     {
00543       const cmt_string& trigger = triggers[i];
00544 
00545       if (trigger == name) return;
00546     }
00547 
00548   cmt_string& new_trigger = triggers.add ();
00549 
00550   new_trigger = name;
00551 }

void DependencyAnalyzer::add_use (? Libmap &? ? libmap )? [protected]
?

Definition at line 553 of file cmt_triggers.cxx.

References cmt_vector< Libmap * >::push_back(), cmt_vector< Libmap * >::size(), and uses.

Referenced by filter().

00554 {
00555   for (int i = 0; i < uses.size (); i++)
00556     {
00557       const Libmap& ref = *(uses[i]);
00558 
00559       if (ref == libmap) return;
00560     }
00561 
00562   uses.push_back (&libmap);
00563 }

void DependencyAnalyzer::begin (? ? )? [virtual]
?

Reimplemented from Awk.

Definition at line 404 of file cmt_triggers.cxx.

00405 {
00406 }

void DependencyAnalyzer::end (? ? )? [virtual]
?

Reimplemented from Awk.

Reimplemented in LibraryAnalyzer, and ApplicationAnalyzer.

Definition at line 535 of file cmt_triggers.cxx.

00536 {
00537 }

void DependencyAnalyzer::filter (? const cmt_string &? ? line )? [virtual]
?

Reimplemented from Awk.

Definition at line 408 of file cmt_triggers.cxx.

References add_trigger(), add_use(), CmtSystem::file_separator(), cmt_string::find(), cmt_string::find_last_of(), Libmap::find_with_trigger(), Cmt::get_quiet(), include_dirs, FAwk::m_file_name, cmt_string::npos, Libmap::null(), package_upper, cmt_string::replace(), cmt_string::replace_all(), cmt_vector< cmt_string >::size(), CmtSystem::split(), cmt_string::substr(), and cmt_string::trim().

00409 {
00410     /* Clip target out of dependency file... */
00411   int pos = line.find ("=");
00412   if ((pos == 0) || (pos == cmt_string::npos))
00413     {
00414       if (!Cmt::get_quiet ())
00415         {
00416           cerr << "  ERROR: Syntax in dependency file: " << line << endl;
00417           cerr << "  Missing = or target name." << endl;
00418         }
00419       exit (1);
00420     }
00421 
00422   cmt_string module;
00423 
00424   line.substr (0, pos, module);
00425   module.trim ();
00426   module.replace ("_dependencies", "");
00427 
00428   if (module == "cmt_path_make") return;
00429 
00430   int underscore = module.find_last_of ("_");
00431 
00432   if (underscore != cmt_string::npos)
00433     {
00434       module[underscore] = '.';
00435     }
00436 
00437   static cmt_string dependencies;
00438 
00439   line.substr (pos + 1, dependencies);
00440 
00441   if (dependencies == "") 
00442     {
00443       cerr << "#CMT> Warning : It seems there is nothing after \'=\' "
00444           "in dependency file " << m_file_name << endl;
00445       return;
00446     }
00447 
00448   CmtSystem::cmt_string_vector deps;
00449 
00450   CmtSystem::split (dependencies, " ", deps);
00451 
00452   for (int i = 0; i < deps.size (); i++)
00453     {
00454       const cmt_string& dep = deps[i];
00455 
00456         //
00457         // dep may either be:
00458         //  o the module itself
00459         //  o a file in one of include_dirs
00460         //  o something else
00461         //
00462 
00463       if (dep.find (module) != cmt_string::npos)
00464         {
00465           // This is the module itself.
00466         }
00467       else
00468         {
00469           bool found = false;
00470 
00471           for (int j = 0; j < include_dirs.size (); j++)
00472             {
00473               const cmt_string& dir = include_dirs[j];
00474 
00475               if (dep.find (dir) == 0)
00476                 {
00477                   // This is a local dependency.
00478 
00479                   cmt_string name = dep;
00480 
00481                   if (dir == "$(src)")
00482                     {
00483                       cmt_string new_dir;
00484 
00485                       new_dir = "$(";
00486                       new_dir += package_upper;
00487                       new_dir += "ROOT)/src/";
00488 
00489                       name.replace (dir, new_dir);
00490                     }
00491 
00492                   if (CmtSystem::file_separator () == '\\')
00493                     {
00494                       name.replace_all (CmtSystem::file_separator (), "/");
00495                     }
00496 
00497                   Libmap& libmap = Libmap::find_with_trigger (name);
00498 
00499                   if (libmap != Libmap::null ())
00500                     {
00501                       add_use (libmap);
00502                     }
00503                   else
00504                     {
00505                       add_trigger (name);
00506                     }
00507 
00508                   found = true;
00509                   break;
00510                 }
00511             }
00512 
00513           if (!found)
00514             {
00515               cmt_string name = dep;
00516 
00517               if (CmtSystem::file_separator () == '\\')
00518                 {
00519                   name.replace_all (CmtSystem::file_separator (), "/");
00520                 }
00521 
00522               // This is an external dependency.
00523 
00524               Libmap& libmap = Libmap::find_with_trigger (name);
00525 
00526               if (libmap != Libmap::null ())
00527                 {
00528                   add_use (libmap);
00529                 }
00530             }
00531         }
00532     }
00533 }

Member Data Documentation

Constituent& DependencyAnalyzer::constituent [protected]
?

Definition at line 358 of file cmt_triggers.cxx.

Referenced by ApplicationAnalyzer::end(), and LibraryAnalyzer::end().

CmtSystem::cmt_string_vector DependencyAnalyzer::include_dirs [protected]
?

Definition at line 355 of file cmt_triggers.cxx.

Referenced by DependencyAnalyzer(), and filter().

cmt_string DependencyAnalyzer::package [protected]
?

Definition at line 359 of file cmt_triggers.cxx.

cmt_string DependencyAnalyzer::package_upper [protected]
?

Definition at line 360 of file cmt_triggers.cxx.

Referenced by DependencyAnalyzer(), and filter().

CmtSystem::cmt_string_vector DependencyAnalyzer::triggers [protected]
?

Definition at line 357 of file cmt_triggers.cxx.

Referenced by add_trigger(), and LibraryAnalyzer::end().

cmt_vector<Libmap*> DependencyAnalyzer::uses [protected]
?

Definition at line 356 of file cmt_triggers.cxx.

Referenced by add_use(), ApplicationAnalyzer::end(), and LibraryAnalyzer::end().


The documentation for this class was generated from the following file:
Generated on Thu Jul 1 15:26:49 2004 for CMT by 1.2.18