Modeling Services > Dynamic Modeling Services > How to Use Dynamic Objects > Dynamic Attributes
 
Dynamic Attributes
A dynamic object has a set of dynamic attributes as declared to the server model interpreter. Rogue Wave® Server instantiates a subclass of IlsDynAttribute as follows:
*IlsDynEntry, whose implementation is an IlsEntry attribute;
*IlsDynDerived, whose implementation is an IlsDerived attribute;
*IlsDynSimpleAttribute, whose implementation is a simple IlsMvValue and does not trigger any notification.
A dynamic attribute can be either of any basic type supported by IlsMvValue or a user-defined type. (See the class IlsMvUserType.)
A dynamic type may also have a set of class attributes (also called static attributes) whose values are shared among all instances of the dynamic type. These static attributes are simple attributes which do not trigger any notification.
You can access a dynamic attribute through the member functions IlsDynObject::setAttributeValue and IlsDynObject::getAttributeValue.
Example
void EditionFunction(IlsViewed& obj)
{
IlsDynObject* dynObj = IlsDynObject::Narrow("Domain", &obj);
if (dynObj) {
IlsString domainName = dynObj->getAttributeValue("name");
IlsString newName = "NewDomainName";
dynObj->setAttributeValue("name", newName);
}
}
Using Derived Dynamic Attributes
When you define a dynamic attribute of type “derived”, Rogue Wave Server automatically assumes that a Rogue Wave Script evaluation function exists to compute its value. The name of this function is:
<class_name>_compute_<attribute_name>
This function will be invoked by Rogue Wave Server each time an up-to-date value is needed for this attribute. If this function does not exist, an error message is displayed when Rogue Wave Server tries to invoke it.
Example
For the derived attribute inputCapacity of class Node, the following evaluation method should be provided:
function Node_compute_inputCapacity(node)
{
var total = 0;
// create an iterator
var i = new IlsServerRelationIterator(node.inputLines);
while (i.next()) {
total = total + i.current.capacity;
}
return total;
}
Note that you can provide a C++ implementation for the evaluation method by using the member function IlsModelInterpreter::DeclDerivedEvaluator.

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.