//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project / mgmt module
//
//File: mgmtdelegationbase.cpp
//
//Version: $Revision: 1.10 $
//
//State: $State: Exp $
//
//Date: $Date: 1998/10/19 08:24:22 $
//
//Organisation:
//      Helsinki University of Technology
//      Laboratory of Telecommunications Software and Multimedia
//
//Author:
//      Timo Kokkonen
//
//Description:
//      See corresponding header file.
//
//Copyright:
//      Copyright 1999 Helsinki University of Technology
//      ALL RIGHTS RESERVED BETWEEN JANUARY 1996 AND JUNE 1999.
//
//Licence:
//
//
//History:
//
#include "pf/exception.h"
#include "mgmtdelegationbase.h"
#include "mgmtsend.h"

//
//Function: constructor
//
//Description:
//
//
mgmtDelegationBase :: mgmtDelegationBase(void)
    : _sendPtr(0)
{
    return;
}

//----------------------------------------------------------------------

//
//Function: destructor
//
//Description:
//
//
mgmtDelegationBase :: ~mgmtDelegationBase(void)
{
    delete _sendPtr;

    return;
}

//----------------------------------------------------------------------

//
//Functions: receive register/unregister notifications
//
//Description:
//    Notify server that user is registered/unregistered. Default
//    implementation is empty.
//
void mgmtDelegationBase :: receiveRegister(void)
{
    return;
}

void mgmtDelegationBase :: receiveUnRegister(void)
{
    return;
}

//
//Function: createOB
//
//Description:
//      Creates OB connection
//
void mgmtDelegationBase :: createOB(void)
{
    _sendPtr = mgmtSend::createOB(this);

    if (_sendPtr == 0)
    {
        throw pfNullPointerException(PF_EX_INFO);
    }

    return;
}

//----------------------------------------------------------------------

//Function: registerToNameService
//
//Description:
//      Method to register in to nameserver
//
//
void mgmtDelegationBase :: registerToNameService(const string &name_)
{
    if (_sendPtr == 0)
    {
        throw pfNullPointerException(PF_EX_INFO);
    }

    _sendPtr->registerToNameService(name_);

    return;
}

//----------------------------------------------------------------------

//
//Function: UnRegisterToNameService
//
//Description:
//      Method to unregister in to nameserver
//
void mgmtDelegationBase :: unRegisterToNameService(void)
{
    if (_sendPtr == 0)
    {
        throw pfNullPointerException(PF_EX_INFO);
    }

    _sendPtr->unRegisterToNameService();

    return;
}
//----------------------------------------------------------------------

//
//Function: registerToOther
//
//Description:
//      Method to register in to other.
//
void mgmtDelegationBase :: registerToOther(const string &name_)
{
    if (_sendPtr == 0)
    {
        throw pfNullPointerException(PF_EX_INFO);
    }

    _sendPtr->registerToOther(name_);

    return;
}

//----------------------------------------------------------------------

//
//Function: unRegisterToOther
//
//Description:
//      Method to unregister in to other
//
void mgmtDelegationBase :: unRegisterToOther(void)
{
    if (_sendPtr == 0)
    {
        throw pfNullPointerException(PF_EX_INFO);
    }

    _sendPtr->unRegisterToOther();

    return;
}

//----------------------------------------------------------------------

//
//Function: sendGet
//
//Description:
//      Sends get to other.
//
string mgmtDelegationBase :: sendGet(const string &name_)
{
    string result;

    if (_sendPtr == 0)
    {
        throw pfNullPointerException(PF_EX_INFO);
    }

    result = _sendPtr->sendGet(name_);

    return result;
}

//----------------------------------------------------------------------

//
//Function: sendSet
//
//Description:
//      Sends set to other.
//
void mgmtDelegationBase :: sendSet(const string &name_, const string &value_)
{
    if (_sendPtr == 0)
    {
        throw pfNullPointerException(PF_EX_INFO);
    }

    _sendPtr->sendSet(name_, value_);

    return;
}

//----------------------------------------------------------------------

//
//Function: sendExecute
//
//Description:
//      Sends execute to other.
//
void mgmtDelegationBase :: sendExecute(mgmtCommand &command_)
{
    if (_sendPtr == 0)
    {
        throw pfNullPointerException(PF_EX_INFO);
    }

    _sendPtr->sendExecute(command_);

    return;
}

//----------------------------------------------------------------------
