const component type& getcomponent()
getcomponent()
, where
component is the name of the component that the extractor will
access. The component is returned by constant reference as the value of
the function. Thus you can use the getcomponent()
function
in any term except you may not modify the returned object.
result setcomponent(component type&)
If you want to modify a component of an object, you have to
getcomponent()
the object first, assigning it to a variable.
Then modify this variable and finally write the variable back to the
outer object with setcomponent()
. It would be not correct to
allow modifying access to parts of an object directly, because this
would violate encapsulation of data. On the other hand it results in
quite ugly code. Suppose you want to set the first name of a patient in
an ADT message. Instead of writing something like this:
ACKmsg ack; ack.PatIde.PatName.FirstName = "Peter";
You must break the assignment term down into the following sequence:
ACKmsg ack; PIDseg pid = ack.getPatIde(); PNtyp pn = pid.getPatName(); pn.setFirstName("Peter"); pid.setPatName(pn); ack.setPatIde(pid);