Rogue Wave Views 5.6 |
Rogue Wave Views |
Rogue Wave Views Documentation Home |
Application Framework interface class. More...
#include <ilviews/appframe/interf.h>
Public Member Functions | |
IlBoolean | callMethod (const IlSymbol *methodName, IlvDvValue *returnedValue,...) |
Generic method for calling a method that is exported in a class interface. | |
IlvDvValue & | getFieldValue (const IlSymbol *fieldName, IlvDvValue &value) const |
Gets a field value. | |
virtual IlBoolean | isProcessingAction (const IlSymbol *methodName) const |
Returns IlTrue if the given action can be processed by the class. | |
virtual IlBoolean | processAction (const IlSymbol *actionName) |
Processes an action. | |
virtual IlBoolean | refreshAction (const IlSymbol *actionName, IlvDvActionDescriptor *desc) const |
Refresh all the menu items that reference the action given by the parameter actionName. | |
void | setFieldValue (const IlSymbol *fieldName, const IlvDvValue &value) |
Sets a field value. |
Application Framework interface class.
Library: ilvappframe
Application Framework provides an introspection mechanism that allows a C++ class to:
getFieldValue(fieldName)
and setFieldValue(fieldName, value)
, callMethod(methodName, values)
.This mechanism provides the following advantages:
To be introspected, a class must both inherit from the IlvDvInterface
class and add some macros in its declaration and its implementation file.
Here is a sample of how to use Application Framework introspection:
// Delaration of A class A : public IlvDvInterface { public: void setX(int x) { _x = x; } int getX() const { return _x; } protected: int _x; }; // Implementation file of A; use these macros to // introspect methods setX, getX, and field _x. IlvDvBeginInterface(A) Method1(SetX, setX) TypedMethod (GetX, getX) Field(X, _x) IlvDvEndInterface() ... // *********************************************************** // How to use introspection // Using an instance of A as an interface, it is possible // to invoke its methods and to modify its field // without being aware of class A !!! A* a = new A; IlvDvInterface* interf = a; // First we invoke its methods IlvDvValue returnedValue; interf->callMethod(IlGetSymbol("SetX"), &returnedValue, 100); interf->callMethod(IlGetSymbol("GetX"), &returnedValue); assert((IlInt) returnedValue == 100); // Then we modify its field directly interf->setFieldValue(IlGetSymbol("X"), 200); assert((IlInt)interf-> getFieldValue(IlGetSymbol("X"), &returnedValue) == 200);
Naming Convention for Macros Used for Scripting and Introspection
The root of the macro name must be Method
. If the declared method returns a value, the macro must begin with prefix Typed
.
If the declared method contains arguments, the macro must end with the suffix number equal to the number of parameters of the method.
Here are some macro samples:
IlFloat getPosition() const
will be declared TypedMethod(GetPosition, getPosition, IlFloat)
in the interface table. const char* set(int)
will be declared TypedMethod1(Set, set, int, ExportedFirstParameterName, const char*)
in the interface table. void setPosition(int x, int y)
will be declared Method2(SetPosition, setPosition, int, X, int, Y)
in the interface table. IlBoolean IlvDvInterface::callMethod | ( | const IlSymbol * | methodName, | |
IlvDvValue * | returnedValue, | |||
... | ||||
) |
Generic method for calling a method that is exported in a class interface.
Calls a method that is exported in the interface table of the class by using the macro xxxMethodxxx(externalName, method,...)
. The externalName
corresponds to the methodName parameter.
returnedValue | The returned value of the called method is stored in this parameter. If the type of the called method is void , this field is not filled. |
IlTrue
if the C++ method is called. IlvDvValue& IlvDvInterface::getFieldValue | ( | const IlSymbol * | fieldName, | |
IlvDvValue & | value | |||
) | const |
Gets a field value.
Gets the value of the field declared in the interface table with an external name that is equal to the fieldName parameter. The value is set in the value parameter.
virtual IlBoolean IlvDvInterface::isProcessingAction | ( | const IlSymbol * | methodName | ) | const [virtual] |
Returns IlTrue
if the given action can be processed by the class.
IlTrue
if the given action can be processed by the class. Reimplemented in IlvDvDocTemplate.
Processes an action.
Tries to process the action given by the parameter actionName. If a macro Action(actionName, actionMethod)
is inserted in the interface table of the class with a specified external name equal to the actionName parameter, the processAction
method will automatically call the actionMethod
method.
IlTrue
if the action is processed. Reimplemented in IlvDvApplication, IlvDvDocTemplate, and IlvDvDockableMainWindow.
virtual IlBoolean IlvDvInterface::refreshAction | ( | const IlSymbol * | actionName, | |
IlvDvActionDescriptor * | desc | |||
) | const [virtual] |
Refresh all the menu items that reference the action given by the parameter actionName.
If a macro RefreshAction(actionName, refreshMethod)
is inserted in the interface table of the class with a specified external name equal to the actionName parameter, the refreshAction
method will automatically call the refreshMethod
method, with desc as the parameter.
All modifications brought to the desc parameter are directly dispatched to all the menu items that reference the action.
IlTrue
if the given action is refreshed. Reimplemented in IlvDvApplication.
void IlvDvInterface::setFieldValue | ( | const IlSymbol * | fieldName, | |
const IlvDvValue & | value | |||
) |
Sets a field value.
Sets the value value to the field that is declared in the interface table with an external name equal to the fieldName parameter.
© Copyright 2012, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.