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

Package Class Reference

This class holds the definition of a package. More...

#include <Package.h>

Collaboration diagram for Package:

[legend]
List of all members.

Public Types

typedef cmt_vector? database

Public Methods

? Package ()
? A public constructor is required by cmt_vector. More...

bool? is_unreachable () const
void? set_unreachable ()
bool? is_done () const
void? set_done ()
int? operator== (const Package& other) const
? Comparison method. More...

int? operator!= (const Package& other) const
const cmt_string&? get_name () const
const cmt_string&? get_version () const
const cmt_string&? get_path () const
const cmt_string&? get_dot_name () const
const cmt_string&? get_cluster_name () const
const cmt_string&? get_dot_label () const
cmt_string? to_string () const
void? collect_clients (tree_node& node)
void? set_node (tree_node* n)
tree_node*? get_node () const
bool? has_version_directory () const
bool? auto_imports () const
bool? is_public () const
void? set_has_version_directory (bool state)
void? set_auto_imports (bool state)
void? set_is_public (bool state)
void? check_client (const Package& other, tree_node& node)
? Is this package a client of "other" ? (ie. More...

void? reduce ()

Static Public Methods

database&? get_database ()
? The database singleton. More...

Package&? create (const cmt_string& p, const cmt_string& v, const cmt_string& pp, const cmt_string& a = "")
? The factory method. More...


Private Methods

void? set (const cmt_string& p, const cmt_string& v, const cmt_string& pp, const cmt_string& a)
? This sets the Package attributes and builds the dot name & label. More...


Private Attributes

cmt_string? package
cmt_string? version
cmt_string? path
cmt_string? area
cmt_string? dot_name
cmt_string? cluster_name
cmt_string? dot_label
bool? unreachable
bool? done
tree_node*? node
bool? m_has_version_directory
bool? m_auto_imports
bool? m_is_public

Detailed Description

This class holds the definition of a package.

A database manages unique entries for each package (no duplicate entries) Each package also builds its own dot representation o a name for dot objects o a label to be displayed within dot boxes

Definition at line 37 of file Package.h.


Member Typedef Documentation

typedef cmt_vector Package::database
?

Definition at line 40 of file Package.h.


Constructor & Destructor Documentation

Package::Package ( )
?

A public constructor is required by cmt_vector.

Definition at line 65 of file Package.cxx.

00066 {
00067   unreachable = false;
00068   done = false;
00069   node = 0;
00070   m_has_version_directory = true;
00071   m_auto_imports = true;
00072   m_is_public = true;
00073 }

Member Function Documentation

bool Package::auto_imports ( ) const
?

Definition at line 169 of file Package.cxx.

Referenced by DotGenerator::run().

00170 {
00171   return (m_auto_imports);
00172 }

void Package::check_client ( const Package & other,
tree_node & node?)
?

Is this package a client of "other" ? (ie.

does it use "other")

Definition at line 209 of file Package.cxx.

Referenced by collect_clients().

00210 {
00211   //if (done) return;
00212   //done = true;
00213 
00214   //cout << "Checking if " << package << " " << version << " " << path << " is client of " << other.package << endl;
00215 
00216   const Package& me = *this;
00217   
00218   if (me == other) return;
00219   
00221   cmt_string req;
00222   
00223   req = area;
00224   if (req != "") req += CmtSystem::file_separator ();
00225   if (path != "")
00226     {
00227       req += path;
00228       req += CmtSystem::file_separator ();
00229     }
00230   req += package;
00231   req += CmtSystem::file_separator ();
00232   req += version;
00233   req += CmtSystem::file_separator ();
00234   req += "cmt";
00235   req += CmtSystem::file_separator ();
00236   req += "requirements";
00237   
00238   if (!CmtSystem::test_file (req))
00239     {
00240       req = area;
00241       if (req != "") req += CmtSystem::file_separator ();
00242       if (path != "")
00243         {
00244           req += path;
00245           req += CmtSystem::file_separator ();
00246         }
00247       req += package;
00248       req += CmtSystem::file_separator ();
00249       req += version;
00250       req += CmtSystem::file_separator ();
00251       req += "cmt";
00252       req += CmtSystem::file_separator ();
00253       req += "requirements";
00254       
00255       if (!CmtSystem::test_file (req)) return;
00256     }
00257   
00259   static cmt_regexp exp ("^use ");
00260   
00266   UseScanner scanner (other, *this, node);
00267   
00268   //cout << "req = " << req << endl;
00269   
00270   scanner.run (req, exp);
00271   
00272   //done = true;
00273 }

void Package::collect_clients ( tree_node & node?)
?

Definition at line 196 of file Package.cxx.

Referenced by UseScanner::filter(), and main().

00197 {
00198   const database& db = Package::get_database ();
00199   for (int i = 0; i < db.size (); i++)
00200     {
00201       Package& p = db[i];
00202       
00203       if (p == *this) continue;
00204       
00205       p.check_client (*this, node);
00206     }
00207 }

Package & Package::create ( const cmt_string & p,
const cmt_string & v,
const cmt_string & pp,
const cmt_string & a = ""?) [static]
?

The factory method.

Definition at line 12 of file Package.cxx.

Referenced by UsesGraphBuilder::UsesGraphBuilder(), UseScanner::filter(), UsesGraphBuilder::filter(), main(), DotGenerator::run(), and PackageViewer::run().

00016 {
00017   database& db = get_database ();
00018 
00019   bool has_wild_card = false;
00020   cmt_string v_prefix = v;
00021   cmt_regexp* v_exp = 0;
00022   int pos;
00023 
00024   if ((pos = v.find ("*")) != cmt_string::npos)
00025     {
00026       has_wild_card = true;
00027       v_prefix.erase (pos);
00028 
00029       cmt_string v_text_exp = "^";
00030       v_text_exp += v_prefix;
00031 
00032       v_exp = new cmt_regexp (v_text_exp);
00033     }
00034   
00035   for (int i = 0; i < db.size (); i++)
00036     {
00037       Package& entry = db[i];
00038       if ((entry.package == p) &&
00039           (entry.path == pp))
00040         {
00041           if (has_wild_card)
00042             {
00043               if (v_exp->match (entry.version))
00044                 {
00045                   return (entry);
00046                 }
00047             }
00048           else
00049             {
00050               if (entry.version == v)
00051                 {
00052                   return (entry);
00053                 }
00054             }
00055         }
00056     }
00057   
00058   Package& entry = db.add ();
00059     //entry.set (p, v_prefix, pp, a);
00060   entry.set (p, v, pp, a);
00061 
00062   return (entry);
00063 }

const cmt_string & Package::get_cluster_name ( ) const
?

Definition at line 130 of file Package.cxx.

Referenced by tree_node::get_cluster_name(), and DotGenerator::run().

00131 {
00132   static const cmt_string top = "top";
00133   if (cluster_name == "") return (top);
00134   return (cluster_name);
00135 }

database & Package::get_database ( ) [static]
?

The database singleton.

Definition at line 5 of file Package.cxx.

Referenced by collect_clients(), create(), and DotGenerator::run().

00006 {
00007   static database db;
00008   
00009   return (db);
00010 }

const cmt_string & Package::get_dot_label ( ) const
?

Definition at line 137 of file Package.cxx.

Referenced by tree_node::get_dot_label(), DotGenerator::run(), and tree_node::show_node().

00138 {
00139   return (dot_label);
00140 }

const cmt_string & Package::get_dot_name ( ) const
?

Definition at line 125 of file Package.cxx.

Referenced by tree_node::get_dot_name(), DotGenerator::run(), and tree_node::show_node().

00126 {
00127   return (dot_name);
00128 }

const cmt_string & Package::get_name ( ) const
?

Definition at line 110 of file Package.cxx.

Referenced by tree_node::check_cycle(), UseScanner::filter(), UsesGraphBuilder::filter(), tree_node::get_name(), and UsesGraphBuilder::start().

00111 {
00112   return (package);
00113 }

tree_node * Package::get_node ( ) const
?

Definition at line 159 of file Package.cxx.

Referenced by tree_node::references().

00160 {
00161   return (node);
00162 }

const cmt_string & Package::get_path ( ) const
?

Definition at line 120 of file Package.cxx.

Referenced by UsesGraphBuilder::start().

00121 {
00122   return (path);
00123 }

const cmt_string & Package::get_version ( ) const
?

Definition at line 115 of file Package.cxx.

Referenced by UsesGraphBuilder::start().

00116 {
00117   return (version);
00118 }

bool Package::has_version_directory ( ) const
?

Definition at line 164 of file Package.cxx.

Referenced by DotGenerator::run().

00165 {
00166   return (m_has_version_directory);
00167 }

bool Package::is_done ( ) const
?

Definition at line 85 of file Package.cxx.

Referenced by UseScanner::filter(), and DotGenerator::run().

00086 {
00087   return (done);
00088 }

bool Package::is_public ( ) const
?

Definition at line 174 of file Package.cxx.

Referenced by DotGenerator::run().

00175 {
00176   return (m_is_public);
00177 }

bool Package::is_unreachable ( ) const
?

Definition at line 75 of file Package.cxx.

Referenced by DotGenerator::run(), tree_node::show_node(), and tree_node::show_tree().

00076 {
00077   return (unreachable);
00078 }

int Package::operator!= ( const Package & other?) const
?

Definition at line 104 of file Package.cxx.

00105 {
00106   const Package& me = *this;
00107   return (!(me == other));
00108 }

int Package::operator== ( const Package & other?) const
?

Comparison method.

Definition at line 95 of file Package.cxx.

00096 {
00097   if (package != other.package) return (0);
00098   if (version != other.version) return (0);
00099   if (path    != other.path) return (0);
00100   if (area    != other.area) return (0);
00101   return (1);
00102 }

void Package::reduce ( )
?

Definition at line 328 of file Package.cxx.

00329 {
00330   if (node == 0) return;
00331 
00332     //node->reduce ();
00333 }

void Package::set ( const cmt_string & p,
const cmt_string & v,
const cmt_string & pp,
const cmt_string & a?) [private]
?

This sets the Package attributes and builds the dot name & label.

Then, only use statements to "other" are considered.

Definition at line 275 of file Package.cxx.

Referenced by create().

00279 {
00280   package = p;
00281   version = v;
00282   path = pp;
00283   area = a;
00284   
00285   dot_name = "\"";
00286   dot_name += package;
00287   dot_name += "-";
00288   dot_name += version;
00289 
00290     /*
00291   if (path != "")
00292     {
00293       dot_name += "-";
00294       dot_name += path;
00295     }
00296     */
00297 
00298   dot_name += "\"";
00299   
00300 
00301   cluster_name = "";
00302   if (path != "")
00303     {
00304       cluster_name = path;
00305       cluster_name.replace_all ("/", "_");
00306       cluster_name.replace_all ("\\", "_");
00307     }
00308 
00309   
00310   dot_label = "";
00311 
00312     /*
00313       if (path != "")
00314       {
00315       dot_label += path;
00316       dot_label += "/";
00317       }
00318     */
00319   
00320   dot_label += package;
00321   if (version != "*")
00322     {
00323       dot_label += "\\n";
00324       dot_label += version;
00325     }
00326 }

void Package::set_auto_imports ( bool state?)
?

Definition at line 186 of file Package.cxx.

Referenced by UsesGraphBuilder::filter().

00187 {
00188   m_auto_imports = state;
00189 }

void Package::set_done ( )
?

Definition at line 90 of file Package.cxx.

Referenced by UseScanner::filter(), and UsesGraphBuilder::filter().

00091 {
00092   done = true;
00093 }

void Package::set_has_version_directory ( bool state?)
?

Definition at line 179 of file Package.cxx.

Referenced by UsesGraphBuilder::filter().

00180 {
00181   m_has_version_directory = state;
00182 }

void Package::set_is_public ( bool state?)
?

Definition at line 191 of file Package.cxx.

Referenced by UsesGraphBuilder::filter().

00192 {
00193   m_is_public = state;
00194 }

void Package::set_node ( tree_node * n?)
?

Definition at line 154 of file Package.cxx.

Referenced by tree_node::install_as_reference_node().

00155 {
00156   node = n;
00157 }

void Package::set_unreachable ( )
?

Definition at line 80 of file Package.cxx.

Referenced by UsesGraphBuilder::filter().

00081 {
00082   unreachable = true;
00083 }

cmt_string Package::to_string ( ) const
?

Definition at line 142 of file Package.cxx.

00143 {
00144   cmt_string result;
00145   result += package;
00146   result += " ";
00147   result += version;
00148   result += " ";
00149   result += path;
00150   
00151   return (result);
00152 }

Member Data Documentation

cmt_string Package::area [private]
?

Definition at line 99 of file Package.h.

cmt_string Package::cluster_name [private]
?

Definition at line 102 of file Package.h.

bool Package::done [private]
?

Definition at line 106 of file Package.h.

cmt_string Package::dot_label [private]
?

Definition at line 103 of file Package.h.

cmt_string Package::dot_name [private]
?

Definition at line 101 of file Package.h.

bool Package::m_auto_imports [private]
?

Definition at line 111 of file Package.h.

bool Package::m_has_version_directory [private]
?

Definition at line 110 of file Package.h.

bool Package::m_is_public [private]
?

Definition at line 112 of file Package.h.

tree_node * Package::node [private]
?

Definition at line 108 of file Package.h.

cmt_string Package::package [private]
?

Definition at line 96 of file Package.h.

cmt_string Package::path [private]
?

Definition at line 98 of file Package.h.

bool Package::unreachable [private]
?

Definition at line 105 of file Package.h.

cmt_string Package::version [private]
?

Definition at line 97 of file Package.h.


The documentation for this class was generated from the following files:
Generated at Fri Apr 12 16:18:16 2002 for cmtgrapher by 1.2.3 written by , ??1997-2000