Entity

Definition of abstract Entity class.

This module defines the Entity class, inherited by all physical simulation elements (including hardware and photons).

class src.kernel.entity.Entity(name: str, timeline: Timeline)

Abstract Entity class. Entity should use the provided pseudo random number generator (PRNG) to produce reproducible random numbers. As a result, simulations with the same seed can reproduce identical results. Function “get_generator” returns the PRNG.

name

name of the entity.

Type:

str

timeline

the simulation timeline for the entity.

Type:

Timeline

owner

another entity that owns or aggregates the current entity.

Type:

Entity

_observers

a list of observers for the entity.

Type:

List

_receivers

a list of entities that receive photons from current component.

Type:

List[Entity]

attach(observer: Any) None

Method to add an observer (to receive hardware updates).

detach(observer: Any) None

Method to remove an observer.

get(photon: Photon, **kwargs)

Method for an entity to receive a photon.

If entity is a node, may forward to external quantum channel. Must be overwritten to be used, or will raise exception.

Parameters:
  • photon (Photon) – photon received by the entity.

  • **kwargs – other arguments required by a particular hardware component.

get_generator() Generator

Method to get random generator of parent node.

If entity is not attached to a node, return default generator.

abstract init() None

Method to initialize entity (abstract).

Entity init methods are invoked for all timeline entities when the timeline is initialized. This method can be used to perform any necessary functions before simulation.

notify(info: Dict[str, Any]) None

Method to notify all attached observers of an update.

remove_from_timeline() None

Method to remove entity from attached timeline.

This is to allow unused entities to be garbage collected.