Changeset 470 for CMT


Ignore:
Timestamp:
Oct 30, 2008, 4:22:54 PM (16 years ago)
Author:
rybkin
Message:

See C.L. 371

Location:
CMT/HEAD
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • CMT/HEAD/ChangeLog

    r469 r470  
     12008-10-30    <rybkin@lal.in2p3.fr> 371
     2       
     3        * source/cmt_project.h: In class IProjectVisitor, add method in_again to
     4        be executed when the project is visited more then once. In class Project,
     5        add method ordered_projects to return ProjectVector ordered according to
     6        the CMTPATH entries, add method visit (IProjectVisitor&, ProjectPtrVector&),
     7        add member m_visits to hold the number of times the project has been visited
     8        * source/cmt_project.cxx: Implement method Project::ordered_projects,
     9        implement method in_again in classes VisitorForFillCMTPATH,
     10        VisitorForShowPaths. In Project::broadcast, Project::reverse_broadcast make
     11        use of ordered_projects to ensure that cmtpath_pattern and
     12        cmtpath_pattern_reverse are applied according to the order of the CMTPATH
     13        entries. Implement method visit (IProjectVisitor&, ProjectPtrVector&) to
     14        be used to visit the projects tree - the order is the projects upon which
     15        the project depends directly, then the direct dependencies of the of the
     16        first dependency, of the second dependency and so on. That is first left to
     17        right, then downwards. In method Project::start_visit, make use of the visit
     18       
    1192008-10-29    <rybkin@lal.in2p3.fr> 370
    220       
  • CMT/HEAD/source/cmt_project.cxx

    r460 r470  
    900900}
    901901
     902//----------------------------------------------------------
     903Project::ProjectVector& Project::ordered_projects ()
     904{
     905  static ProjectVector OrderedProjects;
     906  if (0 != OrderedProjects.size ()) return (OrderedProjects);
     907
     908  cmt_string s = Symbol::get_env_value ("CMTPATH");
     909  CmtSystem::cmt_string_vector path_vector;
     910  CmtSystem::split (s, CmtSystem::path_separator (), path_vector);
     911
     912  for (int i = 0; i < path_vector.size (); i++)
     913    {
     914      const cmt_string& path = path_vector[i];
     915      Project* p = Project::find_by_cmtpath (path);
     916      if (0 != p)
     917        {
     918          OrderedProjects.push_back (*p);
     919        }
     920      else
     921        {
     922          if (CmtMessage::active (Verbose))
     923            CmtMessage::warning ("No project for CMTPATH entry `" + path + "'");
     924        }
     925    }
     926
     927  return (OrderedProjects);
     928}
     929
    902930/*----------------------------------------------------------*/
    903931void Project::clear_all ()
     
    9791007    if (CmtSystem::test_directory (w))
    9801008      {
     1009        cout << "# Add path " << w << " from " << s << endl;
     1010      }
     1011  }
     1012
     1013  void in_again (Project* p)
     1014  {
     1015    const cmt_string& w = p->get_cmtpath_pwd ();
     1016    const cmt_string& s = p->get_cmtpath_source ();
     1017
     1018    if (s == "default path") return;
     1019
     1020    if (CmtSystem::test_directory (w))
     1021      {
     1022        cout << "# Remove path " << w << " from " << s << endl;
    9811023        cout << "# Add path " << w << " from " << s << endl;
    9821024      }
     
    10461088void Project::broadcast (IProjectAction& action)
    10471089{
    1048   static ProjectVector& Projects = projects ();
     1090  //  static ProjectVector& Projects = projects ();
     1091  static ProjectVector& Projects = ordered_projects ();
    10491092
    10501093  for (int i = 0; i < Projects.size (); i++)
     
    10591102void Project::reverse_broadcast (IProjectAction& action)
    10601103{
    1061   static ProjectVector& Projects = projects ();
     1104  //  static ProjectVector& Projects = projects ();
     1105  static ProjectVector& Projects = ordered_projects ();
    10621106
    10631107  for (int i = (Projects.size () - 1); i >= 0; i--)
     
    11861230
    11871231//----------------------------------------------------------
     1232void Project::visit (IProjectVisitor& visitor, ProjectPtrVector& projects)
     1233{
     1234  int size = projects.size ();
     1235  if (0 == size) return;
     1236
     1237  ProjectPtrVector children;
     1238  for (int j = 0; j < size; j++)
     1239    {
     1240      Project* p = projects[j];
     1241      if (20 == p->m_visits)
     1242        continue;
     1243      for (int i = 0; i < p->get_children_size (); i++)
     1244        {
     1245          Project* child = p->get_child (i);
     1246          if (0 == child->m_visits)       
     1247            visitor.in (child);
     1248          else
     1249            visitor.in_again (child);
     1250          child->m_visits++;
     1251          children.push_back (child);
     1252        }
     1253    }
     1254
     1255  visit (visitor, children);
     1256}
     1257
     1258//----------------------------------------------------------
    11881259void Project::start_visit (IProjectVisitor& visitor)
    11891260{
     
    11941265      Project& p = Projects[i];
    11951266      p.m_visited = false;
     1267      p.m_visits = 0;
    11961268    }
    11971269
     
    12051277    }
    12061278
    1207   visitor.pre (p);
    1208   p->visit (visitor);
    1209   visitor.post (p);
     1279  //  visitor.pre (p);
     1280  //p->visit (visitor);
     1281  //  visitor.post (p);
     1282  visitor.in (p);
     1283  p->m_visits++;
     1284  ProjectPtrVector projects;
     1285  projects.push_back (p);
     1286  visit (visitor, projects);
    12101287}
    12111288
     
    12431320    if (CmtSystem::test_directory (w))
    12441321      {
     1322        m_buffer += "path_append CMTPATH \"";
     1323        m_buffer += w;
     1324        m_buffer += "\" \n";
     1325      }
     1326  }
     1327
     1328  void in_again (Project* p)
     1329  {
     1330    const cmt_string& w = p->get_cmtpath_pwd ();
     1331    const cmt_string& s = p->get_cmtpath_source ();
     1332
     1333    if (s == "default path") return;
     1334
     1335    if (CmtSystem::test_directory (w))
     1336      {
     1337        m_buffer += "path_remove CMTPATH \"";
     1338        m_buffer += w;
     1339        m_buffer += "\" \n";
    12451340        m_buffer += "path_append CMTPATH \"";
    12461341        m_buffer += w;
  • CMT/HEAD/source/cmt_project.h

    r437 r470  
    8787  virtual void pre (Project* p) = 0;
    8888  virtual void in (Project* p) = 0;
     89  virtual void in_again (Project* p) = 0;
    8990  virtual void post (Project* p) = 0;
    9091};
     
    108109
    109110  static ProjectVector& projects ();
     111  static ProjectVector& ordered_projects ();
    110112  static void clear_all ();
    111113  static void show_all ();
     
    189191 
    190192  void   visit (IProjectVisitor& visitor);
     193  static  void   visit (IProjectVisitor& visitor, ProjectPtrVector& projects);
    191194 
    192195  // Use
     
    210213
    211214  bool m_visited;
     215  int m_visits;
    212216
    213217  cmt_string m_cmtpath;
Note: See TracChangeset for help on using the changeset viewer.