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

ProjectFactory Class Reference

#include

Inheritance diagram for ProjectFactory:

[legend]
Collaboration diagram for ProjectFactory:

[legend]
List of all members.

Public Methods

void? reset ()
void? create_project (const cmt_string &path, const cmt_string &path_source)

Static Public Methods

IProjectFactory &? instance ()

Private Attributes

Project *? m_first
Project *? m_previous
int? m_id

Member Function Documentation

void ProjectFactory::create_project (? const cmt_string &? ? path,
const cmt_string &? ? path_source
)? [virtual]
?

Implements IProjectFactory.

Definition at line 99 of file cmt_project.cxx.

References Tag::add(), Project::add(), CmtSystem::cd(), CmtSystem::compress_path(), cmt_string::find(), Project::get_cmtpath(), Project::get_cmtpath_pwd(), Project::get_name(), Project::get_project_file_name(), ProjectReader::get_project_name(), m_first, m_id, m_previous, Tag::mark(), SyntaxParser::parse_project_file_text(), PriorityConfig, Project::projects(), CmtSystem::pwd(), cmt_string::read(), Awk::run(), Project::set_cmtpath(), Project::set_cmtpath_pwd(), Project::set_cmtpath_source(), Project::set_predecessor(), cmt_vector< Project >::size(), and CmtSystem::test_file().

00101 {
00102   cmt_string compressed_path = path;
00103   CmtSystem::compress_path (compressed_path);
00104 
00105   static Project::ProjectVector& Projects = Project::projects ();
00106   
00107   for (int i = 0; i < Projects.size (); i++)
00108     {
00109       Project& p = Projects[i];
00110       
00111       if (p.get_cmtpath () == compressed_path) return;
00112       if (p.get_cmtpath_pwd () == compressed_path) return;
00113     }
00114   
00115   Project* project = 0;
00116   Project* cmt = 0;
00117   
00118   bool is_current = false;
00119   
00120   cmt_string here = CmtSystem::pwd ();
00121   if (!CmtSystem::cd (compressed_path)) return;
00122 
00123   cmt_string pwd = CmtSystem::pwd ();
00124   if (here.find (pwd) == 0) is_current = true;
00125 
00126   cmt_string text;
00127 
00128   if (CmtSystem::cd ("cmt") && CmtSystem::test_file (Project::get_project_file_name ()))
00129     {
00130       text.read (Project::get_project_file_name ());
00131 
00132       ProjectReader reader;
00133 
00134       reader.run (text);
00135 
00136       cmt_string name = reader.get_project_name ();
00137       if (name == "")
00138         {
00139           char buffer[20];
00140           m_id++;
00141           sprintf (buffer, "Project%d", m_id);
00142           name = buffer;
00143         }
00144 
00145       project = Project::add (name);
00146 
00147     }
00148   else
00149     {
00150       char buffer[20];
00151       if (source == "default path")
00152         {
00153           strcpy (buffer, "CMT");
00154         }
00155       else
00156         {
00157           m_id++;
00158           sprintf (buffer, "Project%d", m_id);
00159         }
00160       project = Project::add (buffer);
00161     }
00162 
00163   if (source == "default path")
00164     {
00165       cmt = project;
00166       is_current = false;
00167     }
00168   else
00169     {
00170       if (m_first == 0)
00171         {
00172           m_first = project;
00173         }
00174     }
00175 
00176   project->set_cmtpath (compressed_path);
00177   project->set_cmtpath_pwd (pwd);
00178   project->set_cmtpath_source (source);
00179 
00180   if (is_current)
00181     {
00182       Tag* tag;
00183       
00184       tag = Tag::add (project->get_name (), PriorityConfig, "PROJECT", 0);
00185       tag->mark ();
00186     }
00187 
00188   if (m_previous != 0) m_previous->set_predecessor (project);
00189   m_previous = project;
00190 
00191   if (text != "")
00192     {
00193       SyntaxParser::parse_project_file_text (text, 
00194                                              Project::get_project_file_name (),
00195                                              project);
00196     }
00197 
00198   CmtSystem::cd (here);
00199 }

IProjectFactory & ProjectFactory::instance (? ? )? [static]
?

Definition at line 84 of file cmt_project.cxx.

Referenced by Cmt::configure_cmt_path(), and Cmt::parse_arguments().

00085 {
00086   static ProjectFactory me;
00087   
00088   return (me);
00089 }

void ProjectFactory::reset (? ? )? [virtual]
?

Implements IProjectFactory.

Definition at line 91 of file cmt_project.cxx.

References Project::clear_all(), m_first, m_id, and m_previous.

00092 {
00093   Project::clear_all ();
00094   m_first = 0;
00095   m_previous = 0;
00096   m_id = 0;
00097 }

Member Data Documentation

Project* ProjectFactory::m_first [private]
?

Definition at line 27 of file cmt_project.h.

Referenced by create_project(), and reset().

int ProjectFactory::m_id [private]
?

Definition at line 29 of file cmt_project.h.

Referenced by create_project(), and reset().

Project* ProjectFactory::m_previous [private]
?

Definition at line 28 of file cmt_project.h.

Referenced by create_project(), and reset().


The documentation for this class was generated from the following files:
Generated on Wed Sep 1 11:00:51 2004 for CMT by 1.2.18