| 1 | | /*---------------------------------------------------------------------------*\ |
|---|
| 2 | | * OpenSG * |
|---|
| 3 | | * * |
|---|
| 4 | | * * |
|---|
| 5 | | * Copyright 2007 by OpenSG Forum * |
|---|
| 6 | | * * |
|---|
| 7 | | * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de * |
|---|
| 8 | | * * |
|---|
| 9 | | \*---------------------------------------------------------------------------*/ |
|---|
| 10 | | /*---------------------------------------------------------------------------*\ |
|---|
| 11 | | * License * |
|---|
| 12 | | * * |
|---|
| 13 | | * This library is free software; you can redistribute it and/or modify it * |
|---|
| 14 | | * under the terms of the GNU Library General Public License as published * |
|---|
| 15 | | * by the Free Software Foundation, version 2. * |
|---|
| 16 | | * * |
|---|
| 17 | | * This library is distributed in the hope that it will be useful, but * |
|---|
| 18 | | * WITHOUT ANY WARRANTY; without even the implied warranty of * |
|---|
| 19 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * |
|---|
| 20 | | * Library General Public License for more details. * |
|---|
| 21 | | * * |
|---|
| 22 | | * You should have received a copy of the GNU Library General Public * |
|---|
| 23 | | * License along with this library; if not, write to the Free Software * |
|---|
| 24 | | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * |
|---|
| 25 | | * * |
|---|
| 26 | | \*---------------------------------------------------------------------------*/ |
|---|
| 27 | | /*---------------------------------------------------------------------------*\ |
|---|
| 28 | | * Changes * |
|---|
| 29 | | * * |
|---|
| 30 | | * * |
|---|
| 31 | | * * |
|---|
| 32 | | * * |
|---|
| 33 | | * * |
|---|
| 34 | | * * |
|---|
| 35 | | \*---------------------------------------------------------------------------*/ |
|---|
| 36 | | |
|---|
| | 430 | |
|---|
| | 431 | /*! \class DynamicEditMFCPointerFieldHandle<FieldT> |
|---|
| | 432 | |
|---|
| | 433 | Concrete \c EditFieldHandle for multi fields that store pointers. |
|---|
| | 434 | This particular variant is used for dynamically added fields. |
|---|
| | 435 | |
|---|
| | 436 | \dev |
|---|
| | 437 | Since a dynamically added field can not be manipulated by the container |
|---|
| | 438 | it is added to (the container lacks static type information about the |
|---|
| | 439 | field), this EditHandle does not call back into the container, but |
|---|
| | 440 | manipulates the field directly. |
|---|
| | 441 | \enddev |
|---|
| | 442 | */ |
|---|
| | 443 | |
|---|
| | 444 | /*-------------------------------------------------------------------------*/ |
|---|
| | 445 | /* DynamicEditMFCPointerFieldHandle<FieldT> */ |
|---|
| | 446 | /*-------------------------------------------------------------------------*/ |
|---|
| | 447 | |
|---|
| | 448 | /*-------------------------------------------------------------------------*/ |
|---|
| | 449 | /* Helper */ |
|---|
| | 450 | |
|---|
| | 451 | template <class FieldT> |
|---|
| | 452 | inline typename DynamicEditMFCPointerFieldHandle<FieldT>::HandledFieldType * |
|---|
| | 453 | DynamicEditMFCPointerFieldHandle<FieldT>::castFieldDown(void) const |
|---|
| | 454 | { |
|---|
| | 455 | return static_cast<HandledFieldType *>(_pField); |
|---|
| | 456 | } |
|---|
| | 457 | |
|---|
| | 458 | template <class FieldT> |
|---|
| | 459 | inline FieldContainer * |
|---|
| | 460 | DynamicEditMFCPointerFieldHandle<FieldT>::castPtrUp( |
|---|
| | 461 | HandledFieldValueType ptr) const |
|---|
| | 462 | { |
|---|
| | 463 | return static_cast<FieldContainer *>(static_cast<void *>(ptr)); |
|---|
| | 464 | } |
|---|
| | 465 | |
|---|
| | 466 | /*-------------------------------------------------------------------------*/ |
|---|
| | 467 | /* Constructors */ |
|---|
| | 468 | |
|---|
| | 469 | template <class FieldT> |
|---|
| | 470 | inline |
|---|
| | 471 | DynamicEditMFCPointerFieldHandle<FieldT>::DynamicEditMFCPointerFieldHandle( |
|---|
| | 472 | Self const &other) |
|---|
| | 473 | |
|---|
| | 474 | : Inherited(other) |
|---|
| | 475 | { |
|---|
| | 476 | } |
|---|
| | 477 | |
|---|
| | 478 | template <class FieldT> |
|---|
| | 479 | inline |
|---|
| | 480 | DynamicEditMFCPointerFieldHandle<FieldT>::DynamicEditMFCPointerFieldHandle( |
|---|
| | 481 | Field *pField, |
|---|
| | 482 | FieldDescriptionBase const *pDescription) |
|---|
| | 483 | |
|---|
| | 484 | : Inherited(pField, pDescription) |
|---|
| | 485 | { |
|---|
| | 486 | } |
|---|
| | 487 | |
|---|
| | 488 | /*-------------------------------------------------------------------------*/ |
|---|
| | 489 | /* Destructor */ |
|---|
| | 490 | |
|---|
| | 491 | template <class FieldT> |
|---|
| | 492 | inline |
|---|
| | 493 | DynamicEditMFCPointerFieldHandle<FieldT>::~DynamicEditMFCPointerFieldHandle(void) |
|---|
| | 494 | { |
|---|
| | 495 | } |
|---|
| | 496 | |
|---|
| | 497 | /*-------------------------------------------------------------------------*/ |
|---|
| | 498 | /* Type Query */ |
|---|
| | 499 | |
|---|
| | 500 | template <class FieldT> |
|---|
| | 501 | inline FieldType const & |
|---|
| | 502 | DynamicEditMFCPointerFieldHandle<FieldT>::getType(void) const |
|---|
| | 503 | { |
|---|
| | 504 | return HandledFieldType::getClassType(); |
|---|
| | 505 | } |
|---|
| | 506 | |
|---|
| | 507 | /*-------------------------------------------------------------------------*/ |
|---|
| | 508 | /* Stream IO */ |
|---|
| | 509 | |
|---|
| | 510 | template <class FieldT> |
|---|
| | 511 | inline void |
|---|
| | 512 | DynamicEditMFCPointerFieldHandle<FieldT>::pushValueToStream( |
|---|
| | 513 | OutStream &str) const |
|---|
| | 514 | { |
|---|
| | 515 | FWARNING(("DynamicEditMFCPointerFieldHandle<FieldT>::pushValueToStream(): NIY\n")); |
|---|
| | 516 | } |
|---|
| | 517 | |
|---|
| | 518 | template <class FieldT> |
|---|
| | 519 | inline void |
|---|
| | 520 | DynamicEditMFCPointerFieldHandle<FieldT>::pushSizeToStream( |
|---|
| | 521 | OutStream &str) const |
|---|
| | 522 | { |
|---|
| | 523 | FWARNING(("DynamicEditMFCPointerFieldHandle<FieldT>::pushSizeToStream(): NIY\n")); |
|---|
| | 524 | } |
|---|
| | 525 | |
|---|
| | 526 | template <class FieldT> |
|---|
| | 527 | inline void |
|---|
| | 528 | DynamicEditMFCPointerFieldHandle<FieldT>::pushValueFromCString( |
|---|
| | 529 | Char8 const *str) |
|---|
| | 530 | { |
|---|
| | 531 | FWARNING(("DynamicEditMFCPointerFieldHandle<FieldT>::pushValueFromCString()\n")); |
|---|
| | 532 | } |
|---|
| | 533 | |
|---|
| | 534 | /*-------------------------------------------------------------------------*/ |
|---|
| | 535 | /* Generic Operations */ |
|---|
| | 536 | |
|---|
| | 537 | template <class FieldT> |
|---|
| | 538 | inline bool |
|---|
| | 539 | DynamicEditMFCPointerFieldHandle<FieldT>::equal(EditFieldHandlePtr rhs) |
|---|
| | 540 | { |
|---|
| | 541 | FWARNING(("DynamicEditMFCPointerFieldHandle<FieldT>::equal(): NIY\n")); |
|---|
| | 542 | } |
|---|
| | 543 | |
|---|
| | 544 | template <class FieldT> |
|---|
| | 545 | inline void |
|---|
| | 546 | DynamicEditMFCPointerFieldHandle<FieldT>::copyValues(GetFieldHandlePtr source) |
|---|
| | 547 | { |
|---|
| | 548 | FWARNING(("DynamicEditMFCPointerFieldHandle<FieldT>::copyValues(): NIY\n")); |
|---|
| | 549 | } |
|---|
| | 550 | |
|---|
| | 551 | template <class FieldT> |
|---|
| | 552 | inline void |
|---|
| | 553 | DynamicEditMFCPointerFieldHandle<FieldT>::shareValues(GetFieldHandlePtr source) |
|---|
| | 554 | { |
|---|
| | 555 | FWARNING(("DynamicEditMFCPointerFieldHandle<FieldT>::shareValues(): NIY\n")); |
|---|
| | 556 | } |
|---|
| | 557 | |
|---|
| | 558 | template <class FieldT> |
|---|
| | 559 | inline void |
|---|
| | 560 | DynamicEditMFCPointerFieldHandle<FieldT>::cloneValues( |
|---|
| | 561 | GetFieldHandlePtr pSrc, |
|---|
| | 562 | TypePtrVector const &shareTypes, |
|---|
| | 563 | TypePtrVector const &ignoreTypes, |
|---|
| | 564 | TypeIdVector const &shareGroupIds, |
|---|
| | 565 | TypeIdVector const &ignoreGroupIds) const |
|---|
| | 566 | { |
|---|
| | 567 | FWARNING(("DynamicEditMFCPointerFieldHandle<FieldT>::cloneValues(): NIY\n")); |
|---|
| | 568 | } |
|---|
| | 569 | |
|---|
| | 570 | /*-------------------------------------------------------------------------*/ |
|---|
| | 571 | /* Operations */ |
|---|
| | 572 | |
|---|
| | 573 | template <class FieldT> |
|---|
| | 574 | inline UInt32 |
|---|
| | 575 | DynamicEditMFCPointerFieldHandle<FieldT>::size(void) const |
|---|
| | 576 | { |
|---|
| | 577 | return castFieldDown()->size(); |
|---|
| | 578 | } |
|---|
| | 579 | |
|---|
| | 580 | template <class FieldT> |
|---|
| | 581 | inline FieldContainer * |
|---|
| | 582 | DynamicEditMFCPointerFieldHandle<FieldT>::get(UInt32 const uiIndex) const |
|---|
| | 583 | { |
|---|
| | 584 | return castPtrUp((*castFieldDown())[uiIndex]); |
|---|
| | 585 | } |
|---|
| | 586 | |
|---|
| | 587 | template <class FieldT> |
|---|
| | 588 | inline void |
|---|
| | 589 | DynamicEditMFCPointerFieldHandle<FieldT>::add(FieldContainer * const pNewElement) |
|---|
| | 590 | { |
|---|
| | 591 | HandledFieldValueType pTypedNewElement = |
|---|
| | 592 | dynamic_cast<HandledFieldValueType>(pNewElement); |
|---|
| | 593 | |
|---|
| | 594 | if(pTypedNewElement != NULL) |
|---|
| | 595 | { |
|---|
| | 596 | castFieldDown()->push_back(pTypedNewElement); |
|---|
| | 597 | } |
|---|
| | 598 | } |
|---|
| | 599 | |
|---|
| | 600 | template <class FieldT> |
|---|
| | 601 | inline void |
|---|
| | 602 | DynamicEditMFCPointerFieldHandle<FieldT>::sub(UInt32 const uiIndex) |
|---|
| | 603 | { |
|---|
| | 604 | if(uiIndex < castFieldDown()->size()) |
|---|
| | 605 | { |
|---|
| | 606 | typename HandledFieldType::iterator vI = |
|---|
| | 607 | castFieldDown()->begin() + index; |
|---|
| | 608 | |
|---|
| | 609 | castFieldDown()->erase(vI); |
|---|
| | 610 | } |
|---|
| | 611 | } |
|---|
| | 612 | |
|---|
| | 613 | template <class FieldT> |
|---|
| | 614 | inline void |
|---|
| | 615 | DynamicEditMFCPointerFieldHandle<FieldT>::sub(FieldContainer * const pOldElement) |
|---|
| | 616 | { |
|---|
| | 617 | HandledFieldValueType pTypedOldElement = |
|---|
| | 618 | dynamic_cast<HandledFieldValueType>(pOldElement); |
|---|
| | 619 | |
|---|
| | 620 | if(pTypedOldElement != NULL) |
|---|
| | 621 | { |
|---|
| | 622 | typename HandledFieldType::iterator vI = |
|---|
| | 623 | castFieldDown()->find(pTypedOldElement); |
|---|
| | 624 | |
|---|
| | 625 | if(vI != castFieldDown()->end()) |
|---|
| | 626 | { |
|---|
| | 627 | castFieldDown()->erase(vI); |
|---|
| | 628 | } |
|---|
| | 629 | } |
|---|
| | 630 | } |
|---|
| | 631 | |
|---|
| | 632 | template <class FieldT> |
|---|
| | 633 | inline void |
|---|
| | 634 | DynamicEditMFCPointerFieldHandle<FieldT>::insert( |
|---|
| | 635 | UInt32 const uiIndex, |
|---|
| | 636 | FieldContainer * const pNewElement) |
|---|
| | 637 | { |
|---|
| | 638 | HandledFieldValueType pTypedNewElement = |
|---|
| | 639 | dynamic_cast<HandledFieldValueType>(pNewElement); |
|---|
| | 640 | |
|---|
| | 641 | if((pTypedNewElement != NULL) && (uiIndex < castFieldDown()->size)) |
|---|
| | 642 | { |
|---|
| | 643 | typename HandledFieldType::iterator vI = |
|---|
| | 644 | castFieldDown()->begin() + uiIndex; |
|---|
| | 645 | |
|---|
| | 646 | castFieldDown()->insert(vI, pTypedNewElement); |
|---|
| | 647 | } |
|---|
| | 648 | } |
|---|
| | 649 | |
|---|
| | 650 | template <class FieldT> |
|---|
| | 651 | inline void |
|---|
| | 652 | DynamicEditMFCPointerFieldHandle<FieldT>::replace( |
|---|
| | 653 | UInt32 const uiIndex, |
|---|
| | 654 | FieldContainer * const pNewElement) |
|---|
| | 655 | { |
|---|
| | 656 | HandledFieldValueType pTypedNewElement = |
|---|
| | 657 | dynamic_cast<HandledFieldValueType>(pNewElement); |
|---|
| | 658 | |
|---|
| | 659 | if((pTypedNewElement != NULL) && (uiIndex < castFieldDown()->size)) |
|---|
| | 660 | { |
|---|
| | 661 | typename HandledFieldType::iterator vI = |
|---|
| | 662 | castFieldDown()->begin() + uiIndex; |
|---|
| | 663 | |
|---|
| | 664 | *vI = pTypedNewElement; |
|---|
| | 665 | } |
|---|
| | 666 | } |
|---|
| | 667 | |
|---|
| | 668 | template <class FieldT> |
|---|
| | 669 | inline void |
|---|
| | 670 | DynamicEditMFCPointerFieldHandle<FieldT>::replace( |
|---|
| | 671 | FieldContainer * const pOldElement, |
|---|
| | 672 | FieldContainer * const pNewElement) |
|---|
| | 673 | { |
|---|
| | 674 | HandledFieldValueType pTypedOldElement = |
|---|
| | 675 | dynamic_cast<HandledFieldValueType>(pOldElement); |
|---|
| | 676 | HandledFieldValueType pTypedNewElement = |
|---|
| | 677 | dynamic_cast<HandledFieldValueType>(pNewElement); |
|---|
| | 678 | |
|---|
| | 679 | if((pTypedOldElement != NULL) && (pTypedNewElement != NULL)) |
|---|
| | 680 | { |
|---|
| | 681 | typename HandledFieldType::iterator vI = |
|---|
| | 682 | castFieldDown()->find(pTypedOldElement); |
|---|
| | 683 | |
|---|
| | 684 | if(vI != castFieldDown()->end()) |
|---|
| | 685 | { |
|---|
| | 686 | *vI = pTypedNewElement; |
|---|
| | 687 | } |
|---|
| | 688 | } |
|---|
| | 689 | } |
|---|
| | 690 | |
|---|
| | 691 | template <class FieldT> |
|---|
| | 692 | inline void |
|---|
| | 693 | DynamicEditMFCPointerFieldHandle<FieldT>::clear(void) |
|---|
| | 694 | { |
|---|
| | 695 | castFieldDown()->clear(); |
|---|
| | 696 | } |
|---|
| | 697 | |
|---|
| | 698 | /*-------------------------------------------------------------------------*/ |
|---|
| | 699 | /* Typed Operations */ |
|---|
| | 700 | |
|---|
| | 701 | template <class FieldT> |
|---|
| | 702 | inline typename |
|---|
| | 703 | DynamicEditMFCPointerFieldHandle<FieldT>::HandledFieldType * |
|---|
| | 704 | DynamicEditMFCPointerFieldHandle<FieldT>::operator->(void) const |
|---|
| | 705 | { |
|---|
| | 706 | return castFieldDown(); |
|---|
| | 707 | } |
|---|
| | 708 | |
|---|
| | 709 | template <class FieldT> |
|---|
| | 710 | inline typename |
|---|
| | 711 | DynamicEditMFCPointerFieldHandle<FieldT>::HandledFieldType & |
|---|
| | 712 | DynamicEditMFCPointerFieldHandle<FieldT>::operator*(void) const |
|---|
| | 713 | { |
|---|
| | 714 | return *castFieldDown(); |
|---|
| | 715 | } |
|---|
| | 716 | |
|---|
| | 717 | template <class FieldT> |
|---|
| | 718 | inline typename |
|---|
| | 719 | DynamicEditMFCPointerFieldHandle<FieldT>::HandledFieldType const * |
|---|
| | 720 | DynamicEditMFCPointerFieldHandle<FieldT>::getField(void) const |
|---|
| | 721 | { |
|---|
| | 722 | return castFieldDown(); |
|---|
| | 723 | } |
|---|
| | 724 | |
|---|
| | 725 | template <class FieldT> |
|---|
| | 726 | inline typename |
|---|
| | 727 | DynamicEditMFCPointerFieldHandle<FieldT>::HandledFieldType * |
|---|
| | 728 | DynamicEditMFCPointerFieldHandle<FieldT>::editField(void) |
|---|
| | 729 | { |
|---|
| | 730 | return castFieldDown(); |
|---|
| | 731 | } |
|---|
| | 732 | |
|---|
| | 733 | |
|---|
| | 734 | |
|---|