Class DataDefinitionSeg
- java.lang.Object
-
- com.automation_pros.odva.cip.path.PathSegment
-
- com.automation_pros.odva.cip.path.DataDefinitionSeg
-
- All Implemented Interfaces:
java.lang.Comparable<PathSegment>
- Direct Known Subclasses:
AliasDefSeg
,ConstructedDefSeg
,DecoratedDefSeg
,ElementarySeg
,HostedBitDefSeg
,OmStringDefSeg
,StructDefSeg
public abstract class DataDefinitionSeg extends PathSegment
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DataDefinitionSeg.DataDefinitionFragment
-
Nested classes/interfaces inherited from class com.automation_pros.odva.cip.path.PathSegment
PathSegment.HasAlternateHex
-
-
Field Summary
Fields Modifier and Type Field Description static org.slf4j.Logger
sLogger
-
Fields inherited from class com.automation_pros.odva.cip.path.PathSegment
identifierChars, segtype
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DataDefinitionSeg(byte segtype)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
alignment(DataContext ctx)
Alignment is normally the natural size of a primitive element.java.util.List<PathSegment>
browseInner(DataContext ctx)
protected abstract BaseDataType<?>
construct(int[] dimensions, DataContext ctx)
Construct an instance of the type represented by this definition, using the given dimensions.BaseDataType<?>
construct(DataContext ctx)
Construct an instance of the type represented by this definition.DecoratedDefSeg
follow(PathSegment seg, DataContext ctx)
Step into this type definition by the given selector, returning the inner type definition.DataDefinitionSeg.DataDefinitionFragment
followOffsets(java.lang.Integer outerByteOffset, PathSegment seg, DataContext ctx)
Step into this type definition by the given selector, returning the inner type definition.static DataDefinitionSeg
fromClass(java.lang.Class<?> element)
static DataDefinitionSeg
fromData(BaseDataType<?> data)
PermissionedItem
getPermItem()
Support permissions tracking as a general feature.int
getSize(DataContext ctx, int... dims)
Return the number of bytes occupied by the given data type.protected abstract int
getSizeImpl(DataContext ctx)
Return the number of bytes occupied by a single instance of the given data type.boolean
isBoolHost()
Some elementary data types (the integer and word types) can be hosts for named bits within structures.boolean
isBoolImpl()
Size calculations for boolean min and max must defer to .getSize() to get the right answer for boolean arrays.boolean
isStringData()
Mark string implementations for special handling.int
maxSize(DataContext ctx)
Some data types need to offer a range of sizes for the encoded form of their data.int
minSize(DataContext ctx)
Some data types need to offer a range of sizes for the encoded form of their data.int
nestedMaxSize(DataContext ctx)
Certain types (Omron strings and booleans) can have different encodings when packed into structures.int
nestedMinSize(DataContext ctx)
Certain types (Omron strings and booleans) can have different encodings when packed into structures.int
nestedSize(DataContext ctx, int... dims)
Certain types (Omron strings and booleans) can have different encodings when packed into structures.protected int
nestedSizeImpl(DataContext ctx)
Certain types (Omron strings and booleans) can have different encodings when packed into structures.-
Methods inherited from class com.automation_pros.odva.cip.path.PathSegment
compareTo, decode, decodeAll, equals, getBytes, getSegtype, getTokens, getWords, hexString, mergeTokens, put, registerHandler, set, setSegtype, simpleString, toString
-
-
-
-
Method Detail
-
fromData
public static DataDefinitionSeg fromData(BaseDataType<?> data)
-
fromClass
public static DataDefinitionSeg fromClass(java.lang.Class<?> element)
-
getSizeImpl
protected abstract int getSizeImpl(DataContext ctx)
Return the number of bytes occupied by a single instance of the given data type. When the data is indirect, size is zero. When the data is variable length, size is -1;- Returns:
- Number of bytes.
-
nestedSizeImpl
protected int nestedSizeImpl(DataContext ctx)
Certain types (Omron strings and booleans) can have different encodings when packed into structures.
-
minSize
public int minSize(DataContext ctx)
Some data types need to offer a range of sizes for the encoded form of their data. The common case is fixed.- Returns:
-
nestedMinSize
public int nestedMinSize(DataContext ctx)
Certain types (Omron strings and booleans) can have different encodings when packed into structures.
-
maxSize
public int maxSize(DataContext ctx)
Some data types need to offer a range of sizes for the encoded form of their data. The common case is fixed.- Returns:
-
nestedMaxSize
public int nestedMaxSize(DataContext ctx)
Certain types (Omron strings and booleans) can have different encodings when packed into structures.
-
alignment
public int alignment(DataContext ctx)
Alignment is normally the natural size of a primitive element. Structured types and variable length types must override this method.- Returns:
-
getSize
public int getSize(DataContext ctx, int... dims)
Return the number of bytes occupied by the given data type. When the data is indirect (hosted elsewhere), or variable length, size is -1.When dimensions are provided, compute the bytes the complete array will occupy. Otherwise report the size of a singleton.
- Returns:
- Number of bytes.
-
nestedSize
public int nestedSize(DataContext ctx, int... dims)
Certain types (Omron strings and booleans) can have different encodings when packed into structures.
-
isBoolHost
public boolean isBoolHost()
Some elementary data types (the integer and word types) can be hosts for named bits within structures. This method is overridden in the necessary places to support this. It corresponds to subclasses of BaseDataType that implement the BoolHost interface.- Returns:
-
isBoolImpl
public boolean isBoolImpl()
Size calculations for boolean min and max must defer to .getSize() to get the right answer for boolean arrays.- Returns:
-
isStringData
public boolean isStringData()
Mark string implementations for special handling.- Returns:
-
browseInner
public java.util.List<PathSegment> browseInner(DataContext ctx)
-
construct
public BaseDataType<?> construct(DataContext ctx)
Construct an instance of the type represented by this definition. Use the provided context to look up any ambiguous data types.- Parameters:
ctx
-- Returns:
-
construct
protected abstract BaseDataType<?> construct(int[] dimensions, DataContext ctx)
Construct an instance of the type represented by this definition, using the given dimensions. This is an implementation detail that permits a DecoratedDefSeg to create arrays.Use the provided context to look up any ambiguous data types.
- Parameters:
dimensions
-ctx
-- Returns:
-
getPermItem
public PermissionedItem getPermItem()
Support permissions tracking as a general feature. This is overridden where appropriate.- Returns:
-
follow
public DecoratedDefSeg follow(PathSegment seg, DataContext ctx)
Step into this type definition by the given selector, returning the inner type definition. Look up inner types with the given context.- Parameters:
seg
-ctx
-- Returns:
-
followOffsets
public DataDefinitionSeg.DataDefinitionFragment followOffsets(java.lang.Integer outerByteOffset, PathSegment seg, DataContext ctx)
Step into this type definition by the given selector, returning the inner type definition. Look up inner types with the given context. Deliver a null byteOffset if unknowable.- Parameters:
outerByteOffset
-seg
-ctx
-- Returns:
-
-