Prev Up Next Index
Go backward to 3.1.2 Sub-classing the Vector Types
Go up to 3.1 Sub-classing the Type Hierarchy
Go forward to 3.2 Sub-classing the Connect Class

3.1.3 Sub-classing the Compound Types

The read member function of the compound data types simply iterates over the contained variables calling their read member functions. In the future, this definition will move into the supplied classes (That is, read will no longer be a abstract member function for the compound types.).

The two constructor types Sequence and Function are different from all the other types in the DAP in that they have state. That is, the value of a sequence depends on how many values have been read previously. This is very different from an array where the ith element has the same value regardless of what has happened before. When you write implementations for read in the Sequence and Function classes, you must be sure to write those member functions so that they can be called repeatedly and that each call to read returns the next value of the corresponding data Sequence or Function.

This is true because the constraint expression evaluator must be able to apply certain constraints to values of individual sequence elements and is actually implemented in the DDS class by first calling the read member function, evaluating the constraint expression based on the values and, if they constraint expression is satisfied, calling the serialize member function. See the member function DDS::send (See section 4.3.1 for more information on evaluation of constraint expressions).

If, for some reason, it is not possible to write read so that it gets called once for each sequence value6, then you must re-implement DDS::send so that its functions are performed. For example, you could implement Sequence::read so that the entire sequence is read in and overload Sequence::serialize and Sequence::deserialize so that the next set of values are sent/received. You would then build a send that called the Sequence::read member function once and extracted each successive value, evaluated the constraint expression using on that value and used the result of that evaluation to determine whether to send the value or not.


Tom Sgouros, July 2, 2004

Prev Up Next