Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Questions on attributes and structures types

Questions on attributes and structures types 12 Jul 2004 08:36 #6728

  • Antti Hyrkk
  • Antti Hyrkk's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 43
  • Karma: 0
Hello

There are certain things in TTCN-3 attribute usage for which I'd like
some clarification.

Consider the following type definitions:

type integer myInt with { encode "myIntRule" };
type integer myInt2 with { encode "myInt2Rule" };

type record myRecord
{
myInt field1,
myInt2 field2
} with
{
encode "myRecordRule"
}

type record myRecord2
{
myInt field1,
myInt2 field2
} with
{
encode (field1) "myField1Rule";
encode (field2) "myField2Rule"
}

type record myRecord3
{
integer field1,
integer field2
} with
{
encode "myRecord3Rule"
}

if I now send or receive a value of type myRecord, myRecord2 and
myRecord3, what encoding attribute values are present to the codecs?

At decoding, I get decodingHypothesis:

Value decode(in TriMessageType message,
in Type decodingHypothesis)

Now, if I use the method

TString Type::getTypeEncoding()

of decodingHypothesis, what does it return for myRecord, myRecord2 and
myRecord3? There are several possibilities depending on with what the
attributes of structures types are associated.

A)
myRecord: nothing
myRecord2: nothing
myRecord3: nothing

Reasoning:

The attributes of structured types are associated with / propagate to
their fields, the construct itself never has own attributes.

B)
myRecord: "myRecordRule"
myRecord2: nothing
myRecord3: "myRecord3Rule3"

Reasoning:

Structured type can have own attributes, that affect the construct as
whole, and there can be separate attributes for its fields.

C)
myRecord: "myRecordRule"
myRecord2: "myFieldRule", "myField2Rule"
myRecord3: "myRecord3Rule3"

Reasoning:

Clearly this is not possible, since getTypeEncoding returns only one
string.

If A) is correct, then getTypeEncoding() returns always nothing when
applied to a structured type. To get the attributes of the fields, one
needs a method to query for them.

As far as I understand , there is no way to ask for fields attributes of a
type. Simply having a value of type Type of the same type as the field is,
and asking its attribute with getTypeEncoding() is not sufficient enough,
because the value of Type may contain a different encoding attribute than
the field of the same type. In the context of myRecord2, the myInt field1
should be encoded according to "myField1Rule", but if I send a variable
var myInt field1, it should be encoded according to "myIntRule".

If B) is correct, then like in A), a method for reading field attributes
is also needed. The following type definition may also be possible, if the
semantics of non-referenced attribute definition for a structured type is
that the attribute talks about the structure in general, and it does not
override/overwrite any field attributes.

type record myRecord4
{
integer field1,
integer field2
} with
{
encode "<FieldOrder>field1, field2</FieldOrder>";
encode (field1) "<ByteOrder>network</ByteOrder><32bit int>";
encode (field2) "<ByteOrder>little-endian</ByteOrder><16bit int>"
}

That could be interpreted by a codec as "Field1 should be encoded first,
then field2. Field1 should be encoded into 32 bits in network byte order,
field2 into 16 bits in little endian order".


What is the difference between having an override-directive or a
referenced attribute definition?

28.5 Overwriting rules for attributes:

"An attribute definition in a lower scope unit will override a general
attribute definition in a higher scope."

Does "general attribute" in here mean an attribute, that is assigned to
all the elements within the section market with braces {}. If yes,
does this also imply, a that non-general attribute (with { encode (ref)
".."})
at higher scope does override attributes at lower scope?

On override directive:

" An attribute definition in a lower scope can be overwritten in a
higher scope by using the override directive.
...
The override directive forces all contained types at all lower scopes
to be forced to the specified attribute. "

Based on that, are the following types encoded equally?

type integer myInt with { encode "myIntRule" };

type record myRecordA
{
myInt field1
} with
{
encode override "myRecARule"
}

type record myRecordB
{
myInt field1
} with
{
encode (field) "myRecARule"
}


Related question is what is the propagation depth of the referenced
attributes?

type record myPdu
{
HeaderType hdr,
PayloadType payload
} with
{
encode (hdr) "This is the IP header";
encode (playload) "This is the data"
}

If the fields are structured, do the field attribute propagate to the
leaf nodes of all possible possible sub structures, overwriting whatever
attributes there might be, in the following manner:

.
.
|myPdu |
|
+
|
|fld1 |fld2 |
.
`
´ |
| |
v v
.
. .
.
|HeaderType | |PayloadType "This is the data"|
|
+
| `
´
|fld1 |fld2 |
.
`
´ |
| |
v v
.
. .
.
|rec | |leaf "This is the IP header" |
|
+
| `
´
|fld1 |fld2 |
.
`
´ |
| |
v v
.
. .
.
|leaf "This is the IP.."| |leaf "This is the IP header "|
`
´ `
´

Or are they only visible at the root type?

.
.
|myPdu |
|
+
|
|fld1 "This is the IP" |fld2 "This is the data"|
`
'
| |
v v
.
. .
.
|HeaderType | |PayloadType "Own attribute" |
|
+
| `
´
|fld1 "Own" |fld2 "Own" |
.
`
´ |
| |
v v
.
. .
.
|rec | |leaf "Own attribute" |
|
+
| `
´
|fld1 "Own" |fld2 "Own" |
.
`
´ |
| |
v v
.
. .
.
|leaf "Own" | |leaf "Own" |
`
´ `
´

where "own" is the own attribute of the type or field.

BR
Antti
The administrator has disabled public write access.
  • Page:
  • 1

FacebookTwitterGoogle BookmarksRedditNewsvineTechnoratiLinkedin