3
AAd]n  ã               @   s$   d Z G dd„ dƒZG dd„ dƒZdS )z
Copied from Python Cookbook.

c               @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )Ú
RingBufferc             C   s   || _ g | _d S )N)ÚmaxÚdata)ÚselfZsize_max© r   úw/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.6/site-packages/apptools-4.4.0-py3.6.egg/apptools/logger/ring_buffer.pyÚ__init__   s    zRingBuffer.__init__c             C   s,   | j j|ƒ t| j ƒ| jkr(d| _t| _dS )z*append an element at the end of the bufferé    N)r   ÚappendÚlenr   ÚcurÚRingBufferFullÚ	__class__)r   Úxr   r   r   r	      s    zRingBuffer.appendc             C   s   | j S )z8 return a list of elements from the oldest to the newest)r   )r   r   r   r   Úget   s    zRingBuffer.getN)Ú__name__Ú
__module__Ú__qualname__r   r	   r   r   r   r   r   r      s   r   c               @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )r   c             C   s   t dƒ‚d S )Nzyou should use RingBuffer)Ú	Exception)r   Únr   r   r   r   #   s    zRingBufferFull.__init__c             C   s"   || j | j< | jd | j | _d S )Né   )r   r   r   )r   r   r   r   r   r	   %   s    zRingBufferFull.appendc             C   s    | j | jd … | j d | j…  S )N)r   r   )r   r   r   r   r   (   s    zRingBufferFull.getN)r   r   r   r   r	   r   r   r   r   r   r   "   s   r   N)Ú__doc__r   r   r   r   r   r   Ú<module>   s   