Nirvana C++: Service Connection Listener Implementation

Class that implements the service connection listener callbacks

Application Source Code

/*
    Copyright 2012 Software AG, Darmstadt, Germany and/or Software AG USA
    Inc., Reston, United States of America, and/or their licensors.

    In the event that you should download or otherwise use this software
    you hereby acknowledge and agree to the terms at
    http://www.my-channels.com/company/terms.html#legalnotices
*/

#include "Watchers.h"
#include "connectionwatch.h"
#include "nLeafNode.h"
#include "nServiceNode.h"
#include "nConnectionDetails.h"
#include "nChannelConnectionDetails.h"
#ifdef WIN32
#include <crtdbg.h>
#endif
using namespace com::pcbsys::nirvana::nAdminAPI;
using namespace com::pcbsys::nirvana::nAdminAPI::apps;
///
///   <summary> * Class that implements the connection lister interface.
///   * This internal class will Receive notifications when a sesison is added to
///   * or removed from a channel </summary>
///
///
///     <summary> * Construct the channel watch with the channel leaf node </summary>
///
nChannelWatch::nChannelWatch(nLeafNode *pChan, connectionwatch *pWatch) : m_pChannel(pChan), m_pWatcher(pWatch)
{
	m_pChannel->addRef();
}
///
///     <summary> * Notification of a new channel connection </summary>
///
void nChannelWatch::add(nConnectionDetails *pCd)
{
	int type = pCd->getType ();
	if (type == fBase::CHANNELCONNECTIONDETAILS)
	{
		nChannelConnectionDetails *pCcd = (nChannelConnectionDetails*)pCd;
		m_pWatcher->newConnection("Chan: " + m_pChannel->getAbsolutePath() + " with name [" + pCcd->getNamedSubscriber() + "]", pCcd);
	}
}
///
///     <summary> * Notification of a channel connection being removed </summary>
///
void nChannelWatch::del(nConnectionDetails *pCd)
{
	m_pWatcher->delConnection("Chan: " + m_pChannel->getAbsolutePath(), pCd);
}
///
///   <summary> * Class that implements the connection lister interface.
///   * This internal class will Receive notifications when a sesison is added to
///   * or removed from a channel </summary>
///
///
///     <summary> * Construct the channel watch with the channel leaf node </summary>
///
nServiceWatch::nServiceWatch(nServiceNode *pService, connectionwatch *pWatch) : m_pService(pService), m_pWatcher(pWatch)
{
	m_pService->addRef();
}
///
///     <summary> * Notification of a new channel connection </summary>
///
void nServiceWatch::add(nConnectionDetails *pCd)
{
	m_pWatcher->newConnection("Service: " + m_pService->getName(), pCd);
}
///
///     <summary> * Notification of a channel connection being removed </summary>
///
void nServiceWatch::del(nConnectionDetails *pCd)
{
	m_pWatcher->delConnection("Service: " + m_pService->getName(), pCd);
}
///
///   <summary> * Class that implements the connection lister interface.
///   * This internal class will Receive notifications when a subject connection
///   * is added or removed from the realm </summary>
///
nRealmWatch::nRealmWatch(connectionwatch *pWatch) : m_pWatcher(pWatch)
{
}
///
///     <summary> * Notification of a new session connection to the realm </summary>
///
void nRealmWatch::add(nConnectionDetails *pCd)
{
	m_pWatcher->newConnection("Realm: New Connection : ", pCd);
}
///
///     <summary> * Notification of a session connection being removed from the realm </summary>
///
void nRealmWatch::del(nConnectionDetails *pCd)
{
	m_pWatcher->delConnection("Realm: Del Connection : ", pCd);
}
EXAMPLE_SOURCE_END