User defined IS classes may use another
IS classes as types of their attributes. One can still use the OKS
Scheme editor application to define a custom IS class. In order to
explore the new functionality one can use OKS relationships for that
class, which will appear as attributes of respective classes in the
generated C++ or Java code. If OKS Cardinality Constraint defined for
an IS class relationship is "ONE" then a single value attribute of the
respective class will be generated. For any Cardinality Constraint
value other the "ONE" a multi-value attribute will be declared, e.g.
std::vector of the respective type in C++ class. To see an example one
can have a look to the
Online
Histogramming XML file.
Compatibility Note: There
are no incompatible changes in the public API with respect to
this new feature. The old code, which is using IS, shall compile and
function properly if it is used with old IS custom types (i.e. with
types, which don't contain complex attributes).
Missing Functionality Note: There is one restriction for the
applications of the new functionality. An IS information class
attribute can not be of the same type as one in which it is declared as
well as of any subtype of this type. For example class Person, which is
declared as having an attribute of class Child would be invalid if
class Child inherits from the class Person. The class Person would be
invalid as well (from the IS point of view) is it defines for example
an attribute "conjoint" of class Person.
User's code, which is using an instance of ISInfoAny class to read and
parse an arbitrary IS information, requires some modifications, if it
can deal with the new complex IS information objects. Such code has to
accept a new type code value as a result of the
ISInfoAny::getAttributeType function. This new value is an additional
one defined in the ISType::Basic enumeration and it has the following
name ISType::InfoObject. Example below shows how the code, which parses
an ISInfoAny can be implemented using recursive function invocation.
This example is not very practical, but it illustrates the approach to
writing ISInfoAny parsing code.
void printInfoAny( ISInfoAny
& isa )
{
printInfoAnyHelper(
isa, isa.type() );
}
void printInfoAnyHelper( ISInfoAny
& isa, ISType & type )
{
for (
size_t pos = 0; pos < type.entries(); pos++ )
{
ISType::Basic
typecode = type.entryType( pos );
if (
typecode
== ISType::InfoObject )
{
if ( type.entryArray( pos ) )
{
size_t size =
isa.readArraySize( );
for( size_t i = 0; i <
size; i++ )
{
printInfoAnyHelper( isa, type.entryInfoType( pos ) );
}
}
else
{
printInfoAnyHelper(
isa,
type.entryInfoType( pos ) );
}
}
else
{
//
process simple attributes in the
same way as with the previous IS versions
...
}
}
}
|
The new IS API allows to use different
types of callbacks for the ISInfoReceiver::subscribe functions.
Previous IS versions support only global C-style functions or static
class member functions as callbacks. The new version of the IS supports
the following types of callbacks:
- Global C-style functions or static class member functions are
still supported for backward compatibility.
- An instance of a class, which defines void operator()(
ISCallbackInfo * ). This operator will be called when a
subscribed event occurs.
- A combination of an instance of a class with the address of the
member function of that class, which has the following syntax: void XXX(
ISCallbackInfo * )
Below there are some examples, which show how to use the new
subscription facilities: