#include <cmt_tag.h>
Collaboration diagram for Tag:

Public Types | |
| typedef cmt_vector<Tag> | TagVector |
| typedef cmt_vector<Tag*> | TagPtrVector |
Public Methods | |
| Tag () | |
| ~Tag () | |
| void | clear () |
| void | add_tag_ref (Tag* ref) |
| void | add_tag_exclude (Tag* ref) |
| void | unmark () |
| void | mark () |
| void | show_definition (bool quiet) const |
| void | show (bool quiet) const |
| bool | is_selected () const |
Public Attributes | |
| cmt_string | name |
| TagPtrVector | tag_refs |
| TagPtrVector | tag_excludes |
| int | priority |
| Use* | def_use |
| Use* | set_use |
| cmt_string | context |
| bool | selected |
Static Public Methods | |
| void | action (const CmtSystem::cmt_string_vector& words, Use* use) |
| void | action_exclude (const CmtSystem::cmt_string_vector& words, Use* use) |
| Tag* | find (const cmt_string& name) |
| Tag* | add (const cmt_string& name, int priority, const cmt_string& context, Use* use = 0) |
| int | tag_number () |
| Tag* | tag (int index) |
| void | unmark_all () |
| void | restore_tree () |
| Restore the tag tree after cleaning up one tag and its local tree. More... | |
| void | clear_all () |
| TagVector& | all_tags () |
| TagPtrVector& | tags () |
| Tag* | get_default () |
|
|
|
|
|
|
|
|
Definition at line 448 of file cmt_tag.cxx. 00449 {
00450 }
|
|
|
Definition at line 453 of file cmt_tag.cxx. 00454 {
00455 }
|
|
|
Definition at line 147 of file cmt_tag.cxx. Referenced by Cmt::select(). 00148 {
00149 cmt_string name;
00150 Tag* tag;
00151 Tag* ref;
00152
00153 name = words[1];
00154 if (name == "") return;
00155
00156 tag = add (name, PriorityUserTag, "use", use);
00157
00158 int priority = PriorityUserTag;
00159 if (tag->priority > priority)
00160 {
00161 priority = tag->priority;
00162 }
00163
00164 //if (tag->tag_refs.size () == 0)
00165 //{
00166
00167 tag->set_use = use;
00168
00169 //}
00170
00171 for (int i = 2; i < words.size (); i++)
00172 {
00173 name = words[i];
00174 if (name == "") break;
00175 ref = add (name, priority, "use", use);
00176 tag->add_tag_ref (ref);
00177 if (tag->selected) // it was previously selected
00178 {
00179 ref->mark ();
00180 }
00181 }
00182 }
|
|
|
Definition at line 185 of file cmt_tag.cxx. Referenced by Cmt::select(). 00186 {
00187 cmt_string name;
00188 Tag* tag;
00189 Tag* ref;
00190
00191 name = words[1];
00192 if (name == "") return;
00193
00194 tag = add (name, PriorityUserTag, "use", use);
00195
00196 if (tag->tag_excludes.size () == 0)
00197 {
00198 tag->set_use = use;
00199
00200 int i;
00201
00202 for (i = 2; i < words.size (); i++)
00203 {
00204 cmt_string n;
00205 n = words[i];
00206 if (n == "") break;
00207 ref = add (n, PriorityUserTag, "use", use);
00208
00209 /*
00210 if (!Cmt::quiet)
00211 {
00212 cerr << "Excluding tag " << n << "(" << ref->priority << ") from tag "
00213 << name << "(" << tag->priority << ")" << endl;
00214 }
00215 */
00216
00217 tag->add_tag_exclude (ref);
00218 ref->add_tag_exclude (tag);
00219 }
00220
00221 //
00222 // We have to check that some of the excluded tags may be already selected.
00223 // Then we have to figure out which one has to win:
00224 //
00225 // the one with the highest priority
00226 // or the first that had been declared.
00227 //
00228
00229 int count = 0;
00230 int winner_count = 0;
00231
00232 Tag* winner = 0;
00233
00234 if (tag->selected)
00235 {
00236 count++;
00237 winner = tag;
00238 winner_count = 1;
00239 }
00240
00241 for (i = 0; i < tag->tag_excludes.size (); i++)
00242 {
00243 Tag* ref = tag->tag_excludes[i];
00244
00245 if (ref == 0) continue;
00246
00247 if (ref->selected)
00248 {
00249 count++;
00250
00251 if ((winner == 0) ||
00252 (ref->priority > winner->priority))
00253 {
00254 winner = ref;
00255 winner_count = 1;
00256 }
00257 else if (ref->priority == winner->priority)
00258 {
00259 winner_count++;
00260 }
00261 }
00262 }
00263
00264 if (count > 1)
00265 {
00266 if (winner_count > 1)
00267 {
00268 //
00269 // Several contradictory tags are selected and have the same priority!!
00270 //
00271 }
00272
00273 //
00274 // We have at least one selected, and one winner.
00275 // All others will be unselected.
00276 //
00277
00278 if (tag != winner)
00279 {
00280 tag->unmark ();
00281 }
00282
00283 for (i = 0; i < tag->tag_excludes.size (); i++)
00284 {
00285 Tag* ref = tag->tag_excludes[i];
00286
00287 if (ref == 0) continue;
00288 if (ref == winner) continue;
00289
00290 ref->unmark ();
00291 }
00292 }
00293 }
00294 }
|
|
|
Definition at line 320 of file cmt_tag.cxx. Referenced by action(), Symbol::action(), action_exclude(), Cmt::configure_config_tag(), Cmt::configure_hosttype_tag(), Cmt::configure_site_tag(), Cmt::configure_tags(), Cmt::configure_uname_tag(), get_default(), Cmt::load(), Cmt::parse_arguments(), Cmt::reach_current_package(), and Cmt::restore_all_tags(). 00324 {
00325 static TagPtrVector& Tags = tags ();
00326 static TagVector& AllTags = all_tags ();
00327
00328 Tag* tag;
00329
00330 if (name == "") return (0);
00331
00332 tag = find (name);
00333 if (tag != 0)
00334 {
00335 if (priority > tag->priority)
00336 {
00337 tag->priority = priority;
00338
00339 /*
00340 if (!Cmt::quiet)
00341 {
00342 cerr << "increasing priority of " << name << " p=" << priority << endl;
00343 }
00344 */
00345 }
00346 else
00347 {
00348 /*
00349 if (!Cmt::quiet)
00350 {
00351 cerr << "keeping priority of " << name << " p=" << tag->priority << endl;
00352 }
00353 */
00354 }
00355
00356 return (tag);
00357 }
00358
00359 /*
00360 if (!Cmt::quiet)
00361 {
00362 cerr << "adding tag " << name << " p=" << priority << endl;
00363 }
00364 */
00365
00366 Tag& tag_object = AllTags.add ();
00367 tag = &tag_object;
00368 Tags.push_back (tag);
00369
00370 tag->clear ();
00371 tag->name = name;
00372
00373 tag->selected = false;
00374 tag->priority = priority;
00375 tag->def_use = use;
00376 tag->context = context;
00377
00378 return (tag);
00379 }
|
|
|
Definition at line 490 of file cmt_tag.cxx. Referenced by action_exclude(). 00491 {
00492 if (ref == 0) return;
00493
00494 /*
00495 if (selected && ref->selected)
00496 {
00497 static TagPtrVector& Tags = tags ();
00498
00499 int tag_index;
00500
00501 for (tag_index = 0; tag_index < Tags.size (); tag_index++)
00502 {
00503 Tag* t = Tags[tag_index];
00504
00505 if (t == this)
00506 {
00507 ref->unmark ();
00508 break;
00509 }
00510
00511 if (t == ref)
00512 {
00513 unmark ();
00514 break;
00515 }
00516 }
00517 }
00518 */
00519
00520 if (tag_excludes.size () > 0)
00521 {
00522 int number;
00523
00524 for (number = 0; number < tag_excludes.size (); number++)
00525 {
00526 Tag* t = tag_excludes[number];
00527 if (t == ref) return;
00528 }
00529 }
00530
00531 tag_excludes.push_back (ref);
00532 }
|
|
|
Definition at line 471 of file cmt_tag.cxx. Referenced by action(). |
|
|
Definition at line 416 of file cmt_tag.cxx. Referenced by add(), and clear_all(). 00417 {
00418 static Database& db = Database::instance ();
00419 static TagVector& AllTags = db.all_tags ();
00420
00421 return (AllTags);
00422 }
|
|
|
Definition at line 458 of file cmt_tag.cxx. |
|
|
Definition at line 398 of file cmt_tag.cxx. Referenced by Database::clear(), and Cmt::parse_arguments(). 00399 {
00400 static TagPtrVector& Tags = tags ();
00401 static TagVector& AllTags = all_tags ();
00402
00403 int tag_index;
00404
00405 for (tag_index = 0; tag_index < AllTags.size (); tag_index++)
00406 {
00407 Tag& tag = AllTags[tag_index];
00408 tag.clear ();
00409 }
00410
00411 Tags.clear ();
00412 AllTags.clear ();
00413 }
|
|
|
Definition at line 297 of file cmt_tag.cxx. Referenced by Symbol::action(), add(), Cmt::print(), and SymbolValueList::select_first(). 00298 {
00299 static TagPtrVector& Tags = tags ();
00300
00301 int tag_index;
00302 Tag* tag;
00303
00304 if (Tags.size () == 0) return (0);
00305
00306 for (tag_index = 0; tag_index < Tags.size (); tag_index++)
00307 {
00308 tag = Tags[tag_index];
00309
00310 if ((tag != 0) && (tag->name == name))
00311 {
00312 return (tag);
00313 }
00314 }
00315
00316 return (0);
00317 }
|
|
|
Definition at line 434 of file cmt_tag.cxx. Referenced by Symbol::add_value_to_list(), MacroBuilder::build(), PathBuilder::build(), SetBuilder::build(), and Symbol::is_selected(). |
|
|
Definition at line 620 of file cmt_tag.cxx. Referenced by Cmt::print(). 00621 {
00622 return (selected);
00623 }
|
|
|
Definition at line 83 of file cmt_tag.cxx. Referenced by action(), Cmt::configure_config_tag(), Cmt::configure_hosttype_tag(), Cmt::configure_site_tag(), Cmt::configure_tags(), Cmt::configure_uname_tag(), Cmt::load(), Cmt::parse_arguments(), Cmt::reach_current_package(), Cmt::restore_all_tags(), and restore_tree(). 00084 {
00085 if (selected) return;
00086
00087 if (tag_excludes.size () > 0)
00088 {
00089 int number;
00090
00091 for (number = 0; number < tag_excludes.size (); number++)
00092 {
00093 Tag* ref = tag_excludes[number];
00094 if (ref->selected)
00095 {
00096 if (priority > ref->priority)
00097 {
00098 //
00099 // Although this other contradictory tag is already selected,
00100 // its priority is lower. Therefore it will lose !! It has to be
00101 // unselected ...
00102 //
00103
00104 ref->unmark ();
00105 }
00106 else
00107 {
00108 /*
00109 if (!Cmt::quiet)
00110 {
00111 cerr << "Cannot mark excluded tag " << name << " p=" << priority
00112 << " because " << ref->name << "(" << ref->priority << ")" << endl;
00113 show (0);
00114 }
00115 */
00116
00117 return;
00118 }
00119 }
00120 }
00121 }
00122
00123 selected = true;
00124
00125 /*
00126 if (!Cmt::quiet)
00127 {
00128 cerr << "Marking tag " << name << " p=" << priority << endl;
00129 show (0);
00130 }
00131 */
00132
00133 if (tag_refs.size () > 0)
00134 {
00135 int number;
00136
00137 for (number = 0; number < tag_refs.size (); number++)
00138 {
00139 Tag* ref = tag_refs[number];
00140
00141 ref->mark ();
00142 }
00143 }
00144 }
|
|
|
Restore the tag tree after cleaning up one tag and its local tree.
Definition at line 55 of file cmt_tag.cxx. Referenced by Cmt::load(), and Cmt::reach_current_package(). 00056 {
00057 static TagPtrVector& Tags = tags ();
00058
00059 int tag_number;
00060
00061 for (tag_number = 0; tag_number < Tags.size (); tag_number++)
00062 {
00063 Tag* tag = Tags[tag_number];
00064
00065 if (tag->selected)
00066 {
00067 if (tag->tag_refs.size () > 0)
00068 {
00069 int number;
00070
00071 for (number = 0; number < tag->tag_refs.size (); number++)
00072 {
00073 Tag* ref = tag->tag_refs[number];
00074
00075 ref->mark ();
00076 }
00077 }
00078 }
00079 }
00080 }
|
|
|
Definition at line 614 of file cmt_tag.cxx. Referenced by Cmt::do_show_tags(). 00615 {
00616 if (selected) show_definition (quiet);
00617 }
|
|
|
Definition at line 535 of file cmt_tag.cxx. Referenced by Cmt::do_show_all_tags(), and show(). 00536 {
00537 static const cmt_string priority_text[] = {
00538 "Lowest",
00539 "Default",
00540 "Uname",
00541 "Config",
00542 "UserTag",
00543 "PrimaryUserTag",
00544 "Tag"
00545 };
00546
00547 cout << name;
00548
00549 if (!quiet)
00550 {
00551 //cout << "context=" << context << " use=" << def_use << endl;
00552
00553 if ((context == "use") || (def_use != 0))
00554 {
00555 if (def_use != 0)
00556 {
00557 cout << " (from ";
00558 if (context != "use") cout << context;
00559 cout << "package " << def_use->package << ")";
00560 }
00561 }
00562 else
00563 {
00564 cout << " (from " << context << ")";
00565 }
00566 //cout << " (" << priority_text[priority] << ")";
00567
00568 if (tag_refs.size () > 0)
00569 {
00570 int number;
00571
00572 if (set_use != 0)
00573 {
00574 cout << " package " << set_use->package;
00575 }
00576
00577 cout << " implies [";
00578
00579 for (number = 0; number < tag_refs.size (); number++)
00580 {
00581 Tag* ref = tag_refs[number];
00582 if (number > 0) cout << " ";
00583 cout << ref->name;
00584 }
00585
00586 cout << "]";
00587 }
00588
00589 if (tag_excludes.size () > 0)
00590 {
00591 int number;
00592
00593 if (set_use != 0)
00594 {
00595 cout << " package " << set_use->package;
00596 }
00597
00598 cout << " excludes [";
00599
00600 for (number = 0; number < tag_excludes.size (); number++)
00601 {
00602 Tag* ref = tag_excludes[number];
00603 if (number > 0) cout << " ";
00604 cout << ref->name;
00605 }
00606
00607 cout << "]";
00608 }
00609 }
00610 cout << endl;
00611 }
|
|
|
Definition at line 390 of file cmt_tag.cxx. 00391 {
00392 static TagPtrVector& Tags = tags ();
00393
00394 return (Tags[index]);
00395 }
|
|
|
Definition at line 382 of file cmt_tag.cxx. 00383 {
00384 static TagPtrVector& Tags = tags ();
00385
00386 return (Tags.size ());
00387 }
|
|
|
Definition at line 425 of file cmt_tag.cxx. Referenced by add(), clear_all(), Cmt::do_show_all_tags(), Cmt::do_show_tags(), find(), Cmt::parse_arguments(), restore_tree(), tag(), tag_number(), and unmark_all(). 00426 {
00427 static Database& db = Database::instance ();
00428 static TagPtrVector& Tags = db.tags ();
00429
00430 return (Tags);
00431 }
|
|
|
Definition at line 16 of file cmt_tag.cxx. Referenced by action_exclude(), mark(), and unmark_all(). 00017 {
00018 if (!selected) return;
00019
00020 if ((priority == PriorityDefault) ||
00021 (priority == PrioritySite) ||
00022 (priority == PriorityUname)) return;
00023
00024 /*
00025 if (!Cmt::quiet)
00026 {
00027 cerr << "Unmarking tag " << name << " p=" << priority << endl;
00028 show (0);
00029 }
00030 */
00031
00032 selected = false;
00033 def_use = 0;
00034 }
|
|
|
Definition at line 37 of file cmt_tag.cxx. Referenced by Cmt::load(), and Cmt::parse_arguments(). 00038 {
00039 static TagPtrVector& Tags = tags ();
00040
00041 int tag_number;
00042
00043 for (tag_number = 0; tag_number < Tags.size (); tag_number++)
00044 {
00045 Tag* tag = Tags[tag_number];
00046
00047 if (tag->selected) tag->unmark ();
00048 }
00049 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1.2.3 written by Dimitri van Heesch,
© 1997-2000