Class CipStruct

    • Field Detail

      • definition

        protected final StructDef definition
      • bytesEachCache

        protected int bytesEachCache
    • Constructor Detail

      • CipStruct

        public CipStruct​(java.lang.String typeName,
                         StructMember... members)
      • CipStruct

        public CipStruct​(java.lang.String typeName,
                         java.util.List<? extends StructMember> members)
      • CipStruct

        public CipStruct​(StructDef definition)
      • CipStruct

        public CipStruct​(StructDef definition,
                         int[] dimensions)
      • CipStruct

        protected CipStruct​(CipStruct data,
                            int[] indices)
    • Method Detail

      • crcName

        public java.lang.String crcName()
        Description copied from class: BaseDataType
        Obtain the name of this type as used for computing structure CRCs. Can be different from the name(s) used by the CipPath parser.
        Overrides:
        crcName in class BaseDataType<BaseDataType<?>[]>
        Returns:
      • browseInnerImpl

        public java.util.List<PathSegment> browseInnerImpl()
        Description copied from class: BaseDataType
        Complex types that have nested data understood by the DataResolver must enumerate the path segments that are appropriate for the current instance's content. This is typically static for structure members, but dynamic for international string languages.
        Overrides:
        browseInnerImpl in class BaseDataType<BaseDataType<?>[]>
        Returns:
        A list of currently valid path selector segments.
      • getDefinition

        public StructDef getDefinition()
      • getMember

        public StructMember getMember​(java.lang.String name)
      • getMemberIndex

        public int getMemberIndex​(java.lang.String name)
      • getMemberData

        public BaseDataType<?> getMemberData​(java.lang.String name,
                                             int... indices)
      • getMembers

        public java.util.List<? extends StructMember> getMembers()
      • get

        public BaseDataType<?>[] get​(int[] indices)
        Description copied from class: BaseDataType
        Application-side value retrieval. Subclasses must implement this function to retrieve elements of the storage array in the application data type.
        Specified by:
        get in class BaseDataType<BaseDataType<?>[]>
        Parameters:
        indices - Array subscripts. Missing subscripts not allowed.
        Returns:
      • set

        public void set​(int[] indices,
                        BaseDataType<?>[] val)
        Description copied from class: BaseDataType
        Application-side value storage. Subclasses must implement this function to store one value or complex element into the storage array.
        Specified by:
        set in class BaseDataType<BaseDataType<?>[]>
        Parameters:
        indices - Array subscripts. Missing subscripts not allowed.
      • setPayloadImpl

        protected void setPayloadImpl​(java.nio.ByteBuffer source,
                                      int[] indices)
        Unlike simple data types, the Struct types may take one subscript more than there are dimensions -- selecting a specific member from the structure. For booleans attached to a host member, this will read one byte from the source.
        Specified by:
        setPayloadImpl in class BaseDataType<BaseDataType<?>[]>
      • setFromTokenizer

        public void setFromTokenizer​(java.io.StreamTokenizer st,
                                     int... indices)
        Description copied from class: BaseDataType
        Common implementation for setting values from a potentially customized string tokenizer.
        Overrides:
        setFromTokenizer in class BaseDataType<BaseDataType<?>[]>
      • putPayloadImpl

        protected void putPayloadImpl​(java.nio.ByteBuffer dest,
                                      int[] indices)
        Unlike simple data types, the Struct types may take one subscript more than there are dimensions -- selecting a specific member from the structure. For booleans attached to a host member, this will write one byte to the destination.
        Specified by:
        putPayloadImpl in class BaseDataType<BaseDataType<?>[]>
      • putAbbrevType

        public void putAbbrevType​(java.nio.ByteBuffer dest)
        Description copied from class: BaseDataType
        Many subclasses will be data elements supported by Logix processors. The LogixTagType interface requires this routine, which is identical for all types with a compact representation.
        Overrides:
        putAbbrevType in class BaseDataType<BaseDataType<?>[]>
      • bytesEach

        public int bytesEach()
        Compute the fixed number of bytes per member. If any member indicates a variable number of bytes, the entire structure is variable length.
        Specified by:
        bytesEach in class BaseDataType<BaseDataType<?>[]>
        Returns:
        encoded bytes per element
      • minEach

        public int minEach()
        Description copied from class: BaseDataType
        Obtain the smallest number of bytes a single item can occupy in encoded form. Used in structures to compute min/max offset and total structure size range.

        Types where bytesEach is a constant should override this to return that constant too, as a performance optimization.

        Overrides:
        minEach in class BaseDataType<BaseDataType<?>[]>
        Returns:
      • maxEach

        public int maxEach()
        Description copied from class: BaseDataType
        Obtain the largest number of bytes a single item can occupy in encoded form. Used in structures to compute min/max offset and total structure size range.

        Types where bytesEach is a constant should override this to return that constant too, as a performance optimization.

        Overrides:
        maxEach in class BaseDataType<BaseDataType<?>[]>
        Returns:
      • alignment

        public int alignment()
        Description copied from class: BaseDataType
        Obtain the natural alignment of this data type. Used in structures to compute min/max offset and alignment.

        Types where bytesEach is a constant should override this to return a suitable constant too, as a performance optimization.

        Overrides:
        alignment in class BaseDataType<BaseDataType<?>[]>
        Returns:
      • bytesImpl

        protected int bytesImpl​(int[] indices)
        Description copied from class: BaseDataType
        Retrieve the bytes payload size of a single array element (or sole element). Objects with fixed element sizes may simply return bytesEach() here.
        Specified by:
        bytesImpl in class BaseDataType<BaseDataType<?>[]>
        Returns:
      • wrap

        public CipStruct wrap​(int[] indices)
        Description copied from class: BaseDataType
        Application-side wrapper for inner dimensions. Implementations must update memberOffsets if not not using the protected constructor.
        Specified by:
        wrap in class BaseDataType<BaseDataType<?>[]>
        Parameters:
        indices - Array subscripts. Missing subscripts are allowed.
      • getParentDataCtx

        public DataContext getParentDataCtx()
        Description copied from interface: DataContext
        Get the next outer DataContext from the current context.
        Specified by:
        getParentDataCtx in interface DataContext
        Returns:
        The containing DataContext, or null if the current context is the root context.
      • getNamedDef

        public AnonStructSeg getNamedDef​(java.lang.String typeName)
        Description copied from interface: DataContext
        Look up a named type for use expanding a stub definition or to apply to a different context.
        Specified by:
        getNamedDef in interface DataContext
      • getTypeByName

        public StructDef getTypeByName​(java.lang.String typeName)
        Description copied from interface: DataContext
        Look up a named type for use constructing nested elements of a structure.
        Specified by:
        getTypeByName in interface DataContext
        Parameters:
        typeName - The type name to look up in the predefined names.
        Returns:
        The type suitable for use with CipStruct and/or StructMember.
      • getTypeByCRC

        public java.lang.String getTypeByCRC​(int crc)
        Description copied from interface: DataContext
        Look up a named type by CRC for use directly by a StructureDefSeg or indirectly by an AnonTypeSeg.
        Specified by:
        getTypeByCRC in interface DataContext
        Returns:
        The type suitable for use with CipStruct and/or StructMember.
      • getCtxDataImpl

        public BaseDataType<?> getCtxDataImpl​(java.util.List<PathSegment> reference)
        Description copied from interface: DataContext
        Look up reference data within this current context for use in indirection of various kinds, as described for getCtxData(), which uses this implementation and handles delegation to outer contexts.
        Specified by:
        getCtxDataImpl in interface DataContext
        Parameters:
        reference - The path to a data item.
        Returns:
        A data object