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

ClientCollector Class Reference

This PathScanner actor collects all packages clients of the specified one It is used by the cmt show clients operation. More...

Inheritance diagram for ClientCollector:

Inheritance graph
[legend]
Collaboration diagram for ClientCollector:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ClientCollector (const cmt_string &package, const cmt_string &version)
void run (const cmt_string &package, const cmt_string &version, const cmt_string &path)
int count ()

Private Attributes

const cmt_stringm_package
const cmt_stringm_version
int m_count

Detailed Description

This PathScanner actor collects all packages clients of the specified one It is used by the cmt show clients operation.

Definition at line 137 of file cmt_parser.cxx.


Constructor & Destructor Documentation

ClientCollector::ClientCollector const cmt_string package,
const cmt_string version
 

Definition at line 246 of file cmt_parser.cxx.

00247                                                              :
00248   m_package (package), m_version (version), m_count (0)
00249 {
00250 }


Member Function Documentation

int ClientCollector::count  ) 
 

Definition at line 357 of file cmt_parser.cxx.

References m_count.

Referenced by Cmt::do_show_clients().

00358 {
00359   return (m_count);
00360 }

void ClientCollector::run const cmt_string package,
const cmt_string version,
const cmt_string path
[virtual]
 

Reimplemented from PathScanner::actor.

Definition at line 253 of file cmt_parser.cxx.

References CmtSystem::cmt_string_vector, cmt_string::erase(), CmtSystem::file_separator(), cmt_string::find(), m_package, m_version, cmt_string::read(), cmt_vector< T >::size(), cmt_string::size(), CmtSystem::split(), cmt_string::substr(), and CmtSystem::test_file().

00256 {
00257   cmt_string dir = path;
00258   dir += CmtSystem::file_separator ();
00259   dir += package;
00260   dir += CmtSystem::file_separator ();
00261   if (version != "")
00262     {
00263       dir += version;
00264       dir += CmtSystem::file_separator ();
00265     }
00266 
00267   cmt_string req;
00268 
00269   req = dir;
00270   req += "cmt";
00271   req += CmtSystem::file_separator ();
00272   req += "requirements";
00273 
00274   cmt_string requirements;
00275   cmt_string line;
00276   CmtSystem::cmt_string_vector words;
00277 
00278   if (CmtSystem::test_file (req))
00279     {
00280       requirements.read (req);
00281     }
00282   else
00283     {
00284       req = dir;
00285       req += "mgr";
00286       req += CmtSystem::file_separator ();
00287       req += "requirements";
00288       if (CmtSystem::test_file (req))
00289         {
00290           requirements.read (req);
00291         }
00292     }
00293 
00294   if (requirements != "")
00295     {
00296       int pos = 0;
00297       int max_pos = requirements.size ();
00298 
00299       while (pos < max_pos)
00300         {
00301           int cr = requirements.find (pos, "\r\n");
00302           int nl = requirements.find (pos, '\n');
00303           int first = nl;
00304           int length = 1;
00305                 
00306           if (cr != cmt_string::npos)
00307             {
00308               if (nl == cmt_string::npos)
00309                 {
00310                   first = cr;
00311                   length = 2;
00312                 }
00313               else
00314                 {
00315                   first = (nl < cr) ? nl : cr;
00316                   length = (nl < cr) ? 1 : 2;
00317                 }
00318             }
00319                 
00320           if (first == cmt_string::npos)
00321             {
00322               requirements.substr (pos, line);
00323               pos = max_pos;
00324             }
00325           else if (first > pos)
00326             {
00327               requirements.substr (pos, first - pos, line);
00328               pos = first + length;
00329             }
00330           else
00331             {
00332               line.erase (0);
00333               pos += length;
00334             }
00335 
00336           CmtSystem::split (line, " \t", words);
00337 
00338           if ((words.size () > 2) && (words[0] == "use")) 
00339             {
00340               if ((words[1] == m_package) && 
00341                   ((words[2] == m_version) || (m_version == "")))
00342                 {
00343                   cout << "# " << package << " " << version << " " << path;
00344                   if (m_version == "")
00345                     {
00346                       cout << " (use version " << words[2] << ")";
00347                     }
00348                   cout << endl;
00349                   m_count++;
00350                 }
00351             }
00352         }
00353     }
00354 }


Member Data Documentation

int ClientCollector::m_count [private]
 

Definition at line 150 of file cmt_parser.cxx.

Referenced by count().

const cmt_string& ClientCollector::m_package [private]
 

Definition at line 148 of file cmt_parser.cxx.

Referenced by run().

const cmt_string& ClientCollector::m_version [private]
 

Definition at line 149 of file cmt_parser.cxx.

Referenced by run().


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