
Information Object
Information Object code will be generated in a header and source file with a C struct / C++ class to hold the values. The name of the header and source file are of the following format:
In this definition, <ModuleName> would be replaced with the name of the ASN.1 module in which the information object is defined.
For C, a global variable is generated to hold information object definition. This is very similar to the code generated for a value definition.
An example of an information object definition that is derived from the ASN.1 ATTRIBUTE class above is as follows:
name ATTRIBUTE ::= { WITH SYNTAX VisibleString ID { 0 1 1 } }ATTRIBUTE name;name.TypeSize = sizeof(_name_Type); name.encodeType = &asn1E__name_Type; name.decodeType = &asn1D__name_Type; name.id.numids = 3; name.id.subid[0] = 0; name.id.subid[1] = 1; name.id.subid[2] = 1;The C++ classes generated for ASN.1 information objects are derived from the ASN.1 class objects. The constructors in these classes populate the fixed-type field member variables with the values specified in the information object. The classes also implement the virtual methods generated for the information object type fields. All non-optional methods are required to be implemented. The optional methods are only implemented if they are defined in the information object definition.
An example of an information object definition that is derived from the ASN.1 class above is as follows:
name ATTRIBUTE ::= { WITH SYNTAX VisibleString ID { 0 1 1 } }class EXTERN name : public ATTRIBUTE { public: name(); virtual int encodeBERType (ASN1CTXT* pctxt, ASN1TObject& object); virtual int decodeBERType (ASN1CTXT* pctxt, ASN1TObject& object); } ;The constructor implementation for this class (not shown) sets the fixed type fields (id) to the assigned values ({0 1 1}). The class also implements the virtual methods for the type field virtual methods defined in the base class. These methods simply call the BER encode or decode method for the assigned type (this example assumes -ber was specified for code generation - other encode rules could have been used as well).
If the information object contains an embedded type definition, it is extracted from the definition to form a new type to be added to the generated C or C++ code. The format of the new type name is as follows:
_<ObjectName>_<FieldName>
Objective Systems, Inc.102 Pickering Way, Suite #506Exton, Pennsylvania 19341 http://www.obj-sys.com Phone: (484) 875-9841 Toll-free: (877) 307-6855 (US only) Fax: (484) 875-9830 info@obj-sys.com |