mirror of
https://github.com/ShaYmez/xlxd.git
synced 2024-11-07 16:26:06 -05:00
2f9e8a8781
implement XLX interlink feature
105 lines
2.7 KiB
C++
105 lines
2.7 KiB
C++
//
|
|
// cprotocols.cpp
|
|
// xlxd
|
|
//
|
|
// Created by Jean-Luc Deltombe (LX3JL) on 01/11/2015.
|
|
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
|
|
//
|
|
// ----------------------------------------------------------------------------
|
|
// This file is part of xlxd.
|
|
//
|
|
// xlxd is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// xlxd is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
|
// ----------------------------------------------------------------------------
|
|
|
|
#include "main.h"
|
|
#include "cdextraprotocol.h"
|
|
#include "cdplusprotocol.h"
|
|
#include "cdcsprotocol.h"
|
|
#include "cxlxprotocol.h"
|
|
#include "cprotocols.h"
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////
|
|
// constructor
|
|
|
|
CProtocols::CProtocols()
|
|
{
|
|
for ( int i = 0; i < m_Protocols.size(); i++ )
|
|
{
|
|
m_Protocols[i] = NULL;
|
|
}
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////
|
|
// destructor
|
|
|
|
CProtocols::~CProtocols()
|
|
{
|
|
m_Mutex.lock();
|
|
{
|
|
for ( int i = 0; i < m_Protocols.size(); i++ )
|
|
{
|
|
delete m_Protocols[i];
|
|
}
|
|
}
|
|
m_Mutex.unlock();
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////
|
|
// initialization
|
|
|
|
bool CProtocols::Init(void)
|
|
{
|
|
bool ok = true;
|
|
|
|
m_Mutex.lock();
|
|
{
|
|
// create and initialize DEXTRA
|
|
delete m_Protocols[0];
|
|
m_Protocols[0] = new CDextraProtocol;
|
|
ok &= m_Protocols[0]->Init();
|
|
|
|
// create and initialize DPLUS
|
|
delete m_Protocols[1];
|
|
m_Protocols[1] = new CDplusProtocol;
|
|
ok &= m_Protocols[1]->Init();
|
|
|
|
// create and initialize DCS
|
|
delete m_Protocols[2];
|
|
m_Protocols[2] = new CDcsProtocol;
|
|
ok &= m_Protocols[2]->Init();
|
|
|
|
// create and initialize XLX - interlink
|
|
delete m_Protocols[3];
|
|
m_Protocols[3] = new CXlxProtocol;
|
|
ok &= m_Protocols[3]->Init();
|
|
}
|
|
m_Mutex.unlock();
|
|
|
|
// done
|
|
return ok;
|
|
}
|
|
|
|
void CProtocols::Close(void)
|
|
{
|
|
m_Mutex.lock();
|
|
{
|
|
for ( int i = 0; i < m_Protocols.size(); i++ )
|
|
{
|
|
m_Protocols[i]->Close();
|
|
}
|
|
}
|
|
m_Mutex.unlock();
|
|
}
|