// Retrieve desired value bool BondVariable::retrieveAccessor(int i, ReturnValue& rv, bool hasArrayIndex, int arrayIndex) { Messenger::enter("BondVariable::retrieveAccessor"); // Cast 'i' into Accessors enum value if ((i < 0) || (i >= nAccessors)) { printf("Internal Error: Accessor id %i is out of range for Bond type.\n", i); Messenger::exit("BondVariable::retrieveAccessor"); return false; } Accessors acc = (Accessors) i; // Check for correct lack/presence of array index given if ((accessorData[i].arraySize == 0) && hasArrayIndex) { Messenger::print("Error: Unnecessary array index provided for member '%s'.", qPrintable(accessorData[i].name)); Messenger::exit("BondVariable::retrieveAccessor"); return false; } else if ((accessorData[i].arraySize > 0) && (hasArrayIndex)) { if ((arrayIndex < 1) || (arrayIndex > accessorData[i].arraySize)) { Messenger::print("Error: Array index out of bounds for member '%s' (%i, range is 1-%i).", qPrintable(accessorData[i].name), arrayIndex, accessorData[i].arraySize); Messenger::exit("BondVariable::retrieveAccessor"); return false; } } // Get current data from ReturnValue bool result = true; Bond* ptr = (Bond*) rv.asPointer(VTypes::BondData, result); if ((!result) || (ptr == NULL)) { Messenger::print("Invalid (NULL) %s reference encountered.", VTypes::dataType(VTypes::BondData)); result = false; } if (result) switch (acc) { case (BondVariable::I): rv.set(VTypes::AtomData, ptr->atomI()); break; case (BondVariable::J): rv.set(VTypes::AtomData, ptr->atomJ()); break; case (BondVariable::Order): rv.set(ptr->order()); break; case (BondVariable::Type): rv.set(Bond::bondType(ptr->type())); break; default: printf("Internal Error: Access to member '%s' has not been defined in BondVariable.\n", qPrintable(accessorData[i].name)); result = false; break; } Messenger::exit("BondVariable::retrieveAccessor"); return result; }
// Copy bonds for atoms void Clipboard::copyBonds() { Messenger::enter("Clipboard::copyBonds"); // Go through pairs of oldptrs in the atoms list and check for bonds, adding to our list as we go. // The bonds we generate will point to pairs of ClipAtoms. Bond* oldbond; for (ClipAtom* ii = atoms_.first(); ii != NULL; ii = ii->next) { for (ClipAtom* jj = ii->next; jj != NULL; jj = jj->next) { oldbond = ii->atomPointer()->findBond(jj->atomPointer()); if (oldbond != NULL) { ClipBond* b = bonds_.add(); b->setAtoms(ii, jj); b->setType(oldbond->type()); } } } Messenger::exit("Clipboard::copyBonds"); }