- Timestamp:
- Oct 30, 2008, 4:22:54 PM (16 years ago)
- Location:
- CMT/HEAD
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
CMT/HEAD/ChangeLog
r469 r470 1 2008-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 1 19 2008-10-29 <rybkin@lal.in2p3.fr> 370 2 20 -
CMT/HEAD/source/cmt_project.cxx
r460 r470 900 900 } 901 901 902 //---------------------------------------------------------- 903 Project::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 902 930 /*----------------------------------------------------------*/ 903 931 void Project::clear_all () … … 979 1007 if (CmtSystem::test_directory (w)) 980 1008 { 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; 981 1023 cout << "# Add path " << w << " from " << s << endl; 982 1024 } … … 1046 1088 void Project::broadcast (IProjectAction& action) 1047 1089 { 1048 static ProjectVector& Projects = projects (); 1090 // static ProjectVector& Projects = projects (); 1091 static ProjectVector& Projects = ordered_projects (); 1049 1092 1050 1093 for (int i = 0; i < Projects.size (); i++) … … 1059 1102 void Project::reverse_broadcast (IProjectAction& action) 1060 1103 { 1061 static ProjectVector& Projects = projects (); 1104 // static ProjectVector& Projects = projects (); 1105 static ProjectVector& Projects = ordered_projects (); 1062 1106 1063 1107 for (int i = (Projects.size () - 1); i >= 0; i--) … … 1186 1230 1187 1231 //---------------------------------------------------------- 1232 void 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 //---------------------------------------------------------- 1188 1259 void Project::start_visit (IProjectVisitor& visitor) 1189 1260 { … … 1194 1265 Project& p = Projects[i]; 1195 1266 p.m_visited = false; 1267 p.m_visits = 0; 1196 1268 } 1197 1269 … … 1205 1277 } 1206 1278 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); 1210 1287 } 1211 1288 … … 1243 1320 if (CmtSystem::test_directory (w)) 1244 1321 { 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"; 1245 1340 m_buffer += "path_append CMTPATH \""; 1246 1341 m_buffer += w; -
CMT/HEAD/source/cmt_project.h
r437 r470 87 87 virtual void pre (Project* p) = 0; 88 88 virtual void in (Project* p) = 0; 89 virtual void in_again (Project* p) = 0; 89 90 virtual void post (Project* p) = 0; 90 91 }; … … 108 109 109 110 static ProjectVector& projects (); 111 static ProjectVector& ordered_projects (); 110 112 static void clear_all (); 111 113 static void show_all (); … … 189 191 190 192 void visit (IProjectVisitor& visitor); 193 static void visit (IProjectVisitor& visitor, ProjectPtrVector& projects); 191 194 192 195 // Use … … 210 213 211 214 bool m_visited; 215 int m_visits; 212 216 213 217 cmt_string m_cmtpath;
Note: See TracChangeset
for help on using the changeset viewer.