Modeling Services > Rogue Wave Script Integration > Invoking Member Functions from a Script
 
Invoking Member Functions from a Script
All member functions that have been declared to the server model interpreter are available to a server type manipulated in a script. These functions may have been declared either through the ILS_MEMBER_FUNCTION macros or through the dynamic modeling services. They are known as exported member functions and can be called by the method execCallback of the Rogue Wave Script class IlsRpObject for a component.
When used exclusively on the server side, an exported member function can declare arguments of server types. A script can then pass server objects to this exported function.
Example
Let us assume that the class Network declares the exported function addDomain, which receives a Domain object:
ILS_MEMBER_FUNCTION1(IlsBoolean, Network, addDomain, Domain)
The corresponding C++ method has the following prototype:
class Network : ...
{
public:
IlsBoolean addDomain(IlsMvValue arg)
};
If this function is called from Rogue Wave Script with a Domain object, the instance of IlsMvValue received will contain an IlsSvRef object which holds a non-typed pointer to the server object. You have to do an unsafe cast to retrieve the server object. The IlsSvRef object contains the real type of the received object, so that you can perform type checking on your own.
Example
IlsBoolean
Network::addDomain(IlsMvValue arg)
{
Domain* d = 0;
if (arg.isSvRef()) {
IlsSvRef r = arg.asSvObjectRef();
const IlsObjectType* argType =
IlsModelInterpreter::GetType(r.getTypeName());
if (argType && argType->isSubtypeOf("Domain")) {
d = (Domain*)r.getObject();
}
}
}
Note that you shall not call this kind of member functions from a component by using an exec<>Callback function.

Version 6.3
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.