//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project
//
//File: trs_impl.cpp
//
//Version: $Revision: 1.1 $
//
//State: $State: Exp $
//
//Date: $Date: 1998/10/06 12:41:21 $
//
//Organisation:
//      Helsinki University of Technology
//      Laboratory of Telecommunications Software and Multimedia
//
//Author:
//
//
//Description:
//
//
//Copyright:
//      Copyright 1999 Helsinki University of Technology
//      ALL RIGHTS RESERVED BETWEEN JANUARY 1996 AND JUNE 1999.
//
//Licence:
//
//
//History: 

#include "trs_impl.h"
#include "protocol/cc/ccprotocol.h"
#include "pf/debug.h"

trs_RouteServerCallback_impl :: trs_RouteServerCallback_impl(
    ccProtocol *host_)
    : _host(host_)
{
    return;
}

trs_RouteServerCallback_impl :: ~trs_RouteServerCallback_impl(void)
{
    return;
}

void trs_RouteServerCallback_impl :: routeSelection(
    const trs_LinkNumberList &nextLinks_,
    const trs_DTLstackList &dtlStacks_,
    trs_Cause failure_)
{
    if (_host != 0)
    {
        // Call something for CC
        debugUser("Response from RouteServer. ccProtocol installed");

        if (failure_ == trs_NoException)
        {
            // Call some method for CC
            debugUser("Route selected successfully");
        }
        else
        {
            // Do something else
            debugUser("Route selection failured");
        }
    }
    else
    {
        // Just print out the information
        debugTime();
        debugUser("Response from RouteServer. No ccProtocol installed");

        pfUlong i, j, linkNumber;
        pfUlong length = nextLinks_.length();
        pfUlong numOfDtlStacks = dtlStacks_.length();
        pfUlong size;
        
        for(i = 0; i < length; i++)
        {
            linkNumber = nextLinks_[i];
            debugPfUlong("nextLinks_[i], i = ", i);
            debugPfUlong("Number of next link is ", linkNumber);
            if ((numOfDtlStacks > 0) && (numOfDtlStacks > i))
            {
                debugUser("DTL Stack contents:");
            
                size = dtlStacks_[i].length();
                for(j = 0; j < size; j++)
                {
                    if(dtlStacks_[i][j] != 0)
                    {
                        debugUser(dtlStacks_[i][j]);
                    }
                }
            }
        }
    }
    return;
}
