idep_LinkDep Class Reference

#include <idep_linkdep.h>

List of all members.

Public Member Functions

 idep_LinkDep ()
 ~idep_LinkDep ()
void addDependencyFile (const char *fileName)
const char * addAlias (const char *aliasName, const char *componentName)
int readAliases (std::ostream &err, const char *file)
void addUnaliasDirectory (const char *dirName)
int readUnaliasDirectories (const char *file)
int calculate (std::ostream &err, int canonicalFlag=1, int suffixFlag=0)
int numComponents () const
int numLocalComponents () const
int numPackages () const
int numLevels () const
int numCycles () const
int numMembers () const
int ccd () const
double acd () const
double nccd () const
void printAliases (std::ostream &out) const
void printUnaliases (std::ostream &out) const
void printCycles (std::ostream &out) const
void printLevels (std::ostream &out, int longFlag=0, int supressFlag=0) const
void printSummary (std::ostream &out) const

Private Member Functions

 idep_LinkDep (const idep_LinkDep &)
idep_LinkDepoperator= (const idep_LinkDep &)

Private Attributes

idep_LinkDep_id_this

Friends

class idep_AliasIter
class idep_UnaliasIter
class idep_CycleIter
class idep_MemberIter
class idep_LevelIter
class idep_ComponentIter
class idep_DependencyIter

Detailed Description

Definition at line 25 of file idep_linkdep.h.


Constructor & Destructor Documentation

idep_LinkDep::idep_LinkDep ( const idep_LinkDep  )  [private]
idep_LinkDep::idep_LinkDep (  ) 

Definition at line 713 of file idep_ldep.cxx.

00714 : d_this(new idep_LinkDep_i)
00715 {
00716 }

idep_LinkDep::~idep_LinkDep (  ) 

Definition at line 718 of file idep_ldep.cxx.

References d_this.

00719 {
00720     delete d_this;
00721 }


Member Function Documentation

double idep_LinkDep::acd (  )  const

Definition at line 821 of file idep_ldep.cxx.

References ccd(), and numLocalComponents().

Referenced by printSummary().

00822 {
00823     return numLocalComponents() > 0 ? ccd()/(double)numLocalComponents() : 0.0;
00824 }

const char * idep_LinkDep::addAlias ( const char *  aliasName,
const char *  componentName 
)

Definition at line 728 of file idep_ldep.cxx.

References idep_AliasTable::add(), idep_LinkDep_i::d_aliases, d_this, and idep_AliasTable::lookup().

00729 {
00730     return d_this->d_aliases.add(alias, component) < 0 ?
00731                                         d_this->d_aliases.lookup(alias) : 0;
00732 }

void idep_LinkDep::addDependencyFile ( const char *  fileName  ) 

Definition at line 723 of file idep_ldep.cxx.

References idep_NameArray::append(), idep_LinkDep_i::d_dependencyFiles, and d_this.

Referenced by main().

00724 {
00725     d_this->d_dependencyFiles.append(fileName);
00726 }

void idep_LinkDep::addUnaliasDirectory ( const char *  dirName  ) 

Definition at line 739 of file idep_ldep.cxx.

References idep_NameIndexMap::add(), d_this, idep_LinkDep_i::d_unaliases, len, n, and stripDotSlash().

Referenced by main().

00740 {
00741     if (*dirName) {                             
00742         int len = strlen(dirName);
00743         if ('/' == dirName[len-1]) {            // already ends in '/'
00744             const char *n = stripDotSlash(dirName);
00745             if (*n) {                           // avoid adding empty dir 
00746                 d_this->d_unaliases.add(n);
00747             }
00748         }
00749         else {                                  // add trailing '/'
00750             char *buf = new char[len+2];                
00751             memcpy (buf, dirName, len);
00752             buf[len] = '/';
00753             buf[len+1] = '\0';
00754             const char *n = stripDotSlash(buf);
00755             if (*n) {                           // avoid adding empty dir
00756                 d_this->d_unaliases.add(n);
00757             }
00758             delete [] buf;
00759         }
00760     }
00761 }

int idep_LinkDep::calculate ( std::ostream &  err,
int  canonicalFlag = 1,
int  suffixFlag = 0 
)

Definition at line 781 of file idep_ldep.cxx.

References idep_LinkDep_i::calculate(), and d_this.

Referenced by main().

00782 {
00783     return d_this->calculate(orr, canonicalFlag, suffixFlag);
00784 }

int idep_LinkDep::ccd (  )  const

Definition at line 816 of file idep_ldep.cxx.

References idep_LinkDep_i::d_ccd, and d_this.

Referenced by acd(), nccd(), and printSummary().

00817 {
00818     return d_this->d_ccd; 
00819 }

double idep_LinkDep::nccd (  )  const

Definition at line 826 of file idep_ldep.cxx.

References ccd(), ccdBalencedBinaryTree(), and numLocalComponents().

Referenced by printSummary().

00827 {
00828     return numLocalComponents() > 0 ? 
00829         ccd()/ccdBalencedBinaryTree(numLocalComponents()) : 0.0;
00830 }

int idep_LinkDep::numComponents (  )  const

Definition at line 786 of file idep_ldep.cxx.

References idep_LinkDep_i::d_numComponents, and d_this.

Referenced by numLocalComponents(), and numPackages().

00787 {
00788     return d_this->d_numComponents;
00789 }

int idep_LinkDep::numCycles (  )  const

Definition at line 806 of file idep_ldep.cxx.

References idep_LinkDep_i::d_numCycles, and d_this.

Referenced by printLevels(), and printSummary().

00807 {
00808     return d_this->d_numCycles;
00809 }

int idep_LinkDep::numLevels (  )  const

Definition at line 801 of file idep_ldep.cxx.

References idep_LinkDep_i::d_numLevels, and d_this.

Referenced by printLevels(), and printSummary().

00802 {
00803     return d_this->d_numLevels - 1; // depth of component dependency graph
00804 }

int idep_LinkDep::numLocalComponents (  )  const

Definition at line 796 of file idep_ldep.cxx.

References numComponents(), and numPackages().

Referenced by acd(), nccd(), and printSummary().

00797 {
00798     return numComponents() - numPackages();
00799 }

int idep_LinkDep::numMembers (  )  const

Definition at line 811 of file idep_ldep.cxx.

References idep_LinkDep_i::d_numMembers, and d_this.

Referenced by printSummary().

00812 {
00813     return d_this->d_numMembers;
00814 }

int idep_LinkDep::numPackages (  )  const

Definition at line 791 of file idep_ldep.cxx.

References idep_LinkDep_i::d_levels_p, d_this, and numComponents().

Referenced by numLocalComponents(), and printSummary().

00792 {
00793     return numComponents() > 0 ? d_this->d_levels_p[0] : 0;
00794 }

idep_LinkDep& idep_LinkDep::operator= ( const idep_LinkDep  )  [private]
void idep_LinkDep::printAliases ( std::ostream &  out  )  const

Definition at line 832 of file idep_ldep.cxx.

References idep_AliasIter::fromName(), it, len, and idep_AliasIter::toName().

Referenced by main(), and operator<<().

00833 {
00834     idep_AliasIter it(*this);
00835     if (it) {
00836         int fieldWidth = 0;
00837         {
00838             for (idep_AliasIter it(*this); it; ++it) {
00839                 int len = strlen(it.fromName());
00840                 if (fieldWidth < len) {
00841                      fieldWidth = len;
00842                 }
00843             }
00844         }
00845         o << "ALIASES:" << std::endl;
00846         for (; it; ++it) {
00847             o.width(fieldWidth);
00848             o << it.fromName() << " -> " << it.toName() << std::endl;
00849         }
00850         o << std::endl;
00851     }
00852 }

void idep_LinkDep::printCycles ( std::ostream &  out  )  const

Definition at line 866 of file idep_ldep.cxx.

References warn().

Referenced by main(), and operator<<().

00867 {
00868     const char *const SPACE = "    ";
00869     for (idep_CycleIter cit(*this); cit; ++cit) {
00870         warn(ing, cit.cycle()) << "The following " << cit.weight() 
00871                   << " components are cyclically dependent:" << std::endl;
00872 
00873         for (idep_MemberIter mit(cit); mit; ++mit) {
00874             ing << SPACE << mit() << std::endl;
00875         }
00876         ing << std::endl;
00877     }
00878 }

void idep_LinkDep::printLevels ( std::ostream &  out,
int  longFlag = 0,
int  supressFlag = 0 
) const

Definition at line 880 of file idep_ldep.cxx.

References digits(), len, numCycles(), and numLevels().

Referenced by main(), and operator<<().

00881 {
00882     if (!supressFlag) {
00883         o << "LEVELS:" << std::endl;
00884     }
00885 
00886     const char CY_LT = '<';     // define characters to surround cycle index
00887     const char CY_RT = '>';     // define characters to surround cycle index
00888 
00889     int numLevelDigits = digits(numLevels() - 1);
00890     int componentNameFieldWidth = 0;
00891 
00892     int numCycleDigits = digits(numCycles() - 1);
00893     int cycleFieldWidth = numCycleDigits + 2;
00894 
00895     if (longFlag) {
00896         for (idep_LevelIter lit(*this); lit; ++lit) {
00897             for (idep_ComponentIter cit(lit); cit; ++cit) {
00898                 int len = strlen(cit());
00899                 if (componentNameFieldWidth < len) {
00900                      componentNameFieldWidth = len;
00901                 }
00902             }
00903         }
00904     }
00905 
00906     for (idep_LevelIter lit(*this); lit; ++lit) {
00907         if (!supressFlag) {
00908             o.width(numLevelDigits);
00909             o << lit() << ". ";
00910         }
00911         int firstFlag = 1;
00912         for (idep_ComponentIter cit(lit); cit; ++cit) {
00913             if (firstFlag) {
00914                 firstFlag = 0;
00915             }
00916             else {
00917                 if (!supressFlag) {
00918                     o.width(numLevelDigits + 2);
00919                     o << "";
00920                 }
00921             }
00922 
00923             if (longFlag) {
00924                 o.width(componentNameFieldWidth);
00925             }
00926             o << cit();
00927 
00928             if (numCycles() > 0 && !supressFlag) {
00929                 char field[100]; // will always be large enough
00930 #ifdef USE_STRSTREAM
00931                 std::ostrstream f(field, sizeof field);
00932 #else
00933                 std::ostringstream f(field);
00934 #endif
00935                 f << CY_LT << cit.cycle() << CY_RT << std::ends;
00936                 o.width(cycleFieldWidth);
00937                 if (cit.cycle()) {
00938                     FmtFlags_t oldState = o.flags();
00939                     o.setf(std::ios::left, std::ios::adjustfield);
00940                     o << field;
00941                     o.flags(oldState);
00942                 }
00943                 else {
00944                     o << ""; 
00945                 }
00946             }
00947 
00948             if (longFlag) {
00949                 int firstFlag = 1;
00950                 for (idep_DependencyIter dit(cit); dit; ++dit) {
00951                     if (firstFlag) {
00952                         firstFlag = 0;
00953                     }
00954                     else {
00955                         if (!supressFlag) {
00956                             o.width(numLevelDigits + 2);
00957                             o << "";
00958                             if (numCycles() > 0) {
00959                                 o.width(numCycleDigits + 2);
00960                                 o << "";
00961                             }
00962                         }
00963                         o.width(componentNameFieldWidth);
00964                         o << "";
00965                     }
00966                     o << ' ';
00967                     if (!supressFlag) {
00968                         o.width(numLevelDigits);
00969                         o << dit.level() << ". ";
00970                     }
00971                     o << dit();
00972                     if (dit.cycle() && !supressFlag) {
00973                         o << CY_LT << dit.cycle() << CY_RT;
00974                     }
00975                     o << std::endl;
00976                 }
00977             }
00978             o << std::endl;
00979         }
00980         o << std::endl;
00981     }
00982 }

void idep_LinkDep::printSummary ( std::ostream &  out  )  const

Definition at line 987 of file idep_ldep.cxx.

References acd(), ccd(), nccd(), numCycles(), numLevels(), numLocalComponents(), numMembers(), numPackages(), and s().

Referenced by main(), and operator<<().

00988 {
00989     FmtFlags_t iostate = o.setf(std::ios::left, std::ios::adjustfield);
00990     const int FIELD_BUFFER_SIZE = 100;   // Not completely arbitrary -- this
00991     char field[FIELD_BUFFER_SIZE];       // size will be always big enough!
00992     o << "SUMMARY:" << std::endl;
00993 
00994     const int N = 12;           // width of number field
00995     const int G = 1;            // width of gap
00996     const int W = 23;           // width of entire column
00997 
00998     if (numCycles() > 0) {
00999         { 
01000 #ifdef USE_STRSTREAM
01001             std::ostrstream f(field, sizeof field);
01002 #else
01003             std::ostringstream f(field);
01004 #endif
01005             f.width(N);
01006             f << numCycles() << " Cycle" << s(numCycles()) << std::ends;
01007             o.width(W);
01008             o << field;
01009         }
01010         o.width(G);
01011         o << "";
01012         { 
01013 #ifdef USE_STRSTREAM
01014             std::ostrstream f(field, sizeof field);
01015 #else
01016             std::ostringstream f(field);
01017 #endif
01018             f.width(N);
01019             f << numMembers() << " Members" << std::ends;
01020             o.width(W);
01021             o << field;
01022         }
01023         o << std::endl;
01024     }
01025     { 
01026 #ifdef USE_STRSTREAM
01027         std::ostrstream f(field, sizeof field);
01028 #else
01029         std::ostringstream f(field);
01030 #endif
01031         f.width(N);
01032         f << numLocalComponents() << " Component" 
01033                                   << s(numLocalComponents()) << std::ends;
01034         o.width(W);
01035         o << field;
01036     }
01037     o.width(G);
01038     o << "";
01039     { 
01040 #ifdef USE_STRSTREAM
01041         std::ostrstream f(field, sizeof field);
01042 #else
01043         std::ostringstream f(field);
01044 #endif
01045         f.width(N);
01046         f << numLevels() << " Level" << s(numLevels()) << std::ends;
01047         o.width(W);
01048         o << field;
01049     }
01050     o.width(G);
01051     o << "";
01052     { 
01053 #ifdef USE_STRSTREAM
01054         std::ostrstream f(field, sizeof field);
01055 #else
01056         std::ostringstream f(field);
01057 #endif
01058         f.width(N);
01059         f << numPackages() << " Package" << s(numPackages()) << std::ends;
01060         o.width(W);
01061         o << field;
01062     }
01063     o << std::endl;
01064     { 
01065 #ifdef USE_STRSTREAM
01066         std::ostrstream f(field, sizeof field);
01067 #else
01068         std::ostringstream f(field);
01069 #endif
01070         f.width(N);
01071         f << ccd() << " CCD" << std::ends;
01072         o.width(W);
01073         o << field;
01074     }
01075     o.width(G);
01076     o << "";
01077     { 
01078 #ifdef USE_STRSTREAM
01079         std::ostrstream f(field, sizeof field);
01080 #else
01081         std::ostringstream f(field);
01082 #endif
01083         f.width(N);
01084         f << acd() << " ACD" << std::ends;
01085         o.width(W);
01086         o << field;
01087     }
01088     o.width(G);
01089     o << "";
01090     { 
01091 #ifdef USE_STRSTREAM
01092         std::ostrstream f(field, sizeof field);
01093 #else
01094         std::ostringstream f(field);
01095 #endif
01096         f.width(N);
01097         f << nccd() << " NCCD" << std::ends;
01098         o.width(W);
01099         o << field;
01100     }
01101     o << std::endl;
01102 
01103     o.setf(iostate);
01104 
01105     o << std::endl;
01106 }

void idep_LinkDep::printUnaliases ( std::ostream &  out  )  const

Definition at line 854 of file idep_ldep.cxx.

References it.

Referenced by main(), and operator<<().

00855 {
00856     idep_UnaliasIter it(*this);
00857     if (it) {
00858         o << "UNALIASES:" << std::endl;
00859         for (; it; ++it) {
00860              o << it() << std::endl;
00861         }
00862         o << std::endl;
00863     }
00864 }

int idep_LinkDep::readAliases ( std::ostream &  err,
const char *  file 
)

Definition at line 734 of file idep_ldep.cxx.

References idep_LinkDep_i::d_aliases, and d_this.

Referenced by main().

00735 {
00736     return idep_AliasUtil::readAliases(&d_this->d_aliases, orr, file);
00737 }

int idep_LinkDep::readUnaliasDirectories ( const char *  file  ) 

Definition at line 763 of file idep_ldep.cxx.

References idep_NameIndexMap::add(), BAD, d_this, idep_LinkDep_i::d_unaliases, GOOD, and it.

Referenced by main().

00764 {
00765     enum { BAD = -1, GOOD = 0 };
00766 
00767     std::ifstream in(file);
00768     if (!in) {  
00769         return BAD;
00770     }
00771 
00772     for (idep_TokenIter it(in); it; ++it) {
00773         if ('\n' != *it()) {
00774             d_this->d_unaliases.add(it());
00775         }
00776     }
00777 
00778     return GOOD;
00779 }


Friends And Related Function Documentation

friend class idep_AliasIter [friend]

Definition at line 28 of file idep_linkdep.h.

friend class idep_ComponentIter [friend]

Definition at line 33 of file idep_linkdep.h.

friend class idep_CycleIter [friend]

Definition at line 30 of file idep_linkdep.h.

friend class idep_DependencyIter [friend]

Definition at line 34 of file idep_linkdep.h.

friend class idep_LevelIter [friend]

Definition at line 32 of file idep_linkdep.h.

friend class idep_MemberIter [friend]

Definition at line 31 of file idep_linkdep.h.

friend class idep_UnaliasIter [friend]

Definition at line 29 of file idep_linkdep.h.


Member Data Documentation


The documentation for this class was generated from the following files:

Generated on 3 Oct 2018 for loon by  doxygen 1.6.1