//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project/CC
//
//File: trigger.cpp
//
//Version: $Revision: 1.10 $
//
//State: $State: Exp $
//
//Date: $Date: 1998/11/12 15:10:05 $
//
//Organisation:
//      University of Technology
// 
//Author:
//      Pasi Nummisalo
//
//Description:
//     
//
//Copyright:
//     University of Technology
//     Laboratory of Telecommunications and Multimedia 
//      
//Licence:
//     
//
//History:
//

#include "trigger.h"


ccTrigger :: ccTrigger(ccTriggerBase *implementation_)
    : _implementation(implementation_)
{
//    cerr << "ccTrigger::constructor" << endl;
    incRefCount();
    return;
}

ccTrigger :: ccTrigger(const ccTrigger &other_)
    : _implementation(other_._implementation)
{
//    cerr << "ccTrigger::copy_constructor" << endl;
    incRefCount();
    return;
}

ccTrigger :: ~ccTrigger(void)
{
//    cerr << "ccTrigger::destructor" << endl;
    decRefCount();
    return;
}

//
//Functions: operators
//
//Description:
//    Define equal and not equal logical operators
//    and assignment operator
//

const ccTrigger &ccTrigger :: operator = (const ccTrigger &other_)
{
    if (this != &other_) // if not x = x situation
    {
        // Decrease refcount at old implementation
        decRefCount();
        _implementation = other_._implementation;
        // Increase refcount at new implementation
        incRefCount();
    }
    return *this;
}

int ccTrigger :: operator == (const ccTrigger &other_) const
{
    int result = _implementation == other_._implementation;
    return result; 
}

int ccTrigger :: operator != (const ccTrigger &other_) const
{
    int result = _implementation != other_._implementation;
    return result; 
}  

//
//Function: methods for reference counter
//
//Description:
//    See pfProtocol.
//

void ccTrigger :: incRefCount(void) 
{
    if (_implementation != 0)
    {
        _implementation->incRefCount();
    }
    return;
}

void ccTrigger :: decRefCount(void)
{
    if (_implementation != 0)
    {
        _implementation->decRefCount();
        if (_implementation->noReference() != 0)
        {
            delete _implementation;
            _implementation = 0;
        }
    }
    return;
}


//
//Functions: criteria
//
//Description:
//   
//

void ccTrigger :: setCriteria(string criteria_)
{
    if (_implementation != 0)
    {
        _implementation->setCriteria(criteria_);
    }
    return;
}

bool ccTrigger :: checkCriteria(ccProtocol *protocol_) const
{
    bool result = 0;

    if (_implementation != 0)
    {
        result = _implementation->checkCriteria(protocol_);
    }

    return result;
}

string ccTrigger :: getCriteria(void) const
{
    string result;
    
    if (_implementation != 0)
    {
        result = _implementation->getCriteria();
    }    
    return result;
}


//
//Functions: type 
//
//Description:
//   
//

toveinap_TriggerTypeType ccTrigger :: getInapType() const
{
    toveinap_TriggerTypeType result;
    
    if (_implementation != 0)
    {
        result = _implementation->getInapType();
    }
    
    return result;
}

string ccTrigger :: getType(void) const
{
    string result;

    if (_implementation != 0)
    {
        result = _implementation->getType();
    }    
    
    return result;
}

//
//Functions: category 
//
//Description:
//   
//

void ccTrigger :: setCategory(string category_)
{
    if (_implementation != 0)
    {
        _implementation->setCategory(category_);
    }

    return;
}

string ccTrigger :: getCategory(void) const
{
    string result;

    if (_implementation != 0)
    {
        result = _implementation->getCategory();
    }
      
    return result;
}

toveinap_DPAssignmentType ccTrigger :: getInapCategory(void) const
{
    toveinap_DPAssignmentType result;

    if (_implementation != 0)
    {
        result = _implementation->getInapCategory();
    }
      
    return result;    
}

//
//Functions: serviceKey
//
//Description:
//   
//

void ccTrigger :: setServiceKey(toveinap_ServiceKeyType serviceKey_)
{
    if (_implementation != 0)
    {
        _implementation->setServiceKey(serviceKey_);
    }    

    return;
}

toveinap_ServiceKeyType ccTrigger :: getServiceKey(void) const
{
    toveinap_ServiceKeyType result;
    
    if (_implementation != 0)
    {
        result = _implementation->getServiceKey();
    }
    return result;
}

//
//Functions: applicationContext
//
//Description:
//   
//

void ccTrigger :: setApplicationContext(string context_)
{
    if (_implementation != 0)
    {
        _implementation->setApplicationContext(context_);
    }

    return;
}

string ccTrigger :: getApplicationContext(void) const
{
    string result;

    if (_implementation != 0)
    {
        result = _implementation->getApplicationContext();
    }
      
    return result;
}

//
//Functions: address
//
//Description:
//   
//

void ccTrigger :: setAddress(string address_)
{
    if (_implementation != 0)
    {
        _implementation->setAddress(address_);
    }

    return;
}

string ccTrigger :: getAddress(void) const
{
    string result;

    if (_implementation != 0)
    {
        result = _implementation->getAddress();
    }
      
    return result;
}
