Skip to content

value_objects

Package defining the value object class.

Defined classes are used as an interface across multiple packages: architecture, infra, and runtime. CARET uses value objects to avoid unexpectedly overwritten.

CallbackChain #

Bases: MessageContext

TYPE_NAME = 'callback_chain' class-attribute #

Callback chain.

Latency is calculated from callback durations in the node path. When a path within a node passes through multiple callbacks, it is assumed that messages are passed between callbacks by a buffer of queue size 1 (ex. a member variable that stores a single message). If the queue size is larger than 1, the node latency may be calculated to be small.

CallbackGroupStructValue #

Bases: ValueObject, Summarizable

Callback group value object.

callback_group_name: str property #

Get callback group name.

Returns:

Type Description
str

Callback group name.

callback_group_type: CallbackGroupType property #

Get callback_group_type.

Returns:

Type Description
CallbackGroupType

callback_group_type_name: str property #

Get callback_group_type name.

Returns:

Type Description
CallbackGroupType name

callback_names: Tuple[str, ...] property #

Get callback names.

Returns:

Type Description
Tuple[str, ...]

Callback names which are added to the callback group.

callbacks: Tuple[CallbackStructValue, ...] property #

Get callbacks.

Returns:

Type Description
Tuple[CallbackStructValue, ...]

Callbacks which are added to the callback group.

node_name: str property #

Get node name.

Returns:

Type Description
str

node name

__init__(callback_group_type, node_name, callback_values, callback_group_name) #

Construct callback group value object.

Parameters:

Name Type Description Default
callback_group_type str

callback group type

required
node_name List[str]

node name

required
callback_values Tuple[CallbackStructValue, ...]

callback values

required
callback_group_name str

callback group name

required

CallbackGroupType #

Bases: ValueObject

Callback group type class.

The types of callback groups are as follows:

  • MUTUALLY_EXCLUSIVE
  • REENTRANT

type_name: str property #

Return callback group type name.

Returns:

Type Description
str

type name.

__init__(name) #

Construct CallbackGroupType.

Parameters:

Name Type Description Default
name str

type name ['mutually_exclusive', 'reentrant']

required

CallbackGroupValue #

Bases: ValueObject

Callback group value object.

callback_group_id: str property #

Get callback group id.

Returns:

Type Description
str

Callback group id.

callback_group_name: Optional[str] property #

Get callback group name.

Returns:

Type Description
Optional[str]

Callback group name.

callback_group_type: CallbackGroupType property #

Get callback_group_type.

Returns:

Type Description
CallbackGroupType

callback_ids: Tuple[str, ...] property #

Get callback ids.

Returns:

Type Description
Tuple[str, ...]

callback ids added to the callback group.

node_id: str property #

Get node id.

Returns:

Type Description
str

Node id.

node_name: str property #

Get node name.

Returns:

Type Description
str

Node name which includes the callback group.

__init__(callback_group_type_name, node_name, node_id, callback_ids, callback_group_id, *, callback_group_name=None) #

Construct an instance.

Parameters:

Name Type Description Default
callback_group_type_name str

callback group type name: ['mutually_exclusive' / 'reentrant']

required
node_name str

node name.

required
node_id str

Identification of the node, a value that can be identified when retrieved from the Architecture reader.

required
callback_ids Tuple[str, ...]

Identification of the callback, a value that can be identified when retrieved from the Architecture reader.

required
callback_group_id str

Identification of the callback group, a value that can be identified when retrieved from the Architecture reader.

required
callback_group_name Optional[str], optional

callback group name, by default None. If None, it is generated automatically.

None

CallbackStructValue #

Bases: Summarizable

Callback value base class.

callback_name: str property #

Get callback name.

Returns:

Type Description
str

callback name

callback_type: CallbackType property abstractmethod #

Get callback type name.

Returns:

Type Description
CallbackType

callback type

construction_order: int property #

Get construction order.

Returns:

Type Description
int

construction order

node_name: str property #

Get node name.

Returns:

Type Description
str

node name

symbol: str property #

Get callback symbol name.

Returns:

Type Description
str

callback symbol name

CallbackType #

Bases: ValueObject

callback group type class.

type_name: str property #

Return callback type name.

Returns:

Type Description
str

type name.

__init__(name) #

Construct callback type.

Parameters:

Name Type Description Default
name str

callback type name ['timer_callback', 'subscription_callback', 'service_callback']

required

CallbackValue #

Bases: ValueObject

Value object class for representing a callback.

This class has minimal information and no structure. It's used as the return value of ArchitectureReader.

callback_id: str property #

Get callback id.

Callback id is is used to bind. Callback id should be the same if the node name and other properties are the same. If any properties is different, it should be a different callback id.

Returns:

Type Description
str

Callback unique id.

callback_name: Optional[str] property #

Get callback name.

Returns:

Type Description
str

Callback name.

Note:#

Different architecture_readers may return different values.

callback_type: CallbackType property abstractmethod #

Get callback type name.

Returns:

Type Description
CallbackType

callback type

construction_order: int property #

Get construction order.

Returns:

Type Description
int

construction order

node_id: str property #

Get node id.

Returns:

Type Description
str

Node id.

node_name: str property #

Get node name.

Returns:

Type Description
str

Node name.

publish_topic_names: Optional[Tuple[str, ...]] property #

Get publisher topic names.

Returns:

Type Description
Optional[Tuple[str, ...]]

Topic names which the callback publishes.

Note:#

Since callback publishes multiple topics, there are multiple publish topic names.

subscribe_topic_name: Optional[str] property #

Get subscription topic name.

Returns:

Type Description
Optional[str]

Topic name which the callback subscribes.

Note:#

Only one subscription callback have a single subscribe topic name.

symbol: str property #

Get callback symbol name.

Returns:

Type Description
str

Callback symbol name.

__init__(callback_id, node_name, node_id, symbol, subscribe_topic_name, service_name, publish_topic_names, construction_order, *, callback_name=None) #

Construct an instance.

Parameters:

Name Type Description Default
callback_id str

Callback unique id, a value that can be identified when retrieved from the Architecture reader.

required
node_name str

Node name.

required
node_id str

Node unique id, a value that can be identified when retrieved from the Architecture reader.

required
symbol str

Symbol name of the callback.

required
subscribe_topic_name Optional[str]

Topic name which the callback subscribes.

required
service_name Optional[str]

Service name which the callback service.

required
publish_topic_names Optional[Tuple[str, ...]]

Topic name which the callback publishes.

required
construction_order int

Order of instance creation within the identical node.

required
callback_name Optional[str]

Callback name, by default None. This argument is used by ArchitectureReaderYaml.

None

ExecutorStructValue #

Bases: ValueObject, Summarizable

Executor info for architecture.

ExecutorType #

Bases: ValueObject

executor type class.

type_name: str property #

Return executor type name.

Returns:

Type Description
str

type name.

ExecutorValue #

Bases: ValueObject

Executor info for architecture.

InheritUniqueStamp #

Bases: MessageContext

TYPE_NAME = 'inherit_unique_stamp' class-attribute #

Inherit header timestamp.

Latency is calculated for pub/sub messages with the same timestamp value. If the input timestamp is not unique, it may calculate an incorrect value.

MessageContext #

Bases: ValueObject, Summarizable

Structured message context value.

MessageContextType #

Bases: ValueObject

Message context type.

NodePathStructValue #

Bases: ValueObject, Summarizable

StructValue object class for representing a node path.

This class is a structure that includes other related StructValue classes, such as callbacks, and used as the return value of Architecture object. In CARET, the node path is defined as from subscribe to publish.

__init__(node_name, subscription, publisher, child, message_context) #

Construct an instance.

Parameters:

Name Type Description Default
node_name str

Node name

required
subscription Optional[SubscriptionStructValue]

Subscription which the node path subscribes.

required
publisher Optional[PublisherStructValue]

Publisher which the node path publishes.

required
child Optional[Tuple[Union[CallbackStructValue, VariablePassingStructValue], ...]]

Child elements of a node path. Required only when message_context is callback_chain.

required
message_context Optional[MessageContext]

Message Context. Used to define node latency.

required

NodePathValue #

Bases: ValueObject

Value object class for representing a node path.

This class has minimal information and no structure, and used as the return value of ArchitectureReader. In CARET, the node path is defined as from subscribe to publish.

__init__(node_name, subscribe_topic_name, publish_topic_name) #

Construct an instance.

Parameters:

Name Type Description Default
node_name str

Node name.

required
subscribe_topic_name Optional[str]

Topic name which the node-path subscribes.

required
publish_topic_name Optional[str]

Topic name which the node-path publishes.

required

NodeStructValue #

Bases: ValueObject, Summarizable

StructValue object class for representing a node.

This class is a structure that includes other related StructValue classes, such as callbacks, and used as the return value of Architecture object.

NodeValue #

Bases: ValueObject

Value object class for representing a node.

This class has minimal information and no structure, and used as the return value of ArchitectureReader.

__init__(node_name, node_id) #

Construct an instance.

Parameters:

Name Type Description Default
node_name str

Node name.

required
node_id Optional[str]

Identification of the node, a value that can be identified when retrieved from the Architecture reader.

required

NodeValueWithId #

Bases: NodeValue

Value object class for representing a node path.

This class has minimal information and no structure, and used as the return value of ArchitectureReader.

__init__(node_name, node_id) #

Construct an instance.

Parameters:

Name Type Description Default
node_name str

Node name.

required
node_id Optional[str]

Identification of the node, a value that can be identified when retrieved from the Architecture reader.

required

PathValue #

Bases: ValueObject

Path name alias.

PublisherStructValue #

Bases: ValueObject, Summarizable

Structured publisher value.

PublisherValue #

Bases: ValueObject

Publisher value.

Qos #

Bases: ValueObject, Summarizable

Qos info.

Note:#

Currently, only DEPTH is supported, but it is desirable to support other QoS by adding trace points.

ServiceCallbackStructValue #

Bases: CallbackStructValue, ValueObject

Structured service callback value.

ServiceCallbackValue #

Bases: CallbackValue

Service callback value.

ServiceStructValue #

Bases: ValueObject, Summarizable

Service info.

ServiceValue #

Bases: ValueObject

Service info.

SubscriptionCallbackStructValue #

Bases: CallbackStructValue, ValueObject

Structured subscription callback value.

SubscriptionCallbackValue #

Bases: CallbackValue

Subscription callback value.

SubscriptionStructValue #

Bases: ValueObject, Summarizable

Subscription info.

SubscriptionValue #

Bases: ValueObject

Subscription info.

Tilde #

Bases: MessageContext

TYPE_NAME = 'tilde' class-attribute #

tilde.

Latency is calculated from tilde.

TimerCallbackStructValue #

Bases: CallbackStructValue, ValueObject

Structured timer callback value.

TimerCallbackValue #

Bases: CallbackValue

Value object class for representing a timer.

This class has minimal information and no structure, and used as the return value of ArchitectureReader.

TimerStructValue #

Bases: ValueObject, Summarizable

Timer info.

TimerValue #

Bases: ValueObject

Timer info.

UseLatestMessage #

Bases: MessageContext

TYPE_NAME = 'use_latest_message' class-attribute #

Use message context

ValueObject #

Value object base class.

Classes that inherit from this class will become immutable ValueObjects, and eq and hash will be calculated based on public properties.

Note:#

Since the hash value is immutable, inherited classes can be used as a dictionary type key. It is also suitable for cache use and does not unintentionally change properties.

__eq__(right) #

Check whether self object equals to given instance [override].

Parameters:

Name Type Description Default
right Any

Comparison target.

required

Returns:

Type Description
bool

Recursively compares the values of the published properties and returns True only if they all match. False otherwise.

__hash__() #

Calculate hash value.

Returns:

Type Description
int

A hash value calculated from all of the publicly available property values by recursively referencing them.

References#
https://www.baeldung.com/java-hashcode

__str__() #

Convert to string.

Returns:

Type Description
str

Yaml format strings created by recursively access properties.

VariablePassingStructValue #

Bases: ValueObject, Summarizable

variable passing info.

callback_name_read property #

Get read-side callback name.

Returns:

Type Description
[str]

read-side callback name.

callback_name_write: str property #

Get write-side callback name.

Returns:

Type Description
[str]

write-side callback name.

node_name: str property #

Get node name.

Returns:

Type Description
str

node name

VariablePassingValue #

Bases: ValueObject

variable passing info.

callback_id_read: str property #

Get read-side callback id.

Returns:

Type Description
[str]

read-side callback id.

callback_id_write: str property #

Get write-side callback id.

Returns:

Type Description
[str]

write-side callback id.

node_name: str property #

Get node name.

Returns:

Type Description
str

node name