'''
Created on Jan 22, 2011
Modified on Apr 22, 2011
@author: Dilum Bandara
@version: 0.2
@copyright: Copyright(c) 2011, Dilum Bandara
@license: GPL
'''

class BaseOverlay(object):
    '''
    Base Overlay class. 
    '''
    def __init__(self):
        print 'Init method not implemented'
        pass


    def route_new_ads(self, source, atts):
        '''
        Route resource ads to given destination & return no of overlay hops
        @param source: Source node ID
        @param atts: Attributes
        @return: Success/Failure
        '''
        print 'Method route_new_ads not implemented. Must implement in derived class'
        return  []


    def route_old_ads(self, source, atts):
        '''
        Route resource ads to given destination & return no of overlay hops
        @param source: Source node ID
        @param atts: Attributes to remove from index
        @return: Success/Failure
        '''
        print 'Method route_old_ads not implemented. Must implement in derived class'
        return  []


    def route_query(self, que_msg):
        '''
        Route query to given destination & return no of overlay hops   
        @param que_msg: Query message
        @return: Modified query message
        '''
        print 'Method route_query not implemented. Must implement in derived class'
        return None


    def find_successor(self, key, ring_no):
        '''
        Find successor for a given key in given ring
        @param key: Key
        @param ring_no: Which ring to use
        @return: Successor ID
        '''
        print 'Method find_successor not implemented. Must implement in derived class'
        return -1


    def get_distance(self, source, destination):
        '''
        Get overlay distance between 2 nodes
        @param source: Source node
        @param destination: Destination node
        @return: Overlay distance
        '''
        print 'Method get_distance not implemented. Must implement in derived class'
        return -1


    def get_neighbor(self, nid, ring):
        '''
        Find neighbor of given node
        @param nid: Node ID
        @param ring: Which ring to use
        @return: Neighbor ID
        '''
        print 'Method get_neighbor not implemented. Must implement in derived class'
        return -1
   
    
    def get_unvisited_neighbor(self, nid, que_msg):
        '''
        Find a random unvisited neighbor of given node. If unable to find, 
        pick node before me        
        @param nid: Current node ID
        @param que_msg: Query message
        '''
