"""Author: Changbeom Choi (@cbchoi)Copyright (c) 2014-2020 Handong Global UniversityCopyright (c) 2021-2024 Hanbat National UniversityLicense: MIT. The full license text is available at:https://github.com/eventsim/pyjevsim/blob/main/LICENSEThis module contains SystemObject, the top-level class for all models. """importdatetime
[docs]classSystemObject:"""Base class for all system objects, providing unique object IDs and creation time."""# Object ID which tracks the entire instantiated Objects__GLOBAL_OBJECT_ID=0def__init__(self):self.__created_time=datetime.datetime.now()# Creation timeself.__object_id=SystemObject.__GLOBAL_OBJECT_ID# Unique object IDSystemObject.__GLOBAL_OBJECT_ID+=1# Increment global object IDdef__str__(self):""" Returns the string representation of the SystemObject. Returns: str: The string representation """returnf"ID:{self.__object_id}{self.__created_time}"def__lt__(self,other):""" Compares this object with another object for sorting. Args: other (SystemObject): The other object to compare with Returns: bool: True if this object ID is less than the other object's ID """returnself.__object_id<other.__object_id
[docs]defget_obj_id(self):""" Returns the unique object ID. Returns: int: The unique object ID """returnself.__object_id