B
    ɒ\\                 @   s*   d dl mZ ddlmZ G dd dZdS )    )	lru_cache   )ConcurrentShelfc               @   s8   e Zd Zdd Zedddd Zedddd Zd	S )
AddressDictionaryc             C   sH   || _ d| _d | _t|| _| j  d| jkr:d| jd< | j  d S )NF	__last_idr   )
_file_name_closed_shelfr   lockunlock)self	file_name r   ]/global/project/projectdirs/dasrepo/etalumis/pyprob_master_mar20/pyprob/address_dictionary.py__init__   s    



zAddressDictionary.__init__i   )maxsizec             C   sv   d| }|| j kr| j | S | j   | j d d }|| j d< d|}|| j |< d| }|| j |< | j   |S d S )NZ__address__r   r   z__A{}__id__)r	   r
   formatr   )r   addressZaddress_keyZnew_idid_keyr   r   r   address_to_id   s    







zAddressDictionary.address_to_idc             C   s   d| }| j | S )Nr   )r	   )r   idr   r   r   r   id_to_address!   s    zAddressDictionary.id_to_addressN)__name__
__module____qualname__r   r   r   r   r   r   r   r   r      s   
r   N)	functoolsr   Zconcurrencyr   r   r   r   r   r   <module>   s   