Example #1
0
// Perform desired function
bool BondVariable::performFunction(int i, ReturnValue& rv, TreeNode* node)
{
	Messenger::enter("BondVariable::performFunction");
	// Cast 'i' into Accessors enum value
	if ((i < 0) || (i >= nFunctions))
	{
		printf("Internal Error: FunctionAccessor id %i is out of range for Bond type.\n", i);
		Messenger::exit("BondVariable::performFunction");
		return false;
	}
	// Get current data from ReturnValue
	bool result = true;
	Bond* ptr = (Bond*) rv.asPointer(VTypes::BondData, result);
	if (result) switch (i)
	{
		case (BondVariable::Partner):
			rv.set(VTypes::AtomData, ptr->partner( (Atom*) node->argp(0, VTypes::AtomData)));
			break;
		default:
			printf("Internal Error: Access to function '%s' has not been defined in BondVariable.\n", qPrintable(functionData[i].name));
			result = false;
			break;
	}
	Messenger::exit("BondVariable::performFunction");
	return result;
}