'''
Created on Nov 3, 2011
Modified on Sep 3, 2012
@version: 0.11
@author: Dilum Bandara
@email: dilumb@engr.colostate.edu

   Copyright 2012 H. M. N. Dilum Bandara and Anura P. Jayasumana, Colorado State
   University

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
'''

import Config as Config

class OverlayJoinRequestMsg(object):
    '''
    Overlay Join Message class
    '''

    def __init__(self, NID, loc, addToOveraly):
        '''
        Constructor
        @param NID: Node ID of sender 
        @param loc: Location of node wishing to join
        @param addToOveraly: Add to overlay as a fully functional node 
        '''
        self.msgType = 'Join'
        self.NID = NID
        self.loc = loc
        self.inOveraly = addToOveraly
        # NID, locX, locY, locZ is 4-bytes, addToOverlay 1 byte
        size = 9 + Config.NUM_DIMENSIONS * 4 # 4 + 4 + 4 * NUM_DIMENSIONS + 1
        self.size = float(size * 8) #In bits