Changeset 817 for code/branches/core
- Timestamp:
- Feb 16, 2008, 7:31:18 PM (17 years ago)
- Location:
- code/branches/core/src/orxonox
- Files:
-
- 1 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core/src/orxonox/Orxonox.cc
r811 r817 78 78 #include "core/ClassTreeMask.h" 79 79 #include "objects/WorldEntity.h" 80 #include "core/DebugLevel.h" 80 81 #include "core/BaseObject.h" 81 82 #include "objects/Test.h" … … 231 232 break; 232 233 } 233 234 234 #define testandcout(code) \ 235 235 std::cout << #code << " " << code << "\n" 236 237 236 /* 238 237 std::cout << "Test 1\n"; … … 259 258 test4 = new A3(); 260 259 test4 = new A3(); 261 */ 262 /* 260 261 263 262 std::cout << "Test 5\n"; 264 263 A1* test5_01 = new A1(); … … 280 279 A3B2C1* test5_17 = new A3B2C1(); 281 280 A3B2C2* test5_18 = new A3B2C2(); 282 283 OrxonoxClass* test5; 281 */ 282 /* 283 OrxonoxClass* test5 = 0; 284 284 for (int i = 0; i <= 18; i++) 285 285 { … … 305 305 306 306 std::cout << "\n"; 307 std::cout << test5->getIdentifier()->getName() << " (" << test5->getIdentifier()->getNetworkID() << "): parents: " << test5->getIdentifier()->getParents().toString() << "\n"; 308 std::cout << test5->getIdentifier()->getName() << " (" << test5->getIdentifier()->getNetworkID() << "): children: " << test5->getIdentifier()->getChildren().toString() << "\n"; 307 std::cout << test5->getIdentifier()->getName() << " (" << test5->getIdentifier()->getNetworkID() << "): parents: " << test5->getIdentifier()->getParents() << "\n"; 308 std::cout << test5->getIdentifier()->getName() << " (" << test5->getIdentifier()->getNetworkID() << "): children: " << test5->getIdentifier()->getChildren() << "\n"; 309 std::cout << test5->getIdentifier()->getName() << " (" << test5->getIdentifier()->getNetworkID() << "): direct parents: " << test5->getIdentifier()->getDirectParents() << "\n"; 310 std::cout << test5->getIdentifier()->getName() << " (" << test5->getIdentifier()->getNetworkID() << "): direct children: " << test5->getIdentifier()->getDirectChildren() << "\n"; 309 311 } 310 311 std::cout << "Class with ID 0: " << ID(0) << " " << ID(0)->getName() << "\n"; 312 std::cout << "Class with ID 1: " << ID(1) << " " << ID(1)->getName() << "\n"; 313 std::cout << "Class with ID 2: " << ID(2) << " " << ID(2)->getName() << "\n"; 314 std::cout << "Class with ID 3: " << ID(3) << " " << ID(3)->getName() << "\n"; 315 std::cout << "Class with ID 4: " << ID(4) << " " << ID(4)->getName() << "\n"; 312 */ 313 /* 314 for (std::map<std::string, Identifier*>::const_iterator it = Factory::getFactoryBegin(); it != Factory::getFactoryEnd(); ++it) 315 std::cout << "Class with ID " << (*it).second->getNetworkID() << ": " << ID((*it).second->getNetworkID()) << " / " << ID((*it).second->getNetworkID())->getName() << std::endl; 316 316 317 std::cout << "Class with ID 100: " << ID(100) << "\n"; 317 318 std::cout << "ID of BaseObject: " << Class(BaseObject)->getNetworkID() << "\n"; … … 360 361 std::cout << "isDirectA(XYZ)-Test:\n"; 361 362 std::cout << "test5_01 = A1, Erwartet: 1 0 0 0 0\n"; 362 testandcout(test5_01->is DirectlyA(Class(A1)));363 testandcout(test5_01->is DirectlyA(Class(A2)));364 testandcout(test5_01->is DirectlyA(Class(A1B1)));365 testandcout(test5_01->is DirectlyA(Class(BaseObject)));366 testandcout(test5_01->is DirectlyA(Class(Interface1)));363 testandcout(test5_01->isExactlyA(Class(A1))); 364 testandcout(test5_01->isExactlyA(Class(A2))); 365 testandcout(test5_01->isExactlyA(Class(A1B1))); 366 testandcout(test5_01->isExactlyA(Class(BaseObject))); 367 testandcout(test5_01->isExactlyA(Class(Interface1))); 367 368 368 369 std::cout << "\n"; 369 370 std::cout << "test5_02 = A2, Erwartet: 0 1 0 0 0\n"; 370 testandcout(test5_02->is DirectlyA(Class(A1)));371 testandcout(test5_02->is DirectlyA(Class(A2)));372 testandcout(test5_02->is DirectlyA(Class(A1B1)));373 testandcout(test5_02->is DirectlyA(Class(BaseObject)));374 testandcout(test5_02->is DirectlyA(Class(Interface1)));371 testandcout(test5_02->isExactlyA(Class(A1))); 372 testandcout(test5_02->isExactlyA(Class(A2))); 373 testandcout(test5_02->isExactlyA(Class(A1B1))); 374 testandcout(test5_02->isExactlyA(Class(BaseObject))); 375 testandcout(test5_02->isExactlyA(Class(Interface1))); 375 376 376 377 std::cout << "\n"; 377 378 std::cout << "test5_03 = A3, Erwartet: 0 0 0 0 0\n"; 378 testandcout(test5_03->is DirectlyA(Class(A1)));379 testandcout(test5_03->is DirectlyA(Class(A2)));380 testandcout(test5_03->is DirectlyA(Class(A1B1)));381 testandcout(test5_03->is DirectlyA(Class(BaseObject)));382 testandcout(test5_03->is DirectlyA(Class(Interface1)));379 testandcout(test5_03->isExactlyA(Class(A1))); 380 testandcout(test5_03->isExactlyA(Class(A2))); 381 testandcout(test5_03->isExactlyA(Class(A1B1))); 382 testandcout(test5_03->isExactlyA(Class(BaseObject))); 383 testandcout(test5_03->isExactlyA(Class(Interface1))); 383 384 384 385 std::cout << "\n"; … … 431 432 432 433 std::cout << "\n"; 434 std::cout << "isDirectChildOf(XYZ)-Test:\n"; 435 std::cout << "test5_04 = A1B1, Erwartet: 1 0 0 0 0 0 0\n"; 436 testandcout(test5_04->isDirectChildOf(Class(A1))); 437 testandcout(test5_04->isDirectChildOf(Class(A2))); 438 testandcout(test5_04->isDirectChildOf(Class(BaseObject))); 439 testandcout(test5_04->isDirectChildOf(Class(Interface1))); 440 testandcout(test5_04->isDirectChildOf(Class(Interface2))); 441 testandcout(test5_04->isDirectChildOf(Class(A1B1C2))); 442 testandcout(test5_04->isDirectChildOf(Class(A1B1))); 443 444 std::cout << "\n"; 445 std::cout << "test5_06 = A2B1, Erwartet: 0 1 0 0 0 0 0\n"; 446 testandcout(test5_06->isDirectChildOf(Class(A1))); 447 testandcout(test5_06->isDirectChildOf(Class(A2))); 448 testandcout(test5_06->isDirectChildOf(Class(BaseObject))); 449 testandcout(test5_06->isDirectChildOf(Class(Interface1))); 450 testandcout(test5_06->isDirectChildOf(Class(Interface2))); 451 testandcout(test5_06->isDirectChildOf(Class(A1B1C2))); 452 testandcout(test5_06->isDirectChildOf(Class(A1B1))); 453 454 std::cout << "\n"; 455 std::cout << "test5_07 = A2B2, Erwartet: 0 1 0 1 0 0\n"; 456 testandcout(test5_07->isDirectChildOf(Class(A1))); 457 testandcout(test5_07->isDirectChildOf(Class(A2))); 458 testandcout(test5_07->isDirectChildOf(Class(BaseObject))); 459 testandcout(test5_07->isDirectChildOf(Class(Interface1))); 460 testandcout(test5_07->isDirectChildOf(Class(Interface2))); 461 testandcout(test5_07->isDirectChildOf(Class(A1B1C2))); 462 463 std::cout << "\n"; 464 std::cout << "test5_08 = A3B1, Erwartet: 0 0 0 0 0 0\n"; 465 testandcout(test5_08->isDirectChildOf(Class(A1))); 466 testandcout(test5_08->isDirectChildOf(Class(A2))); 467 testandcout(test5_08->isDirectChildOf(Class(BaseObject))); 468 testandcout(test5_08->isDirectChildOf(Class(Interface1))); 469 testandcout(test5_08->isDirectChildOf(Class(Interface2))); 470 testandcout(test5_08->isDirectChildOf(Class(A1B1C2))); 471 472 std::cout << "\n"; 473 std::cout << "test5_09 = A3B2, Erwartet: 0 0 0 0 1 0\n"; 474 testandcout(test5_09->isDirectChildOf(Class(A1))); 475 testandcout(test5_09->isDirectChildOf(Class(A2))); 476 testandcout(test5_09->isDirectChildOf(Class(BaseObject))); 477 testandcout(test5_09->isDirectChildOf(Class(Interface1))); 478 testandcout(test5_09->isDirectChildOf(Class(Interface2))); 479 testandcout(test5_09->isDirectChildOf(Class(A1B1C2))); 480 481 std::cout << "\n"; 482 433 483 std::cout << "isParentOf(XYZ)-Test:\n"; 434 484 std::cout << "test1 = BaseObject, Erwartet: 0 0 1 1 1 1 1\n"; … … 460 510 testandcout(Class(Interface1)->isParentOf(Class(A2B2))); 461 511 testandcout(Class(Interface1)->isParentOf(Class(A3B1C2))); 512 513 std::cout << "\n"; 514 std::cout << "isDirectParentOf(XYZ)-Test:\n"; 515 std::cout << "test1 = BaseObject, Erwartet: 0 0 1 1 0 0 0\n"; 516 testandcout(test1->isDirectParentOf(Class(BaseObject))); 517 testandcout(test1->isDirectParentOf(Class(Interface1))); 518 testandcout(test1->isDirectParentOf(Class(A1))); 519 testandcout(test1->isDirectParentOf(Class(A2))); 520 testandcout(test1->isDirectParentOf(Class(A1B1))); 521 testandcout(test1->isDirectParentOf(Class(A2B2))); 522 testandcout(test1->isDirectParentOf(Class(A3B1C2))); 523 524 std::cout << "\n"; 525 std::cout << "test5_01 = A1, Erwartet: 0 0 0 0 1 0 0\n"; 526 testandcout(test5_01->isDirectParentOf(Class(BaseObject))); 527 testandcout(test5_01->isDirectParentOf(Class(Interface1))); 528 testandcout(test5_01->isDirectParentOf(Class(A1))); 529 testandcout(test5_01->isDirectParentOf(Class(A2))); 530 testandcout(test5_01->isDirectParentOf(Class(A1B1))); 531 testandcout(test5_01->isDirectParentOf(Class(A2B2))); 532 testandcout(test5_01->isDirectParentOf(Class(A3B1C2))); 533 534 std::cout << "\n"; 535 std::cout << "Interface1, Erwartet: 0 0 0 0 0 1 0\n"; 536 testandcout(Class(Interface1)->isDirectParentOf(Class(BaseObject))); 537 testandcout(Class(Interface1)->isDirectParentOf(Class(Interface1))); 538 testandcout(Class(Interface1)->isDirectParentOf(Class(A1))); 539 testandcout(Class(Interface1)->isDirectParentOf(Class(A2))); 540 testandcout(Class(Interface1)->isDirectParentOf(Class(A1B1))); 541 testandcout(Class(Interface1)->isDirectParentOf(Class(A2B2))); 542 testandcout(Class(Interface1)->isDirectParentOf(Class(A3B1C2))); 462 543 */ 463 544 /* 464 545 std::cout << "Test 6\n"; 465 std::cout << "1 :\n";546 std::cout << "1\n"; 466 547 Identifier* test6_01 = Class(A1B1); 467 std::cout << "2 :\n";548 std::cout << "2\n"; 468 549 Identifier* test6_02 = Class(A1B1); 469 std::cout << "3 :\n";550 std::cout << "3\n"; 470 551 Identifier* test6_03 = Class(A1); 471 std::cout << "4 :\n";552 std::cout << "4\n"; 472 553 Identifier* test6_04 = Class(A1B1C1); 473 std::cout << "5 :\n";554 std::cout << "5\n"; 474 555 Identifier* test6_05 = Class(A1B1); 475 std::cout << "6 :\n";556 std::cout << "6\n"; 476 557 Identifier* test6_06 = Class(A1B1C1); 477 558 478 std::cout << "\n"; 479 std::cout << "BaseObject: parents: " << Class(BaseObject)->getParents().toString() << "\n"; 480 std::cout << "BaseObject: children: " << Class(BaseObject)->getChildren().toString() << "\n"; 481 482 std::cout << "\n"; 483 std::cout << "A1: parents: " << Class(A1)->getParents().toString() << "\n"; 484 std::cout << "A1: children: " << Class(A1)->getChildren().toString() << "\n"; 485 486 std::cout << "\n"; 487 std::cout << "A1B1: parents: " << Class(A1B1)->getParents().toString() << "\n"; 488 std::cout << "A1B1: children: " << Class(A1B1)->getChildren().toString() << "\n"; 489 490 std::cout << "\n"; 491 std::cout << "A1B1C1: parents: " << Class(A1B1C1)->getParents().toString() << "\n"; 492 std::cout << "A1B1C1: children: " << Class(A1B1C1)->getChildren().toString() << "\n"; 493 494 std::cout << "\n"; 495 std::cout << "A3B1C1 child of A3: " << Class(A3B1C1)->isChildOf(Class(A3)) << "\n"; 496 std::cout << "\n"; 497 std::cout << "A2 parent of A2B1C1: " << Class(A2)->isParentOf(Class(A2B1C1)) << "\n"; 559 std::cout << "7\n"; 560 561 std::cout << "\n"; 562 std::cout << "BaseObject: parents: " << Class(BaseObject)->getParents() << "\n"; 563 std::cout << "BaseObject: children: " << Class(BaseObject)->getChildren() << "\n"; 564 std::cout << "BaseObject: direct parents: " << Class(BaseObject)->getDirectParents() << "\n"; 565 std::cout << "BaseObject: direct children: " << Class(BaseObject)->getDirectChildren() << "\n"; 566 567 std::cout << "\n"; 568 std::cout << "A1: parents: " << Class(A1)->getParents() << "\n"; 569 std::cout << "A1: children: " << Class(A1)->getChildren() << "\n"; 570 std::cout << "A1: direct parents: " << Class(A1)->getDirectParents() << "\n"; 571 std::cout << "A1: direct children: " << Class(A1)->getDirectChildren() << "\n"; 572 573 std::cout << "\n"; 574 std::cout << "A1B1: parents: " << Class(A1B1)->getParents() << "\n"; 575 std::cout << "A1B1: children: " << Class(A1B1)->getChildren() << "\n"; 576 std::cout << "A1B1: direct parents: " << Class(A1B1)->getDirectParents() << "\n"; 577 std::cout << "A1B1: direct children: " << Class(A1B1)->getDirectChildren() << "\n"; 578 579 std::cout << "\n"; 580 std::cout << "A1B1C1: parents: " << Class(A1B1C1)->getParents() << "\n"; 581 std::cout << "A1B1C1: children: " << Class(A1B1C1)->getChildren() << "\n"; 582 std::cout << "A1B1C1: direct parents: " << Class(A1B1C1)->getDirectParents() << "\n"; 583 std::cout << "A1B1C1: direct children: " << Class(A1B1C1)->getDirectChildren() << "\n"; 584 585 std::cout << "\n"; 586 std::cout << "A3B1C1 child of A3: " << Class(A3B1C1)->isChildOf(Class(A3)) << "\n"; 587 std::cout << "\n"; 588 std::cout << "A2 parent of A2B1C1: " << Class(A2)->isParentOf(Class(A2B1C1)) << "\n"; 589 590 std::cout << "8\n"; 498 591 */ 499 592 /* … … 510 603 */ 511 604 /* 605 // ## WARNING - CRASH! ## 512 606 std::cout << "2\n"; 513 607 … … 520 614 SubclassIdentifier<A1B1> test7_05; 521 615 test7_05 = Class(A2); 616 // ## END WARNING - CRASH! ## 522 617 */ 523 618 /* … … 558 653 delete test8_02; 559 654 delete test8_03; 560 561 655 */ 656 /* 562 657 std::cout << "Test 9\n"; 563 658 std::cout << "1\n"; … … 603 698 int count; 604 699 605 count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it != 0; ++it) { count++; }700 count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it; ++it) { count++; } 606 701 std::cout << "Anzahl BaseObjects: " << count << "\n"; 607 count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it != 0; ++it) { count++; }702 count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it; ++it) { count++; } 608 703 std::cout << "Anzahl A1: " << count << "\n"; 609 704 count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::start(); it; ++it) { count++; } … … 616 711 std::cout << "2\n"; 617 712 BaseObject* test10_08; 618 BaseObject* test10_09 ;619 BaseObject* test10_10 ;713 BaseObject* test10_09 = 0; 714 BaseObject* test10_10 = 0; 620 715 for (int i = 0; i < 10; i++) 621 716 { … … 632 727 } 633 728 634 count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it != 0; ++it) { count++; }729 count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it; ++it) { count++; } 635 730 std::cout << "Anzahl BaseObjects: " << count << "\n"; 636 count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it != 0; ++it) { count++; }731 count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it; ++it) { count++; } 637 732 std::cout << "Anzahl A1: " << count << "\n"; 638 733 count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::start(); it; ++it) { count++; } … … 653 748 delete test10_08; 654 749 655 count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it != 0; ++it) { count++; }750 count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it; ++it) { count++; } 656 751 std::cout << "Anzahl BaseObjects: " << count << "\n"; 657 count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it != 0; ++it) { count++; }752 count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it; ++it) { count++; } 658 753 std::cout << "Anzahl A1: " << count << "\n"; 659 754 count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::start(); it; ++it) { count++; } … … 675 770 delete test10_09; 676 771 677 count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::end(); it != 0; --it) { count++; }772 count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::end(); it; --it) { count++; } 678 773 std::cout << "Anzahl BaseObjects: " << count << "\n"; 679 count = 0; for (Iterator<A1> it = ObjectList<A1>::end(); it != 0; --it) { count++; }774 count = 0; for (Iterator<A1> it = ObjectList<A1>::end(); it; --it) { count++; } 680 775 std::cout << "Anzahl A1: " << count << "\n"; 681 776 count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::end(); it; --it) { count++; } … … 697 792 delete test10_10; 698 793 699 count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it != 0; ++it) { count++; }794 count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it; ++it) { count++; } 700 795 std::cout << "Anzahl BaseObjects: " << count << "\n"; 701 count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it != 0; ++it) { count++; }796 count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it; ++it) { count++; } 702 797 std::cout << "Anzahl A1: " << count << "\n"; 703 798 count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::start(); it; ++it) { count++; } … … 721 816 std::cout << "Test 11\n"; 722 817 std::cout << "1\n"; 723 count = 0; for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it) { count++; }724 std::cout << "AnzahlTickable: " << count << "\n";818 int count2 = 0; for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it) { count2++; } 819 std::cout << "AnzahlTickable: " << count2 << "\n"; 725 820 726 821 Test1* test11_1; … … 728 823 test11_1 = new Test1; 729 824 730 count = 0; for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it) { count++; }731 std::cout << "AnzahlTickable: " << count << "\n";825 count2 = 0; for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it) { count2++; } 826 std::cout << "AnzahlTickable: " << count2 << "\n"; 732 827 733 828 for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it) … … 736 831 std::cout << "2\n"; 737 832 Test2* test11_2 = new Test2; 738 */ 739 /* 833 834 740 835 std::cout << "3\n"; 741 836 Test3* test11_3 = new Test3; … … 834 929 std::cout << "Mask 2:\n"; 835 930 TestClassTreeMask(test13_2); 836 /* 931 932 std::cout << "2\n"; 933 837 934 ClassTreeMask test13_3; 838 test13_3.include(Class(A1) );839 test13_3.exclude(Class(A1B2) );840 test13_3.exclude(Class(A1B1C2) );841 test13_3.include(Class(A2) );842 test13_3.exclude(Class(A2B2) );843 test13_3.include(Class(A3B1) );844 test13_3.include(Class(A3B2) );845 test13_3.exclude(Class(A3B2C2) );935 test13_3.include(Class(A1), true, false); 936 test13_3.exclude(Class(A1B2), true, false); 937 test13_3.exclude(Class(A1B1C2), true, false); 938 test13_3.include(Class(A2), true, false); 939 test13_3.exclude(Class(A2B2), true, false); 940 test13_3.include(Class(A3B1), true, false); 941 test13_3.include(Class(A3B2), true, false); 942 test13_3.exclude(Class(A3B2C2), true, false); 846 943 std::cout << std::endl; 847 944 std::cout << "Mask 2 without excluded BaseObject:\n"; 848 945 TestClassTreeMask(test13_3); 849 test13_3.exclude(Class(BaseObject) );850 std::cout << std::endl; 851 std::cout << "Mask 2 with BaseObject excluded afterwards :\n";946 test13_3.exclude(Class(BaseObject), false, false); 947 std::cout << std::endl; 948 std::cout << "Mask 2 with BaseObject excluded afterwards without overwrite:\n"; 852 949 TestClassTreeMask(test13_3); 853 854 ClassTreeMask test13_3_2; 855 test13_3_2.include(Class(A1)); 856 test13_3_2.exclude(Class(A1B2)); 857 test13_3_2.exclude(Class(A1B1C2)); 858 test13_3_2.include(Class(A2)); 859 test13_3_2.exclude(Class(A2B2)); 860 test13_3_2.include(Class(A3B1)); 861 test13_3_2.include(Class(A3B2)); 862 test13_3_2.exclude(Class(A3B2C2)); 863 test13_3_2.clean(); 864 test13_3_2.exclude(Class(BaseObject)); 865 std::cout << std::endl; 866 std::cout << "Mask 2 with BaseObject excluded afterwards, but cleaned before:\n"; 867 TestClassTreeMask(test13_3_2); 868 test13_3_2.include(Class(BaseObject)); 869 std::cout << std::endl; 870 std::cout << "Mask 2 from before, but BaseObject re-included without cleaning:\n"; 871 TestClassTreeMask(test13_3_2); 950 test13_3.exclude(Class(BaseObject), true); 951 std::cout << std::endl; 952 std::cout << "Mask 2 with BaseObject excluded afterwards with overwrite:\n"; 953 TestClassTreeMask(test13_3); 872 954 873 955 ClassTreeMask test13_4; … … 882 964 test13_4.include(Class(A1)); 883 965 std::cout << std::endl; 884 std::cout << "Mask 2 created in random order :\n";966 std::cout << "Mask 2 created in random order with overwrite and clean:\n"; 885 967 TestClassTreeMask(test13_4); 886 968 887 std::cout << "2\n"; 888 889 ClassTreeMask test13_5 = test13_1; 890 std::cout << std::endl; 891 std::cout << "Mask 1 assigned to a new ClassTestMask:\n"; 892 TestClassTreeMask(test13_5); 969 ClassTreeMask test13_4_2; 970 test13_4_2.include(Class(A3B2), false, false); 971 test13_4_2.exclude(Class(A1B1C2), false, false); 972 test13_4_2.include(Class(A3B1), false, false); 973 test13_4_2.exclude(Class(A3B2C2), false, false); 974 test13_4_2.exclude(Class(BaseObject), false, false); 975 test13_4_2.include(Class(A2), false, false); 976 test13_4_2.exclude(Class(A1B2), false, false); 977 test13_4_2.exclude(Class(A2B2), false, false); 978 test13_4_2.include(Class(A1), false, false); 979 std::cout << std::endl; 980 std::cout << "Mask 2 created in random order without overwrite and without clean:\n"; 981 TestClassTreeMask(test13_4_2); 893 982 894 983 std::cout << "3\n"; … … 929 1018 std::cout << "8\n"; 930 1019 931 std::cout << std::endl; 932 ClassTreeMask test13_11(test13_1); 933 std::cout << std::endl; 934 std::cout << "Mask 1 assigned with copyconstructor + original mask 1:\n"; 935 TestClassTreeMask(test13_11); 936 TestClassTreeMask(test13_1); 937 938 ClassTreeMask test13_12(!test13_11); 1020 ClassTreeMask test13_12(!test13_1); 939 1021 std::cout << std::endl; 940 1022 std::cout << "Mask 1 inverted assigned with copyconstructor + the original from before:\n"; 941 1023 TestClassTreeMask(test13_12); 942 TestClassTreeMask(test13_1 1);943 944 ClassTreeMask test13_13; 945 test13_13 =test13_2;946 std::cout << std::endl; 947 std::cout << "Mask 2 assigned with = operator + original mask 2:\n";1024 TestClassTreeMask(test13_1); 1025 1026 1027 ClassTreeMask test13_13 = test13_1 + test13_2; 1028 std::cout << std::endl; 1029 std::cout << "Mask 1 + Mask 2 assigned with copyconstructor + originals from before:\n"; 948 1030 TestClassTreeMask(test13_13); 1031 TestClassTreeMask(test13_1); 949 1032 TestClassTreeMask(test13_2); 950 1033 951 ClassTreeMask test13_14 = test13_11 + test13_13; 952 std::cout << std::endl; 953 std::cout << "Mask 1 + Mask 2 assigned with copyconstructor + originals from before:\n"; 1034 ClassTreeMask test13_14 = test13_1; 1035 test13_14 += test13_2; 1036 std::cout << std::endl; 1037 std::cout << "Mask 1 + Mask 2 with += operator + original of mask 2 from before:\n"; 954 1038 TestClassTreeMask(test13_14); 955 TestClassTreeMask(test13_11); 956 TestClassTreeMask(test13_13); 957 958 test13_11 += test13_13; 959 std::cout << std::endl; 960 std::cout << "Mask 1 + Mask 2 with += operator + original of mask 2 from before:\n"; 961 TestClassTreeMask(test13_11); 962 TestClassTreeMask(test13_13); 1039 TestClassTreeMask(test13_2); 963 1040 964 1041 test13_1 = test13_1; … … 968 1045 969 1046 std::cout << "9\n"; 970 */ 971 1047 1048 ClassTreeMask test13_15; 1049 test13_15.exclude(Class(Interface1)); 1050 std::cout << std::endl; 1051 std::cout << "Mask with excluded Interface 1:\n"; 1052 TestClassTreeMask(test13_15); 1053 1054 ClassTreeMask test13_16 = test13_1; 1055 test13_16.exclude(Class(Interface1)); 1056 std::cout << std::endl; 1057 std::cout << "Mask 1 with excluded Interface 1 (overwrite):\n"; 1058 TestClassTreeMask(test13_16); 1059 1060 ClassTreeMask test13_17 = test13_1; 1061 test13_17.exclude(Class(Interface1), false); 1062 std::cout << std::endl; 1063 std::cout << "Mask 1 with excluded Interface 1 (without overwrite):\n"; 1064 TestClassTreeMask(test13_17); 1065 1066 ClassTreeMask test13_18 = test13_2; 1067 test13_18.exclude(Class(Interface1), false); 1068 std::cout << std::endl; 1069 std::cout << "Mask 2 with excluded Interface 1 (without overwrite):\n"; 1070 TestClassTreeMask(test13_18); 1071 1072 std::cout << "10\n"; 1073 1074 ClassTreeMask test13_19; 1075 test13_19.exclude(Class(Test1)); 1076 std::cout << std::endl; 1077 std::cout << "Mask with excluded Test1:\n"; 1078 TestClassTreeMask(test13_19); 1079 1080 std::cout << "11\n"; 1081 1082 ClassTreeMask test13_20; 1083 test13_20.exclude(Class(DebugLevel)); 1084 std::cout << std::endl; 1085 std::cout << "Mask with excluded DebugLevel:\n"; 1086 TestClassTreeMask(test13_20); 1087 1088 std::cout << "12\n"; 1089 1090 /* 972 1091 std::cout << "Test 14\n"; 973 1092 std::cout << "1\n"; … … 991 1110 std::cout << test14_5.getIdentifier()->getName() << std::endl; 992 1111 1112 std::cout << "2\n"; 1113 */ 993 1114 // startRenderLoop(); 994 1115 } -
code/branches/core/src/orxonox/core/ClassTreeMask.cc
r813 r817 57 57 { 58 58 // Go through the list of all subnodes and delete them 59 this->deleteAllSubnodes(); 60 } 61 62 /** 63 @brief Sets the rule for the node to "included". 64 */ 65 void ClassTreeMaskNode::include(bool overwrite) 66 { 67 this->setIncluded(true, overwrite); 68 } 69 70 /** 71 @brief Sets the rule for the node to "excluded". 72 */ 73 void ClassTreeMaskNode::exclude(bool overwrite) 74 { 75 this->setIncluded(false, overwrite); 76 } 77 78 /** 79 @brief Sets the rule for the node to a given value and erases all following rules. 80 @param bIncluded The rule: included (true) or excluded (false) 81 */ 82 void ClassTreeMaskNode::setIncluded(bool bIncluded, bool overwrite) 83 { 84 if (overwrite) 85 this->deleteAllSubnodes(); 86 87 this->bIncluded_ = bIncluded; 88 } 89 90 /** 91 @brief Adds a new subnode to the list of subnodes. 92 @param subnode The new subnode 93 */ 94 void ClassTreeMaskNode::addSubnode(ClassTreeMaskNode* subnode) 95 { 96 this->subnodes_.insert(this->subnodes_.end(), subnode); 97 } 98 99 /** 100 @brief Tells if the rule is "included" or not. 101 @return The rule: true = included, false = excluded 102 */ 103 bool ClassTreeMaskNode::isIncluded() const 104 { 105 return this->bIncluded_; 106 } 107 108 /** 109 @brief Tells if the rule is "excluded" or not. 110 @return The inverted rule: true = excluded, false = included 111 */ 112 bool ClassTreeMaskNode::isExcluded() const 113 { 114 return (!this->bIncluded_); 115 } 116 117 /** 118 @brief Returns the Identifier of the class the rule refers to. 119 @return The Identifier representing the class 120 */ 121 const Identifier* ClassTreeMaskNode::getClass() const 122 { 123 return this->subclass_; 124 } 125 126 /** 127 @brief Deletes all subnodes of this node. 128 */ 129 void ClassTreeMaskNode::deleteAllSubnodes() 130 { 131 // Go through the list of all subnodes and delete them 59 132 for (std::list<ClassTreeMaskNode*>::iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ) 60 133 delete (*(it++)); 61 } 62 63 /** 64 @brief Sets the rule for the node to "included". 65 */ 66 void ClassTreeMaskNode::include() 67 { 68 this->bIncluded_ = true; 69 } 70 71 /** 72 @brief Sets the rule for the node to "excluded". 73 */ 74 void ClassTreeMaskNode::exclude() 75 { 76 this->bIncluded_ = false; 77 } 78 79 /** 80 @brief Sets the rule for the node to a given value. 81 @param bIncluded The rule: included (true) or excluded (false) 82 */ 83 void ClassTreeMaskNode::setIncluded(bool bIncluded) 84 { 85 this->bIncluded_ = bIncluded; 86 } 87 88 /** 89 @brief Adds a new subnode to the list of subnodes. 90 @param subnode The new subnode 91 */ 92 void ClassTreeMaskNode::addSubnode(ClassTreeMaskNode* subnode) 93 { 94 this->subnodes_.insert(this->subnodes_.end(), subnode); 95 } 96 97 /** 98 @brief Tells if the rule is "included" or not. 99 @return The rule: true = included, false = excluded 100 */ 101 bool ClassTreeMaskNode::isIncluded() const 102 { 103 return this->bIncluded_; 104 } 105 106 /** 107 @brief Tells if the rule is "excluded" or not. 108 @return The inverted rule: true = excluded, false = included 109 */ 110 bool ClassTreeMaskNode::isExcluded() const 111 { 112 return (!this->bIncluded_); 113 } 114 115 /** 116 @brief Returns the Identifier of the class the rule refers to. 117 @return The Identifier representing the class 118 */ 119 const Identifier* ClassTreeMaskNode::getClass() const 120 { 121 return this->subclass_; 134 135 // Clear the list 136 this->subnodes_.clear(); 122 137 } 123 138 … … 258 273 this->root_ = new ClassTreeMaskNode(ClassManager<BaseObject>::getIdentifier(), true); 259 274 for (ClassTreeMaskIterator it = other.root_; it; ++it) 260 this->add(it->getClass(), it->isIncluded() );275 this->add(it->getClass(), it->isIncluded(), false); 261 276 } 262 277 … … 273 288 @param subclass The subclass 274 289 */ 275 void ClassTreeMask::include(const Identifier* subclass )276 { 277 this->add(subclass, true );290 void ClassTreeMask::include(const Identifier* subclass, bool overwrite, bool clean) 291 { 292 this->add(subclass, true, overwrite, clean); 278 293 } 279 294 … … 282 297 @param subclass The subclass 283 298 */ 284 void ClassTreeMask::exclude(const Identifier* subclass )285 { 286 this->add(subclass, false );299 void ClassTreeMask::exclude(const Identifier* subclass, bool overwrite, bool clean) 300 { 301 this->add(subclass, false, overwrite, clean); 287 302 } 288 303 … … 292 307 @param bInclude The rule: include (true) or exclude (false) 293 308 */ 294 void ClassTreeMask::add(const Identifier* subclass, bool bInclude) 295 { 309 void ClassTreeMask::add(const Identifier* subclass, bool bInclude, bool overwrite, bool clean) 310 { 311 // Check if the given subclass is a child of our root-class 296 312 if (subclass->isA(this->root_->getClass())) 297 this->add(this->root_, subclass, bInclude); 313 { 314 // Yes it is: Just add the rule to the three 315 this->add(this->root_, subclass, bInclude, overwrite); 316 } 298 317 else 299 318 { 300 301 } 302 303 this->clean(); 319 // No it's not: Search for classes inheriting from the given class and add the rules for them 320 for (std::list<const Identifier*>::const_iterator it = subclass->getDirectChildrenBegin(); it != subclass->getDirectChildrenEnd(); ++it) 321 if ((*it)->isA(this->root_->getClass())) 322 if (overwrite || (!this->nodeExists(*it))) // If we don't want to overwrite, only add nodes that don't already exist 323 this->add(this->root_, *it, bInclude, overwrite); 324 } 325 326 // Clean the rule-tree 327 if (clean) 328 this->clean(); 304 329 } 305 330 … … 310 335 @param bInclude The rule: include (true) or exclude (false) 311 336 */ 312 void ClassTreeMask::add(ClassTreeMaskNode* node, const Identifier* subclass, bool bInclude )337 void ClassTreeMask::add(ClassTreeMaskNode* node, const Identifier* subclass, bool bInclude, bool overwrite) 313 338 { 314 339 // Check if the current node contains exactly the subclass we want to add … … 316 341 { 317 342 // We're at the right place, just change the mask and return 318 node->setIncluded(bInclude );343 node->setIncluded(bInclude, overwrite); 319 344 return; 320 345 } 321 else 346 else if (subclass->isA(node->getClass())) 322 347 { 323 348 // Search for an already existing node, containing the subclass we want to add … … 327 352 { 328 353 // We've found an existing node -> delegate the work with a recursive function-call and return 329 this->add(*it, subclass, bInclude );354 this->add(*it, subclass, bInclude, overwrite); 330 355 return; 331 356 } … … 335 360 ClassTreeMaskNode* newnode = new ClassTreeMaskNode(subclass, bInclude); 336 361 337 // Search for nodes that should actually be subnodes of our new node 362 // Search for nodes that should actually be subnodes of our new node and erase them 338 363 for (std::list<ClassTreeMaskNode*>::iterator it = node->subnodes_.begin(); it != node->subnodes_.end(); ) 339 364 { 340 365 if ((*it)->getClass()->isChildOf(subclass)) 341 366 { 342 // We've found a subnode: add it to the new node an erase it from the current node 343 newnode->addSubnode(*it); 367 // We've found a subnode: add it to the new node and erase it from the current node 368 if (!overwrite) 369 newnode->addSubnode(*it); 370 else 371 delete (*it); 372 344 373 node->subnodes_.erase(it++); 345 374 } … … 453 482 454 483 /** 484 @brief Checks if a node for the given subclass exists. 485 @param subclass The Identifier of the subclass 486 @return True = the node exists 487 */ 488 bool ClassTreeMask::nodeExists(const Identifier* subclass) 489 { 490 for (ClassTreeMaskIterator it = this->root_; it; ++it) 491 if ((*it)->getClass() == subclass) 492 return true; 493 494 return false; 495 } 496 497 /** 455 498 @brief Assignment operator: Adds all rules of the other mask. 456 499 @param other The other mask … … 467 510 // Copy all rules from the other mask 468 511 for (ClassTreeMaskIterator it = temp.root_; it; ++it) 469 this->add(it->getClass(), it->isIncluded() );512 this->add(it->getClass(), it->isIncluded(), false, false); 470 513 471 514 // Return a reference to the mask itself … … 505 548 { 506 549 const Identifier* subclass = it->getClass(); 507 newmask.add(subclass, this->isIncluded(subclass) or other.isIncluded(subclass) );550 newmask.add(subclass, this->isIncluded(subclass) or other.isIncluded(subclass), false, false); 508 551 } 509 552 … … 512 555 { 513 556 const Identifier* subclass = it->getClass(); 514 newmask.add(subclass, this->isIncluded(subclass) or other.isIncluded(subclass) );557 newmask.add(subclass, this->isIncluded(subclass) or other.isIncluded(subclass), false, false); 515 558 } 516 559 … … 536 579 { 537 580 const Identifier* subclass = it->getClass(); 538 newmask.add(subclass, this->isIncluded(subclass) and other.isIncluded(subclass) );581 newmask.add(subclass, this->isIncluded(subclass) and other.isIncluded(subclass), false, false); 539 582 } 540 583 … … 543 586 { 544 587 const Identifier* subclass = it->getClass(); 545 newmask.add(subclass, this->isIncluded(subclass) and other.isIncluded(subclass) );588 newmask.add(subclass, this->isIncluded(subclass) and other.isIncluded(subclass), false, false); 546 589 } 547 590 … … 576 619 { 577 620 const Identifier* subclass = it->getClass(); 578 newmask.add(subclass, !this->isIncluded(subclass) );621 newmask.add(subclass, !this->isIncluded(subclass), false, false); 579 622 } 580 623 … … 650 693 { 651 694 const Identifier* subclass = it->getClass(); 652 newmask.add(subclass, this->isIncluded(subclass) xor other.isIncluded(subclass) );695 newmask.add(subclass, this->isIncluded(subclass) xor other.isIncluded(subclass), false, false); 653 696 } 654 697 … … 657 700 { 658 701 const Identifier* subclass = it->getClass(); 659 newmask.add(subclass, this->isIncluded(subclass) xor other.isIncluded(subclass) );702 newmask.add(subclass, this->isIncluded(subclass) xor other.isIncluded(subclass), false, false); 660 703 } 661 704 -
code/branches/core/src/orxonox/core/ClassTreeMask.h
r813 r817 34 34 Identifier of the class. 35 35 36 You can work with a ClassTreeMask in the sense of the set 36 You can work with a ClassTreeMask in the sense of the set-theory, meaning that you can create 37 37 unions, intersections, complements and differences by using overloaded operators. 38 39 38 40 39 41 The ClassTreeMask is internally represented by a tree. The nodes in the tree are … … 42 44 nodes changing the mask. By adding new rules, the tree gets reordered dynamically. 43 45 44 You can manually add useless rules and they stay in the tree. That way you can add rules in 45 any order without changing information of the resulting mask. Example: A new mask includes all 46 classes. Now you explicitly include a subclass. This seems to be useless. But if you exclude a 47 baseclass of the formerly included subclass, the subclass stays included. You could create the 48 same mask by first excluding the baseclass and then including the subclass. You can drop 49 useless rules from the tree by calling clean(). 46 Adding a new rule overwrites all rules assigned to inherited classes. Use overwrite = false 47 if you don't like this feature. Useless rules that don't change the information of the mask 48 aren't saved in the internal tree. Use clean = false if you wan't to save them. 49 50 With overwrite = false and clean = false it doesn't matter in which way you create the mask. 51 You can manually drop useless rules from the tree by calling clean(). 52 53 50 54 51 55 Because of the complicated shape of the internal tree, there is an iterator to iterate … … 91 95 ~ClassTreeMaskNode(); 92 96 93 void include( );94 void exclude( );95 void setIncluded(bool bIncluded );97 void include(bool overwrite = true); 98 void exclude(bool overwrite = true); 99 void setIncluded(bool bIncluded, bool overwrite = true); 96 100 97 101 void addSubnode(ClassTreeMaskNode* subnode); … … 103 107 104 108 private: 109 void deleteAllSubnodes(); 110 105 111 const Identifier* subclass_; //!< The Identifier of the subclass the rule refers to 106 112 bool bIncluded_; //!< The rule: included or excluded … … 146 152 With a ClassTreeMask, you can include or exclude subtrees of the class-tree, starting 147 153 with a given subclass, described by the corresponding Identifier. To minimize the size 148 of the mask, the mask saves only relevant rules. But you are allowed to manually add 149 rules that don't change the information of the mask. This way you can create the same 150 mask by adding the same rules in a different way without changing the information. If 151 you want to drop useless rules, call the clean() function. 154 of the mask, the mask saves only relevant rules. But you can manually add rules that 155 don't change the information of the mask by using clean = false. If you want to drop 156 useless rules, call the clean() function. 152 157 */ 153 158 class _CoreExport ClassTreeMask … … 158 163 ~ClassTreeMask(); 159 164 160 void include(const Identifier* subclass );161 void exclude(const Identifier* subclass );162 void add(const Identifier* subclass, bool bInclude );165 void include(const Identifier* subclass, bool overwrite = true, bool clean = true); 166 void exclude(const Identifier* subclass, bool overwrite = true, bool clean = true); 167 void add(const Identifier* subclass, bool bInclude, bool overwrite = true, bool clean = true); 163 168 void reset(); 164 169 void clean(); … … 193 198 194 199 private: 195 void add(ClassTreeMaskNode* node, const Identifier* subclass, bool bInclude );200 void add(ClassTreeMaskNode* node, const Identifier* subclass, bool bInclude, bool overwrite = true); 196 201 bool isIncluded(ClassTreeMaskNode* node, const Identifier* subclass) const; 197 202 void clean(ClassTreeMaskNode* node); 203 bool nodeExists(const Identifier* subclass); 198 204 199 205 ClassTreeMaskNode* root_; //!< The root-node of the internal rule-tree, usually BaseObject -
code/branches/core/src/orxonox/core/Factory.cc
r813 r817 109 109 return &theOneAndOnlyFactoryInstance; 110 110 } 111 112 /** 113 @brief Returns the begin-iterator of the factory-map. 114 @return The begin-iterator 115 */ 116 std::map<std::string, Identifier*>::const_iterator Factory::getFactoryBegin() 117 { 118 return Factory::getFactoryPointer()->identifierStringMap_.begin(); 119 } 120 121 /** 122 @brief Returns the end-iterator of the factory-map. 123 @return The end-iterator 124 */ 125 std::map<std::string, Identifier*>::const_iterator Factory::getFactoryEnd() 126 { 127 return Factory::getFactoryPointer()->identifierStringMap_.end(); 128 } 111 129 } -
code/branches/core/src/orxonox/core/Factory.h
r813 r817 67 67 68 68 static Factory* getFactoryPointer(); // avoid overriding order problem in the static intialisation process 69 static std::map<std::string, Identifier*>::const_iterator getFactoryBegin(); 70 static std::map<std::string, Identifier*>::const_iterator getFactoryEnd(); 69 71 70 72 private: -
code/branches/core/src/orxonox/core/Identifier.cc
r813 r817 30 30 @brief Implementation of the Identifier class. 31 31 */ 32 33 #include <ostream> 32 34 33 35 #include "Identifier.h" … … 50 52 51 53 this->children_ = new std::list<const Identifier*>(); 54 this->directChildren_ = new std::list<const Identifier*>(); 52 55 53 56 // Use a static variable because the classID gets created before main() and that's why we should avoid static member variables … … 62 65 { 63 66 delete this->children_; 67 delete this->directChildren_; 64 68 } 65 69 … … 75 79 if (parents) 76 80 { 77 std::list<const Identifier*>::iterator temp1 = parents->begin(); 78 while (temp1 != parents->end()) 81 this->parents_ = (*parents); 82 this->directParents_ = (*parents); 83 84 // Iterate through all parents 85 for (std::list<const Identifier*>::iterator it = parents->begin(); it != parents->end(); ++it) 79 86 { 80 this->parents_.insert(this->parents_.end(), *temp1); 81 (*temp1)->getChildren().insert((*temp1)->getChildren().end(), this); // We're a child of our parents 82 83 ++temp1; 87 // Tell the parent we're one of it's children 88 (*it)->getChildrenIntern().insert((*it)->getChildrenIntern().end(), this); 89 90 // Erase all parents of our parent from our direct-parent-list 91 for (std::list<const Identifier*>::const_iterator it1 = (*it)->getParents().begin(); it1 != (*it)->getParents().end(); ++it1) 92 { 93 // Search for the parent's parent in our direct-parent-list 94 for (std::list<const Identifier*>::iterator it2 = this->directParents_.begin(); it2 != this->directParents_.end(); ++it2) 95 { 96 if ((*it1) == (*it2)) 97 { 98 // We've found a non-direct parent in our list: Erase it 99 this->directParents_.erase(it2); 100 break; 101 } 102 } 103 } 104 } 105 106 // Now iterate through all direct parents 107 for (std::list<const Identifier*>::iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it) 108 { 109 // Tell the parent we're one of it's direct children 110 (*it)->getDirectChildrenIntern().insert((*it)->getDirectChildrenIntern().end(), this); 84 111 } 85 112 } … … 98 125 else 99 126 { 100 // Abstract classes don't have a factory and therefore can't create new objects101 127 COUT(1) << "An error occurred in Identifier:" << std::endl; 102 COUT(1) << "Error: Cannot create an object of type '" << this->name_ << "'. Class is abstract." << std::endl;128 COUT(1) << "Error: Cannot fabricate an object of type '" << this->name_ << "'. Class has no factory." << std::endl; 103 129 COUT(1) << "Aborting..." << std::endl; 104 130 abort(); … … 130 156 @param identifier The identifier to compare with 131 157 */ 132 bool Identifier::is DirectlyA(const Identifier* identifier) const158 bool Identifier::isExactlyA(const Identifier* identifier) const 133 159 { 134 160 return (identifier == this); … … 145 171 146 172 /** 173 @brief Returns true, if the assigned identifier is a direct child of the given identifier. 174 @param identifier The identifier to compare with 175 */ 176 bool Identifier::isDirectChildOf(const Identifier* identifier) const 177 { 178 return this->identifierIsInList(identifier, this->directParents_); 179 } 180 181 /** 147 182 @brief Returns true, if the assigned identifier is a parent of the given identifier. 148 183 @param identifier The identifier to compare with … … 151 186 { 152 187 return this->identifierIsInList(identifier, *this->children_); 188 } 189 190 /** 191 @brief Returns true, if the assigned identifier is a direct parent of the given identifier. 192 @param identifier The identifier to compare with 193 */ 194 bool Identifier::isDirectParentOf(const Identifier* identifier) const 195 { 196 return this->identifierIsInList(identifier, *this->directChildren_); 153 197 } 154 198 … … 167 211 return false; 168 212 } 213 214 std::ostream& operator<<(std::ostream& out, const std::list<const Identifier*>& list) 215 { 216 for (std::list<const Identifier*>::const_iterator it = list.begin(); it != list.end(); ++it) 217 out << (*it)->getName() << " "; 218 219 return out; 220 } 169 221 } -
code/branches/core/src/orxonox/core/Identifier.h
r814 r817 39 39 40 40 Every object has a pointer to the Identifier of its class. This allows the use isA(...), 41 is DirectlyA(...), isChildOf(...) and isParentOf(...).41 isExactlyA(...), isChildOf(...) and isParentOf(...). 42 42 43 43 To create the class-hierarchy, the Identifier has some intern functions and variables. … … 82 82 83 83 Every object has a pointer to the Identifier of its class. This allows the use isA(...), 84 is DirectlyA(...), isChildOf(...) and isParentOf(...).84 isExactlyA(...), isChildOf(...) and isParentOf(...). 85 85 86 86 You can't directly create an Identifier, it's just the base-class for ClassIdentifier. … … 102 102 BaseObject* fabricate(); 103 103 bool isA(const Identifier* identifier) const; 104 bool is DirectlyA(const Identifier* identifier) const;104 bool isExactlyA(const Identifier* identifier) const; 105 105 bool isChildOf(const Identifier* identifier) const; 106 bool isDirectChildOf(const Identifier* identifier) const; 106 107 bool isParentOf(const Identifier* identifier) const; 108 bool isDirectParentOf(const Identifier* identifier) const; 107 109 108 110 /** @brief Removes all objects of the corresponding class. */ … … 114 116 /** @brief Returns the parents of the class the Identifier belongs to. @return The list of all parents */ 115 117 inline const std::list<const Identifier*>& getParents() const { return this->parents_; } 116 117 118 /** @brief Returns the begin-iterator of the parents-list. @return The begin-iterator */ 118 119 inline std::list<const Identifier*>::const_iterator getParentsBegin() const { return this->parents_.begin(); } 119 120 120 /** @brief Returns the end-iterator of the parents-list. @return The end-iterator */ 121 121 inline std::list<const Identifier*>::const_iterator getParentsEnd() const { return this->parents_.end(); } 122 122 123 /** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */ 124 inline const std::list<const Identifier*>& getChildren() const { return (*this->children_); } 123 125 /** @brief Returns the begin-iterator of the children-list. @return The begin-iterator */ 124 126 inline std::list<const Identifier*>::const_iterator getChildrenBegin() const { return this->children_->begin(); } 125 126 127 /** @brief Returns the end-iterator of the children-list. @return The end-iterator */ 127 128 inline std::list<const Identifier*>::const_iterator getChildrenEnd() const { return this->children_->end(); } 129 130 /** @brief Returns the direct parents of the class the Identifier belongs to. @return The list of all direct parents */ 131 inline const std::list<const Identifier*>& getDirectParents() const { return this->directParents_; } 132 /** @brief Returns the begin-iterator of the direct-parents-list. @return The begin-iterator */ 133 inline std::list<const Identifier*>::const_iterator getDirectParentsBegin() const { return this->directParents_.begin(); } 134 /** @brief Returns the end-iterator of the direct-parents-list. @return The end-iterator */ 135 inline std::list<const Identifier*>::const_iterator getDirectParentsEnd() const { return this->directParents_.end(); } 136 137 /** @brief Returns the direct children the class the Identifier belongs to. @return The list of all direct children */ 138 inline const std::list<const Identifier*>& getDirectChildren() const { return (*this->directChildren_); } 139 /** @brief Returns the begin-iterator of the direct-children-list. @return The begin-iterator */ 140 inline std::list<const Identifier*>::const_iterator getDirectChildrenBegin() const { return this->directChildren_->begin(); } 141 /** @brief Returns the end-iterator of the direct-children-list. @return The end-iterator */ 142 inline std::list<const Identifier*>::const_iterator getDirectChildrenEnd() const { return this->directChildren_->end(); } 128 143 129 144 /** @brief Returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents. @return The status of the class-hierarchy creation */ … … 143 158 inline void setConfigValueContainer(const std::string& varname, ConfigValueContainer* container) 144 159 { this->configValues_[varname] = container; } 160 161 static bool identifierIsInList(const Identifier* identifier, const std::list<const Identifier*>& list); 145 162 146 163 private: … … 150 167 void initialize(std::list<const Identifier*>* parents); 151 168 152 /** @brief Returns the parents of the class the Identifier belongs to. @return The list of all parents */153 inline std::list<const Identifier*>& getParents() { return this->parents_; }154 155 169 /** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */ 156 inline std::list<const Identifier*>& getChildren() const { return (*this->children_); } 170 inline std::list<const Identifier*>& getChildrenIntern() const { return (*this->children_); } 171 /** @brief Returns the direct children of the class the Identifier belongs to. @return The list of all direct children */ 172 inline std::list<const Identifier*>& getDirectChildrenIntern() const { return (*this->directChildren_); } 157 173 158 174 /** … … 174 190 } 175 191 176 static bool identifierIsInList(const Identifier* identifier, const std::list<const Identifier*>& list); 177 178 std::list<const Identifier*> parents_; //!< The Parents of the class the Identifier belongs to 179 std::list<const Identifier*>* children_; //!< The Children of the class the Identifier belongs to 192 std::list<const Identifier*> parents_; //!< The parents of the class the Identifier belongs to 193 std::list<const Identifier*>* children_; //!< The children of the class the Identifier belongs to 194 195 std::list<const Identifier*> directParents_; //!< The direct parents of the class the Identifier belongs to 196 std::list<const Identifier*>* directChildren_; //!< The direct children of the class the Identifier belongs to 180 197 181 198 std::string name_; //!< The name of the class the Identifier belongs to … … 188 205 }; 189 206 207 std::ostream& operator<<(std::ostream& out, const std::list<const Identifier*>& list); 208 190 209 191 210 // ############################### … … 215 234 void removeObjects() const; 216 235 void setName(const std::string& name); 236 inline const ObjectList<T>* getObjects() const { return this->objects_; } 217 237 218 238 private: … … 231 251 ClassIdentifier<T>::ClassIdentifier() 232 252 { 233 this->objects_ = ObjectList<T>::getList(); 253 // this->objects_ = ObjectList<T>::getList(); 254 this->objects_ = new ObjectList<T>(); 234 255 this->bSetName_ = false; 235 256 } … … 294 315 void ClassIdentifier<T>::removeObjects() const 295 316 { 296 for (Iterator<T> it = ObjectList<T>::start(); it;)317 for (Iterator<T> it = this->objects_->start(); it;) 297 318 delete *(it++); 298 319 } 320 299 321 300 322 // ############################### … … 409 431 410 432 /** @brief Returns true, if the assigned identifier is exactly of the given type. @param identifier The identifier to compare with */ 411 inline bool is DirectlyA(const Identifier* identifier) const412 { return this->identifier_->is DirectlyA(identifier); }433 inline bool isExactlyA(const Identifier* identifier) const 434 { return this->identifier_->isExactlyA(identifier); } 413 435 414 436 /** @brief Returns true, if the assigned identifier is a child of the given identifier. @param identifier The identifier to compare with */ … … 416 438 { return this->identifier_->isChildOf(identifier); } 417 439 440 /** @brief Returns true, if the assigned identifier is a direct child of the given identifier. @param identifier The identifier to compare with */ 441 inline bool isDirectChildOf(const Identifier* identifier) const 442 { return this->identifier_->isDirectChildOf(identifier); } 443 418 444 /** @brief Returns true, if the assigned identifier is a parent of the given identifier. @param identifier The identifier to compare with */ 419 445 inline bool isParentOf(const Identifier* identifier) const 420 446 { return this->identifier_->isParentOf(identifier); } 447 448 /** @brief Returns true, if the assigned identifier is a direct parent of the given identifier. @param identifier The identifier to compare with */ 449 inline bool isDirectParentOf(const Identifier* identifier) const 450 { return this->identifier_->isDirectParentOf(identifier); } 421 451 422 452 private: -
code/branches/core/src/orxonox/core/ObjectList.h
r813 r817 40 40 #include "CorePrereqs.h" 41 41 #include "Iterator.h" 42 #include "ClassManager.h" 42 43 43 44 namespace orxonox … … 83 84 { 84 85 public: 85 static ObjectList<T>* getList(); 86 ObjectList(); 87 ~ObjectList(); 86 88 87 89 ObjectListElement<T>* add(T* object); … … 90 92 /** @brief Returns the first element in the list. @return The first element */ 91 93 inline static Iterator<T> start() 92 { return Iterator<T>( getList()->first_); }94 { return Iterator<T>(ClassManager<T>::getIdentifier()->getObjects()->first_); } 93 95 94 96 /** @brief Returns the first element in the list. @return The first element */ 95 97 inline static Iterator<T> begin() 96 { return Iterator<T>( getList()->first_); }98 { return Iterator<T>(ClassManager<T>::getIdentifier()->getObjects()->first_); } 97 99 98 100 /** @brief Returns the last element in the list. @return The last element */ 99 101 inline static Iterator<T> end() 100 { return Iterator<T>( getList()->last_); }102 { return Iterator<T>(ClassManager<T>::getIdentifier()->getObjects()->last_); } 101 103 102 104 ObjectListElement<T>* first_; //!< The first element in the list 103 105 ObjectListElement<T>* last_; //!< The last element in the list 104 105 private:106 ObjectList();107 ~ObjectList();108 106 }; 109 107 … … 131 129 this->first_ = temp; 132 130 } 133 }134 135 /**136 @brief Returns a pointer to the only existing instance for the given class T. @return The instance137 */138 template <class T>139 ObjectList<T>* ObjectList<T>::getList()140 {141 static ObjectList<T> theOnlyObjectListObjectForClassT = ObjectList<T>();142 return &theOnlyObjectListObjectForClassT;143 131 } 144 132 -
code/branches/core/src/orxonox/core/OrxonoxClass.h
r813 r817 72 72 inline void createParents() { this->parents_ = new std::list<const Identifier*>(); } 73 73 74 // /** @brief Sets the Parents of the object. Used by the RegisterObject-macro. */75 // inline void setParents(std::list<const Identifier*>* parents) { this->parents_ = parents; }76 77 74 /** @brief Returns the MetaObjectList of the object, containing a link to all ObjectLists and ObjectListElements the object is registered in. @return The list */ 78 75 inline MetaObjectList& getMetaList() { return this->metaList_; } … … 83 80 { return this->getIdentifier()->isA(identifier); } 84 81 /** @brief Returns true if the objects class is exactly of the given type. */ 85 inline bool is DirectlyA(const Identifier* identifier)86 { return this->getIdentifier()->is DirectlyA(identifier); }82 inline bool isExactlyA(const Identifier* identifier) 83 { return this->getIdentifier()->isExactlyA(identifier); } 87 84 /** @brief Returns true if the objects class is a child of the given type. */ 88 85 inline bool isChildOf(const Identifier* identifier) 89 86 { return this->getIdentifier()->isChildOf(identifier); } 87 /** @brief Returns true if the objects class is a direct child of the given type. */ 88 inline bool isDirectChildOf(const Identifier* identifier) 89 { return this->getIdentifier()->isDirectChildOf(identifier); } 90 90 /** @brief Returns true if the objects class is a parent of the given type. */ 91 91 inline bool isParentOf(const Identifier* identifier) 92 92 { return this->getIdentifier()->isParentOf(identifier); } 93 /** @brief Returns true if the objects class is a direct parent of the given type. */ 94 inline bool isDirectParentOf(const Identifier* identifier) 95 { return this->getIdentifier()->isDirectParentOf(identifier); } 93 96 94 97 … … 97 100 { return this->getIdentifier()->isA(identifier->getIdentifier()); } 98 101 /** @brief Returns true if the objects class is exactly of the given type. */ 99 inline bool is DirectlyA(const SubclassIdentifier<class B>* identifier)100 { return this->getIdentifier()->is DirectlyA(identifier->getIdentifier()); }102 inline bool isExactlyA(const SubclassIdentifier<class B>* identifier) 103 { return this->getIdentifier()->isExactlyA(identifier->getIdentifier()); } 101 104 /** @brief Returns true if the objects class is a child of the given type. */ 102 105 inline bool isChildOf(const SubclassIdentifier<class B>* identifier) 103 106 { return this->getIdentifier()->isChildOf(identifier->getIdentifier()); } 107 /** @brief Returns true if the objects class is a direct child of the given type. */ 108 inline bool isDirectChildOf(const SubclassIdentifier<class B>* identifier) 109 { return this->getIdentifier()->isDirectChildOf(identifier->getIdentifier()); } 104 110 /** @brief Returns true if the objects class is a parent of the given type. */ 105 111 inline bool isParentOf(const SubclassIdentifier<class B>* identifier) 106 112 { return this->getIdentifier()->isParentOf(identifier->getIdentifier()); } 113 /** @brief Returns true if the objects class is a direct parent of the given type. */ 114 inline bool isDirectParentOf(const SubclassIdentifier<class B>* identifier) 115 { return this->getIdentifier()->isDirectParentOf(identifier->getIdentifier()); } 107 116 108 117 … … 111 120 { return this->getIdentifier()->isA(identifier.getIdentifier()); } 112 121 /** @brief Returns true if the objects class is exactly of the given type. */ 113 inline bool is DirectlyA(const SubclassIdentifier<class B> identifier)114 { return this->getIdentifier()->is DirectlyA(identifier.getIdentifier()); }122 inline bool isExactlyA(const SubclassIdentifier<class B> identifier) 123 { return this->getIdentifier()->isExactlyA(identifier.getIdentifier()); } 115 124 /** @brief Returns true if the objects class is a child of the given type. */ 116 125 inline bool isChildOf(const SubclassIdentifier<class B> identifier) 117 126 { return this->getIdentifier()->isChildOf(identifier.getIdentifier()); } 127 /** @brief Returns true if the objects class is a direct child of the given type. */ 128 inline bool isDirectChildOf(const SubclassIdentifier<class B> identifier) 129 { return this->getIdentifier()->isDirectChildOf(identifier.getIdentifier()); } 118 130 /** @brief Returns true if the objects class is a parent of the given type. */ 119 131 inline bool isParentOf(const SubclassIdentifier<class B> identifier) 120 132 { return this->getIdentifier()->isParentOf(identifier.getIdentifier()); } 133 /** @brief Returns true if the objects class is a direct parent of the given type. */ 134 inline bool isDirectParentOf(const SubclassIdentifier<class B> identifier) 135 { return this->getIdentifier()->isDirectParentOf(identifier.getIdentifier()); } 121 136 122 137 … … 125 140 { return this->getIdentifier()->isA(object->getIdentifier()); } 126 141 /** @brief Returns true if the objects class is exactly of the given type. */ 127 inline bool is DirectlyA(const OrxonoxClass* object)128 { return this->getIdentifier()->is DirectlyA(object->getIdentifier()); }142 inline bool isExactlyA(const OrxonoxClass* object) 143 { return this->getIdentifier()->isExactlyA(object->getIdentifier()); } 129 144 /** @brief Returns true if the objects class is a child of the given type. */ 130 145 inline bool isChildOf(const OrxonoxClass* object) 131 146 { return this->getIdentifier()->isChildOf(object->getIdentifier()); } 147 /** @brief Returns true if the objects class is a direct child of the given type. */ 148 inline bool isDirectChildOf(const OrxonoxClass* object) 149 { return this->getIdentifier()->isDirectChildOf(object->getIdentifier()); } 132 150 /** @brief Returns true if the objects class is a parent of the given type. */ 133 151 inline bool isParentOf(const OrxonoxClass* object) 134 152 { return this->getIdentifier()->isParentOf(object->getIdentifier()); } 153 /** @brief Returns true if the objects class is a direct child of the given type. */ 154 inline bool isDirectParentOf(const OrxonoxClass* object) 155 { return this->getIdentifier()->isDirectParentOf(object->getIdentifier()); } 135 156 136 157 -
code/branches/core/src/orxonox/objects/Test.h
r811 r817 74 74 public: 75 75 A1B2() { RegisterObject(A1B2); } 76 virtual void test() = 0;76 // virtual void test() = 0; 77 77 }; 78 78 … … 117 117 public: 118 118 A1B2C1() { RegisterObject(A1B2C1); } 119 void test() { std::cout << "test!\n"; }119 // void test() { std::cout << "test!\n"; } 120 120 }; 121 121 … … 160 160 CreateFactory(A3); 161 161 CreateFactory(A1B1); 162 //CreateFactory(A1B2);162 CreateFactory(A1B2); 163 163 CreateFactory(A2B1); 164 164 CreateFactory(A2B2);
Note: See TracChangeset
for help on using the changeset viewer.