Class QObject

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected double myTimeStamp
      can be used to time stamp the qObject
      protected GetValueIfc myValue
      Generic attribute that can be used to return a value
    • Constructor Summary

      Constructors 
      Constructor Description
      QObject​(double creationTime)
      Creates a QObject with name "null" and the creation time set to the supplied value
      QObject​(double creationTime, java.lang.String name)
      Creates an QObject with the given name and the creation time set to the supplied value
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(QObject obj)
      Returns a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object.
      protected void enterQueue​(Queue queue, double time, int priority, java.lang.Object obj)
      Used by Queue to indicate that the QObject has entered the queue
      protected void exitQueue​(double time)
      Indicates that the QObject exited the queue
      java.lang.Object getAttachedObject()
      If there is no attached object then this method returns null
      double getCreateTime()
      Gets the time that the QObject was created
      long getId()
      Gets a uniquely assigned identifier for this QObject.
      java.lang.String getName()
      Gets this QObject's name.
      int getPriority()
      Gets the queueing priority associated with this QObject
      Queue getQueue()
      Returns the queue that the QObject was last enqueued within
      StateAccessorIfc getQueuedState()
      This method can be used to get direct access to the State that represents when the object was queued.
      double getTimeEnteredQueue()
      Gets the time the QObject was LAST enqueued
      double getTimeExitedQueue()
      Gets the time the QObject LAST exited a queue
      double getTimeInQueue()
      Gets the time the QObject spent in the Queue based on the LAST time dequeued
      double getTimeStamp()  
      java.util.Optional<GetValueIfc> getValueObject()
      Returns the value determined by the object supplied from setValue().
      protected void initialize​(double time, java.lang.String name)
      Causes the QObject to look like new, gets a new name, number, priority is reset to 1, states are initialized, and starts in created state.
      boolean isQueued()
      Checks if the QObject is queued
      void nullify()
      Causes all references to objects from this QObject to be set to null and all internal objects to be set to null including State information
      void setAttachedObject​(java.lang.Object obj)
      Sets an object that can be attached to the QObject
      void setName​(java.lang.String str)
      Sets the name of this QObject
      protected void setNulls()
      Used to make the QObject not have any references, e.g.
      void setPriority​(int priority)
      Sets the priority to the supplied value If the QObject is queued, the queue's changePriority() method is called (possibly causing a reordering of the queue) which may cause significant reordering overhead otherwise the priority is directly changed Changing this value only changes how the QObjects are compared and may or may not change how they are ordered in the queue, depending on the queue discipline used
      protected void setPriority_​(int priority)
      Sets the queueing priority for this QObject Changing the priority while the object is in a queue has no effect on the ordering of the queue.
      protected void setQueue​(Queue queue)
      Sets the queue that the QObject is enqueued
      void setTimeStamp​(double timeStamp)  
      void setValueObject​(GetValueIfc value)
      Allows for a generic value to be held by the QObject whose value will be return by getValue() It can be null, in which case, getValue() will return null
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • myTimeStamp

        protected double myTimeStamp
        can be used to time stamp the qObject
      • myValue

        protected GetValueIfc myValue
        Generic attribute that can be used to return a value
    • Constructor Detail

      • QObject

        public QObject​(double creationTime)
        Creates a QObject with name "null" and the creation time set to the supplied value
        Parameters:
        creationTime - the time created
      • QObject

        public QObject​(double creationTime,
                       java.lang.String name)
        Creates an QObject with the given name and the creation time set to the supplied value
        Parameters:
        creationTime - the time created
        name - The name of the QObject
    • Method Detail

      • getValueObject

        public java.util.Optional<GetValueIfc> getValueObject()
        Returns the value determined by the object supplied from setValue(). The object returned may be null
        Returns:
        an implementation of GetValueIfc or null
      • setValueObject

        public void setValueObject​(GetValueIfc value)
        Allows for a generic value to be held by the QObject whose value will be return by getValue() It can be null, in which case, getValue() will return null
        Parameters:
        value - the value object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getName

        public final java.lang.String getName()
        Gets this QObject's name.
        Specified by:
        getName in interface GetNameIfc
        Returns:
        The name of the QObject.
      • getId

        public final long getId()
        Gets a uniquely assigned identifier for this QObject. This identifier is assigned when the QObject is created. It may vary if the order of creation changes.
        Returns:
        The identifier for the entity.
      • getCreateTime

        public final double getCreateTime()
        Gets the time that the QObject was created
        Returns:
        A double representing simulated creation time
      • getPriority

        public final int getPriority()
        Gets the queueing priority associated with this QObject
        Returns:
        The priority as an int
      • getQueue

        public final Queue getQueue()
        Returns the queue that the QObject was last enqueued within
        Returns:
        The Queue, or null if no queue
      • getTimeEnteredQueue

        public final double getTimeEnteredQueue()
        Gets the time the QObject was LAST enqueued
        Returns:
        A double representing the time the QObject was enqueued
      • getTimeExitedQueue

        public final double getTimeExitedQueue()
        Gets the time the QObject LAST exited a queue
        Returns:
        A double representing the time the QObject last exited a QObject
      • getTimeInQueue

        public final double getTimeInQueue()
        Gets the time the QObject spent in the Queue based on the LAST time dequeued
        Returns:
        the most recent time spend in a queue
      • getQueuedState

        public final StateAccessorIfc getQueuedState()
        This method can be used to get direct access to the State that represents when the object was queued. This allows access to the total time in the queued state as well as other statistical accumulation of state statistics
        Returns:
        Returns the QueuedState.
      • getAttachedObject

        public final java.lang.Object getAttachedObject()
        If there is no attached object then this method returns null
        Returns:
        A reference to the attached object
      • isQueued

        public final boolean isQueued()
        Checks if the QObject is queued
        Returns:
        true if it is queued
      • setPriority

        public final void setPriority​(int priority)
        Sets the priority to the supplied value If the QObject is queued, the queue's changePriority() method is called (possibly causing a reordering of the queue) which may cause significant reordering overhead otherwise the priority is directly changed Changing this value only changes how the QObjects are compared and may or may not change how they are ordered in the queue, depending on the queue discipline used
        Parameters:
        priority - An integer representing the priority of the QObject
      • setName

        public final void setName​(java.lang.String str)
        Sets the name of this QObject
        Parameters:
        str - The name as a string.
      • initialize

        protected final void initialize​(double time,
                                        java.lang.String name)
        Causes the QObject to look like new, gets a new name, number, priority is reset to 1, states are initialized, and starts in created state. As if newly, created. Useful if reusing QObjects
        Parameters:
        time - used to set the creation time of the QObject
        name - the name
      • setNulls

        protected void setNulls()
        Used to make the QObject not have any references, e.g. to a Queue and to an Object that was queued

      • nullify

        public void nullify()
        Causes all references to objects from this QObject to be set to null and all internal objects to be set to null including State information

        Meant primarily to facilitate garbage collection. After this call, the object should not be used.

      • enterQueue

        protected final void enterQueue​(Queue queue,
                                        double time,
                                        int priority,
                                        java.lang.Object obj)
        Used by Queue to indicate that the QObject has entered the queue
        Parameters:
        queue - the queue entered
        time - the time
        priority - the priority
        obj - an object to attach
      • exitQueue

        protected final void exitQueue​(double time)
        Indicates that the QObject exited the queue
        Parameters:
        time - The time QObject exited the queue
      • setPriority_

        protected final void setPriority_​(int priority)
        Sets the queueing priority for this QObject Changing the priority while the object is in a queue has no effect on the ordering of the queue. This priority is only used to determine the ordering in the queue when the item enters the queue.
        Parameters:
        priority - lower priority implies earlier ranking in the queue
      • setQueue

        protected void setQueue​(Queue queue)
        Sets the queue that the QObject is enqueued
        Parameters:
        queue - The Queue that the object is enqueued
      • setAttachedObject

        public final void setAttachedObject​(java.lang.Object obj)
        Sets an object that can be attached to the QObject
        Parameters:
        obj - The attached object
      • compareTo

        public final int compareTo​(QObject obj)
        Returns a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object.

        Throws ClassCastException if the specified object's type prevents it from begin compared to this object.

        Throws RuntimeException if the id's of the objects are the same, but the references are not when compared with equals.

        Note: This class may have a natural ordering that is inconsistent with equals.

        Specified by:
        compareTo in interface java.lang.Comparable<QObject>
        Parameters:
        obj - The object to compare to
        Returns:
        Returns a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object.
      • getTimeStamp

        public final double getTimeStamp()
        Returns:
        Returns the TimeStamp.
      • setTimeStamp

        public final void setTimeStamp​(double timeStamp)
        Parameters:
        timeStamp - The timeStamp to set.