1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941
|
/*****************************************************************************
*
* Copyright (c) 2000 - 2010, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-400124
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the LLNS/LLNL nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
* LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
// ************************************************************************* //
// AttributeSubjectMap.C //
// ************************************************************************* //
#include <AttributeSubject.h>
#include <AttributeSubjectMap.h>
#include <DataNode.h>
#include <limits.h>
#define MAP_INCR 4
// ****************************************************************************
// Method: AttributeSubjectMap constructor
//
// Programmer: Eric Brugger
// Creation: November 15, 2002
//
// ****************************************************************************
AttributeSubjectMap::AttributeSubjectMap()
{
nIndices = 0;
maxIndices = MAP_INCR;
atts = new AttributeSubject*[MAP_INCR];
indices = new int[MAP_INCR];
for(int i = 0; i < MAP_INCR; ++i)
{
atts[i] = 0;
indices[i] = 0;
}
}
// ****************************************************************************
// Method: AttributeSubjectMap::AttributeSubjectMap
//
// Purpose:
// Copy constructor.
//
// Arguments:
// obj : The object to copy.
//
// Programmer: Brad Whitlock
// Creation: Tue Dec 30 17:05:04 PST 2003
//
// Modifications:
//
// ****************************************************************************
AttributeSubjectMap::AttributeSubjectMap(const AttributeSubjectMap &obj)
{
int i;
nIndices = obj.nIndices;
maxIndices = obj.maxIndices;
atts = new AttributeSubject*[maxIndices];
indices = new int[maxIndices];
for(i = 0; i < nIndices; ++i)
{
atts[i] = obj.atts[i]->NewInstance(true);
indices[i] = obj.indices[i];
}
for(i = nIndices; i < maxIndices; ++i)
{
atts[i] = 0;
indices[i] = 0;
}
}
// ****************************************************************************
// Method: AttributeSubjectMap destructor
//
// Programmer: Eric Brugger
// Creation: November 15, 2002
//
// ****************************************************************************
AttributeSubjectMap::~AttributeSubjectMap()
{
int i;
for (i = 0; i < nIndices; ++i)
{
delete atts[i];
}
if (maxIndices > 0)
{
delete [] atts;
delete [] indices;
}
}
// ****************************************************************************
// Method: AttributeSubjectMap::operator =
//
// Purpose:
// Assignment operator.
//
// Arguments:
// obj : The object to copy.
//
// Programmer: Brad Whitlock
// Creation: Tue Dec 30 17:05:42 PST 2003
//
// Modifications:
//
// ****************************************************************************
void
AttributeSubjectMap::operator =(const AttributeSubjectMap &obj)
{
int i;
for(i = 0; i < nIndices; ++i)
delete atts[i];
delete [] atts;
nIndices = obj.nIndices;
maxIndices = obj.maxIndices;
atts = new AttributeSubject*[maxIndices];
indices = new int[maxIndices];
for(i = 0; i < nIndices; ++i)
{
atts[i] = obj.atts[i]->NewInstance(true);
indices[i] = obj.indices[i];
}
for(i = nIndices; i < maxIndices; ++i)
{
atts[i] = 0;
indices[i] = 0;
}
}
// ****************************************************************************
// Method: AttributeSubjectMap::SetAtts
//
// Purpose:
// Set the attributes for the entire AttributeSubjectMap. The map will
// consist of a single entry with the attributes defined at index 0.
//
// Arguments:
// attr The attribute subject to store.
//
// Programmer: Eric Brugger
// Creation: December 27, 2002
//
// ****************************************************************************
void
AttributeSubjectMap::SetAtts(const AttributeSubject *attr)
{
//
// If we have at least one entry in the map, then delete all but the
// first one, and set its index to 0.
//
if (nIndices > 0)
{
int i;
for (i = 1; i < nIndices; ++i)
{
delete atts[i];
}
indices[0] = 0;
nIndices = 1;
}
//
// Set the attributes at index 0.
//
int i0, i1;
SetAtts(0, attr, i0, i1);
}
// ****************************************************************************
// Method: AttributeSubjectMap::SetAtts
//
// Purpose:
// Set the attributes for the AttributeSubjectMap at the specified index.
//
// Arguments:
// index The index to store the attribute subject at.
// attr The attribute subject to store.
//
// Programmer: Eric Brugger
// Creation: November 15, 2002
//
// ****************************************************************************
void
AttributeSubjectMap::SetAtts(const int index, const AttributeSubject *attr)
{
int i0, i1;
SetAtts(index, attr, i0, i1);
}
// ****************************************************************************
// Method: AttributeSubjectMap::SetAttsLe
//
// Purpose:
// Set the attributes for the AttributeSubjectMap at the index that is
// nearest to but less then or equal to the specified index
//
// Arguments:
// index The given index
// attr The attribute subject to store.
//
// Programmer: Mark C. Miller
// Creation: March 25, 2004
//
// ****************************************************************************
void
AttributeSubjectMap::SetAttsLe(const int index, const AttributeSubject *attr)
{
// find an index that is less than or equal to the given index
int i, i0, i1;
for (i = 0; i < nIndices && indices[i] <= index; ++i);
SetAtts(i, attr, i0, i1);
}
// ****************************************************************************
// Method: AttributeSubjectMap::SetAtts
//
// Purpose:
// Set the attributes in the AttributeSubjectMap at the specified index
// and return the range of the plots invalided by the operation.
//
// Arguments:
// index The index to store the attribute subject at.
// attr The attribute subject to store.
// i0 The returned index of the first attribute invalidated.
// The argument will contain 0 if it extends to the
// beginning of the range.
// i1 The returned index of the last attribute invalidated.
// The argument will contain INT_MAX if it extends to the
// end of the range.
//
// Programmer: Eric Brugger
// Creation: November 15, 2002
//
// Modifications:
// Brad Whitlock, Wed Jul 23 11:25:12 PDT 2003
// Made it use NewInstance.
//
// ****************************************************************************
void
AttributeSubjectMap::SetAtts(const int index, const AttributeSubject *attr,
int &i0, int &i1)
{
int i;
for (i = 0; i < nIndices && indices[i] < index; ++i) ;
//
// If the index matches an existing index exactly then replace
// the attributes for it, otherwise insert it in the list.
//
if (i < nIndices && indices[i] == index)
{
atts[i]->CopyAttributes(attr);
}
else
{
int j;
//
// Increase the length of the list if we need to.
//
if (nIndices == maxIndices)
{
ResizeMap(maxIndices+MAP_INCR);
}
//
// Insert the item in the list.
//
for (j = nIndices; j > i; --j)
{
atts[j] = atts[j-1];
indices[j] = indices[j-1];
}
atts[i] = attr->NewInstance(true);
indices[i] = index;
nIndices++;
}
//
// Determine the range of attributes invalidated.
//
if (i - 1 < 0)
i0 = 0;
else
i0 = indices[i-1] + 1;
if (i + 1 < nIndices)
i1 = indices[i+1] - 1;
else
i1 = INT_MAX;
}
// ****************************************************************************
// Method: AttributeSubjectMap::GetAtts
//
// Purpose:
// Get the attributes in the AttributeSubjectMap at the specified index.
//
// Arguments:
// index The index to retrieve the attribute subject from.
// attr The attribute subject to store the results in.
//
// Programmer: Eric Brugger
// Creation: November 15, 2002
//
// ****************************************************************************
void
AttributeSubjectMap::GetAtts(const int index, AttributeSubject *attr) const
{
int i;
if(nIndices > 0)
{
for (i = 0; i < nIndices && indices[i] <= index; ++i) ;
if (i == 0)
{
attr->CopyAttributes(atts[0]);
}
else if (i == nIndices)
{
attr->CopyAttributes(atts[nIndices-1]);
}
else
{
int i0 = indices[i-1];
int i1 = indices[i];
double f = (double) (index - i0) / (double) (i1 - i0);
attr->InterpolateLinear(atts[i-1], atts[i], f);
}
}
}
// ****************************************************************************
// Method: AttributeSubjectMap::ClearAtts
//
// Purpose:
// Clear the attribute subjects in the map.
//
// Programmer: Eric Brugger
// Creation: January 8, 2003
//
// ****************************************************************************
void
AttributeSubjectMap::ClearAtts()
{
int i;
for (i = 0; i < nIndices; ++i)
{
delete atts[i];
atts[i] = 0;
indices[i] = 0;
}
nIndices = 0;
}
// ****************************************************************************
// Method: AttributeSubjectMap::DeleteAtts
//
// Purpose:
// Delete the attribute subject at the specified index.
//
// Arguments:
// index The index at which to delete the attribute subject.
// i0 The returned index of the first attribute invalidated.
// The argument will contain 0 if it extends to the
// beginning of the range.
// i1 The returned index of the last attribute invalidated.
// The argument will contain INT_MAX if it extends to the
// end of the range.
//
// Returns:
// A boolean indicating if the attribute subject was deleted.
//
// Programmer: Eric Brugger
// Creation: December 23, 2002
//
// ****************************************************************************
bool
AttributeSubjectMap::DeleteAtts(const int index, int &i0, int &i1)
{
//
// If the number of indices in the map is less than or equal to one,
// then return since there must always be at least one index.
//
if (nIndices <= 1)
{
return false;
}
//
// Find the index.
//
int i;
for (i = 0; i < nIndices && indices[i] < index; ++i) ;
//
// If we found a match, then delete the attribute subject at
// the index and compress the list.
//
if (i < nIndices && indices[i] == index)
{
int j;
delete atts[i];
for (j = i; j < nIndices - 1; ++j)
{
indices[j] = indices[j+1];
atts[j] = atts[j+1];
}
nIndices--;
//
// Determine the range of attributes invalidated.
//
if (i - 1 < 0)
i0 = 0;
else
i0 = indices[i-1] + 1;
if (i < nIndices)
i1 = indices[i] - 1;
else
i1 = INT_MAX;
return true;
}
else
{
return false;
}
}
// ****************************************************************************
// Method: AttributeSubjectMap::MoveAtts
//
// Purpose:
// Move the position of an attribute subject.
//
// Arguments:
// oldIndex The old index of the attribute subject.
// newIndex The new index of the attribute subject.
// i0 The returned index of the first attribute invalidated.
// The argument will contain 0 if it extends to the
// beginning of the range.
// i1 The returned index of the last attribute invalidated.
// The argument will contain INT_MAX if it extends to the
// end of the range.
//
// Returns:
// A boolean indicating if the attribute subject was moved.
//
// Programmer: Eric Brugger
// Creation: January 28, 2003
//
// ****************************************************************************
bool
AttributeSubjectMap::MoveAtts(int oldIndex, int newIndex, int &i0, int &i1)
{
//
// If the old and new index are the same, do nothing.
//
if (oldIndex == newIndex)
{
return false;
}
//
// Find the old index.
//
int i;
for (i = 0; i < nIndices && indices[i] < oldIndex; ++i) ;
//
// If we found a match, then delete the attribute subject at
// the index, compress the list, and set the attributes at
// the new spot.
//
if (i < nIndices && indices[i] == oldIndex)
{
AttributeSubject *attr = atts[i];
int j;
for (j = i; j < nIndices - 1; ++j)
{
indices[j] = indices[j+1];
atts[j] = atts[j+1];
}
nIndices--;
//
// Determine the range of attributes invalidated.
//
if (i - 1 < 0)
i0 = 0;
else
i0 = indices[i-1] + 1;
if (i < nIndices)
i1 = indices[i] - 1;
else
i1 = INT_MAX;
//
// Set the attributes at the new location.
//
int i2, i3;
SetAtts(newIndex, attr, i2, i3);
//
// Update the range of attributes invalidated.
//
i0 = i0 < i2 ? i0 : i2;
i1 = i1 > i3 ? i1 : i3;
return true;
}
else
{
return false;
}
}
// ****************************************************************************
// Method: AttributeSubjectMap::GetNIndices
//
// Purpose:
// Get the number of indices in the map.
//
// Returns:
// The number of indices in the map.
//
// Programmer: Eric Brugger
// Creation: January 7, 2003
//
// ****************************************************************************
int
AttributeSubjectMap::GetNIndices() const
{
return nIndices;
}
// ****************************************************************************
// Method: AttributeSubjectMap::GetIndices
//
// Purpose:
// Get the indices associated with the map.
//
// Arguments:
// nIndices_ The number of indices in the map.
//
// Returns:
// The indices in the map.
//
// Programmer: Eric Brugger
// Creation: November 15, 2002
//
// ****************************************************************************
const int *
AttributeSubjectMap::GetIndices(int &nIndices_) const
{
nIndices_ = nIndices;
return indices;
}
// ****************************************************************************
// Method: AttributeSubjectMap::CreateCompatible
//
// Purpose:
// Return a compatible attribute subject.
//
// Arguments:
// tname The name of the attribute subject. Used as a consistency
// check.
//
// Returns:
// The compatible attribute subject.
//
// Programmer: Eric Brugger
// Creation: November 15, 2002
//
// ****************************************************************************
AttributeSubject *
AttributeSubjectMap::CreateCompatible(const std::string &tname) const
{
//
// If we don't have any attributes, we can't return a compatible.
//
if (nIndices <= 0)
return NULL;
return atts[0]->CreateCompatible(tname);
}
// ****************************************************************************
// Method: AttributeSubjectMap::CopyAttributes
//
// Purpose:
// Copies the attributes into the current object and returns whether or not
// the attributes were copied.
//
// Arguments:
// attr The attributes that we want to copy into the current object.
//
// Returns:
// A boolean indicating if the attributes were copied.
//
// Programmer: Eric Brugger
// Creation: December 10, 2002
//
// Modifications:
// Brad Whitlock, Fri Dec 20 15:17:52 PST 2002
// I made it return true.
//
// ****************************************************************************
bool
AttributeSubjectMap::CopyAttributes(const AttributeSubjectMap *attr)
{
//
// If we don't have any attributes, we can't copy them.
//
if (nIndices <= 0 || attr == NULL || attr->nIndices <= 0)
return false;
//
// Try copying the first attributes to determine if the individual
// attributes can be copied.
//
if (!atts[0]->CopyAttributes(attr->atts[0]))
return false;
indices[0] = attr->indices[0];
//
// Resize the map if necessary.
//
if (maxIndices < attr->nIndices)
{
ResizeMap(attr->maxIndices);
}
//
// Copy the map. Delete any excess AttributeSubjects if there were
// fewer indices in the source than in the destination.
//
int i;
for (i = 1; i < attr->nIndices; ++i)
{
if (i >= nIndices)
atts[i] = attr->CreateCompatible(attr->atts[i]->TypeName());
atts[i]->CopyAttributes(attr->atts[i]);
indices[i] = attr->indices[i];
}
for (; i < nIndices; ++i)
{
delete atts[i];
}
nIndices = attr->nIndices;
return true;
}
// ****************************************************************************
// Method: AttributeSubjectMap::ResizeMap
//
// Purpose:
// Resizes the attribute subject map to be the new size.
//
// Arguments:
// newSize The new size of the attribute subject map.
//
// Programmer: Eric Brugger
// Creation: December 10, 2002
//
// ****************************************************************************
void
AttributeSubjectMap::ResizeMap(const int newSize)
{
//
// It is illegal to set the new the new size less than the current
// number of indices, so return if that is the case.
//
if (newSize < nIndices)
return;
AttributeSubject **atts2 = new AttributeSubject*[newSize];
int *indices2 = new int[newSize];
int i;
for (i = 0; i < nIndices; ++i)
{
atts2[i] = atts[i];
indices2[i] = indices[i];
}
delete [] atts;
delete [] indices;
atts = atts2;
indices = indices2;
maxIndices = newSize;
}
// ****************************************************************************
// Method: AttributeSubjectMap::CreateNode
//
// Purpose:
// Saves the AttributeSubjectMap to a DataNode.
//
// Arguments:
// parentNode : The node to which the map will be saved.
//
// Programmer: Brad Whitlock
// Creation: Tue Jul 22 11:32:17 PDT 2003
//
// Modifications:
// Brad Whitlock, Thu Dec 18 11:16:03 PDT 2003
// I made it call CreateNode with the new completeSave flag set to true.
//
// ****************************************************************************
bool
AttributeSubjectMap::CreateNode(DataNode *parentNode)
{
bool retval = false;
if(parentNode == 0)
return retval;
if(nIndices > 0)
{
DataNode *mapNode = new DataNode("AttributeSubjectMap");
parentNode->AddNode(mapNode);
// Add the indices.
intVector ids;
int i;
for(i = 0; i < nIndices; ++i)
ids.push_back(indices[i]);
mapNode->AddNode(new DataNode("indices", ids));
// Add the attributes.
DataNode *attNode = new DataNode("attributes");
mapNode->AddNode(attNode);
for(i = 0; i < nIndices; ++i)
atts[i]->CreateNode(attNode, true, true);
retval = true;
}
return retval;
}
// ****************************************************************************
// Method: AttributeSubjectMap::SetFromNode
//
// Purpose:
// Initializes the map using the data in the config file.
//
// Arguments:
// parentNode : The data node that will be used to initialize the map.
// factoryObj : The object that we use to create new instances of attributes.
//
// Programmer: Brad Whitlock
// Creation: Tue Jul 22 11:33:21 PDT 2003
//
// Modifications:
//
// ****************************************************************************
void
AttributeSubjectMap::SetFromNode(DataNode *parentNode,
AttributeSubject *factoryObj)
{
//
// Clear the attributes.
//
ClearAtts();
//
// Look for the required nodes.
//
if(parentNode == 0)
return;
DataNode *mapNode = parentNode->GetNode("AttributeSubjectMap");
if(mapNode == 0)
return;
DataNode *indicesNode = mapNode->GetNode("indices");
if(indicesNode == 0)
return;
DataNode *attsNode = mapNode->GetNode("attributes");
if(attsNode == 0)
return;
//
// Now that we have all of the nodes that we need, read in the objects
// and add them to the "map".
//
const intVector &iv = indicesNode->AsIntVector();
DataNode **attsObjects = attsNode->GetChildren();
const int numAtts = attsNode->GetNumChildren();
for(int i = 0; i < iv.size(); ++i)
{
if(i < numAtts)
{
// Create a fresh AttributeSubject so that its fields are
// initialized to the default values and not those last read in.
AttributeSubject *reader = factoryObj->NewInstance(false);
// Initialize the object using the data node.
reader->SetFromNode(attsObjects[i]);
// Add the object to the map.
SetAtts(iv[i], reader);
// delete the reader object.
delete reader;
}
}
}
// ****************************************************************************
// Method: AttributeSubjectMap::ProcessOldVersions
//
// Purpose:
// Initializes the map using the data in the config file.
//
// Arguments:
// parentNode : The data node that will be used to initialize the map.
// configVersion : The version from the config file.
// obj : The object that we use to create new instances of attributes.
//
// Programmer: Brad Whitlock
// Creation: Wed Feb 13 14:43:42 PST 2008
//
// Modifications:
//
// ****************************************************************************
void
AttributeSubjectMap::ProcessOldVersions(DataNode *parentNode,
const std::string &configVersion, AttributeSubject *obj)
{
//
// Look for the required nodes.
//
if(parentNode == 0)
return;
DataNode *mapNode = parentNode->GetNode("AttributeSubjectMap");
if(mapNode == 0)
return;
DataNode *indicesNode = mapNode->GetNode("indices");
if(indicesNode == 0)
return;
DataNode *attsNode = mapNode->GetNode("attributes");
if(attsNode == 0)
return;
//
// Now that we have all of the nodes that we need, process old versions
// of each of the input data nodes.
//
const intVector &iv = indicesNode->AsIntVector();
DataNode **attsObjects = attsNode->GetChildren();
const int numAtts = attsNode->GetNumChildren();
for(int i = 0; i < iv.size(); ++i)
{
if(i < numAtts)
obj->ProcessOldVersions(attsObjects[i], configVersion.c_str());
}
}
|