idep_CompileDep Class Reference

#include <idep_compiledep.h>

List of all members.

Public Member Functions

 idep_CompileDep ()
 ~idep_CompileDep ()
void addIncludeDirectory (const char *dirName)
int readIncludeDirectories (const char *file)
void addRootFile (const char *fileName)
int readRootFiles (const char *file)
void inputRootFiles ()
int calculate (std::ostream &err, int recursionFlag=1)

Private Member Functions

 idep_CompileDep (const idep_CompileDep &)
idep_CompileDepoperator= (const idep_CompileDep &)

Private Attributes

idep_CompileDep_id_this

Friends

class idep_RootFileIter
class idep_HeaderFileIter

Detailed Description

Definition at line 15 of file idep_compiledep.h.


Constructor & Destructor Documentation

idep_CompileDep::idep_CompileDep ( const idep_CompileDep  )  [private]
idep_CompileDep::idep_CompileDep (  ) 

Definition at line 196 of file idep_cdep.cxx.

00197 : d_this(new idep_CompileDep_i)
00198 {
00199 }

idep_CompileDep::~idep_CompileDep (  ) 

Definition at line 201 of file idep_cdep.cxx.

References d_this.

00202 {
00203     delete d_this;
00204 }


Member Function Documentation

void idep_CompileDep::addIncludeDirectory ( const char *  dirName  ) 

Definition at line 206 of file idep_cdep.cxx.

References idep_NameArray::append(), idep_CompileDep_i::d_includeDirectories, d_this, and len.

Referenced by main(), and readIncludeDirectories().

00207 {
00208     if (*dirName) {
00209         int len = strlen(dirName);
00210         if ('/' == dirName[len-1]) {            // already ends in '/'
00211             d_this->d_includeDirectories.append(dirName);               
00212         }
00213         else {                                  // add trailing '/'
00214             char *buf = new char[len+2];
00215             memcpy(buf, dirName, len);
00216             buf[len] = '/';
00217             buf[len+1] = '\0';
00218             d_this->d_includeDirectories.append(buf);           
00219             delete [] buf;
00220         }
00221     }
00222 }

void idep_CompileDep::addRootFile ( const char *  fileName  ) 

Definition at line 229 of file idep_cdep.cxx.

References idep_NameArray::append(), idep_CompileDep_i::d_rootFiles, and d_this.

Referenced by inputRootFiles(), main(), and readRootFiles().

00230 {
00231     d_this->d_rootFiles.append(fileName);               
00232 }

int idep_CompileDep::calculate ( std::ostream &  err,
int  recursionFlag = 1 
)

Definition at line 248 of file idep_cdep.cxx.

References idep_NameIndexMap::add(), idep_BinRel::appendEntry(), BAD, idep_CompileDep_i::d_dependencies_p, idep_CompileDep_i::d_fileNames_p, idep_CompileDep_i::d_includeDirectories, idep_CompileDep_i::d_numRootFiles, idep_CompileDep_i::d_rootFiles, d_this, err(), getDep(), GOOD, idep_NameArray::length(), idep_BinRel::makeTransitive(), s_err_p, s_recurse, and search().

Referenced by main().

00249 {
00250     enum { BAD = -1, GOOD = 0 } status = GOOD;
00251 
00252     // clean up any previous calculation artifacts
00253     delete d_this->d_fileNames_p;       
00254     delete d_this->d_dependencies_p;
00255 
00256     // allocate new data structures for this calculation
00257     d_this->d_fileNames_p = new idep_NameIndexMap;
00258     d_this->d_dependencies_p = new idep_BinRel;     
00259     d_this->d_numRootFiles = 0;
00260 
00261 
00262     // place all root files at the start of the relation
00263     int i;
00264     for (i = 0; i < d_this->d_rootFiles.length(); ++i) {
00265         idep_String s;
00266         const char *file = d_this->d_rootFiles[i];
00267         const char *dirFile = search(&s, d_this->d_includeDirectories, file);
00268 
00269         if (!dirFile) {
00270             err(orr) << "root file \"" << file 
00271                     << "\" not found." << std::endl;
00272             status = BAD;
00273         }
00274         else if (d_this->d_fileNames_p->add(dirFile) < 0) { 
00275             err(orr) << "root file \"" << file 
00276                     << "\" redundantly specified." << std::endl;
00277             status = BAD;
00278         }
00279         else {
00280             ++d_this->d_numRootFiles;
00281             d_this->d_dependencies_p->appendEntry();
00282         }
00283     }
00284         
00285     // We must now investigate the compile-time dependencies for each 
00286     // translation unit recursively.  First we will set up several
00287     // file-scope pointers to reduce recursive overhead.
00288 
00289     s_dependencies_p = d_this->d_dependencies_p;
00290     s_files_p = d_this->d_fileNames_p;
00291     s_includes_p = &d_this->d_includeDirectories;
00292     s_recurse = recursionFlag;
00293     s_err_p = &orr;
00294 
00295     // Each translation unit forms the root of a tree of dependencies.
00296     // We will visit each node only once, recording the results as we go.
00297     // Initially, only the translation units are present in the relation.
00298 
00299     for (i = 0; i < d_this->d_numRootFiles; ++i) {
00300         const char *name = (*d_this->d_fileNames_p)[i];
00301         if (getDep(i)) {
00302             err(orr) << "could not determine all dependencies for \""
00303                     << name << "\"." << std::endl;
00304             status = BAD;
00305         }
00306     }
00307 
00308     if (recursionFlag) {
00309         d_this->d_dependencies_p->makeTransitive();
00310     }
00311 
00312     return status;
00313 }

void idep_CompileDep::inputRootFiles (  ) 

Definition at line 239 of file idep_cdep.cxx.

References addRootFile(), and loadFromStream().

Referenced by main().

00240 {
00241     if (std::cin) {
00242         loadFromStream(std::cin, this, &idep_CompileDep::addRootFile); 
00243         // cin.clear(0);             // reset eof for standard input
00244         std::cin.clear();             // reset eof for standard input
00245     }
00246 }

idep_CompileDep& idep_CompileDep::operator= ( const idep_CompileDep  )  [private]
int idep_CompileDep::readIncludeDirectories ( const char *  file  ) 

Definition at line 224 of file idep_cdep.cxx.

References addIncludeDirectory(), and loadFromFile().

Referenced by main().

00225 {
00226     return loadFromFile(file, this, &idep_CompileDep::addIncludeDirectory); 
00227 }

int idep_CompileDep::readRootFiles ( const char *  file  ) 

Definition at line 234 of file idep_cdep.cxx.

References addRootFile(), and loadFromFile().

Referenced by main().

00235 {
00236     return loadFromFile(file, this, &idep_CompileDep::addRootFile); 
00237 }


Friends And Related Function Documentation

friend class idep_HeaderFileIter [friend]

Definition at line 19 of file idep_compiledep.h.

friend class idep_RootFileIter [friend]

Definition at line 18 of file idep_compiledep.h.


Member Data Documentation

Definition at line 16 of file idep_compiledep.h.

Referenced by addIncludeDirectory(), addRootFile(), calculate(), and ~idep_CompileDep().


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

Generated on 16 Apr 2018 for loon by  doxygen 1.6.1