<commit_before>#ifndef _BULK_DATA_NT_RECEIVER_STREAM_H_
#define _BULK_DATA_NT_RECEIVER_STREAM_H_
/*******************************************************************************
 * ALMA - Atacama Large Millimiter Array
 * (c) European Southern Observatory, 2011
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 *
 * "@(#) $Id: bulkDataNTReceiverStream.h,v 1.19 2012/09/06 10:50:30 bjeram Exp $"
 *
 * who       when      what
 * --------  --------  ----------------------------------------------
 * bjeram  2011-04-19  created
 */

/************************************************************************
 *
 *----------------------------------------------------------------------
 */

#ifndef __cplusplus
#error This is a C++ include file and cannot be used from plain C
#endif

#include "bulkDataNTStream.h"
#include "bulkDataNTReceiverFlow.h"
#include <map>

namespace AcsBulkdata
{



//TBD: actually we can move lots of stuff from BulkDataNTReceiverStream template class which do not depend on template parameter
class BulkDataNTReceiverStreamBase : public BulkDataNTStream
{
public:
	BulkDataNTReceiverStreamBase(const char* streamName, const ReceiverStreamConfiguration &cfg):
		BulkDataNTStream(streamName, cfg), receiverName_m("DefaultReceiver") {}

	BulkDataNTReceiverStreamBase( const char* receiverName, const char* streamName, const ReceiverStreamConfiguration &cfg):
			BulkDataNTStream(streamName, cfg), receiverName_m(receiverName){}

	/**
	 * Set receiver name (in receiver callback). Nothing to do with stream/flow name!
	 * @param recvName the name of receiver
	 */
	void setReceiverName(char * recvName) { receiverName_m = recvName; }

	/**
	 * Set receiver name (in receiver callback). Nothing to do with stream/flow name!
	 * @param recvName
	 */
	void setReceiverName(const char * recvName) { receiverName_m = recvName; }

	/**
	 * Gives the name (of previously set) receiver name
	 * @return receiver name
	 */
	const char* getReceiverName() { return receiverName_m.c_str(); }

protected:

	std::string receiverName_m;

};//BulkDataNTReceiverStreamBase

template<class TReceiverCallback>
class BulkDataNTReceiverStream : public BulkDataNTReceiverStreamBase

//, public AcsBulkdata::BulkDataNTDDSSubscriber

{
public:

	/**
	 * Receiver stream constructor where we do not specify receiver name.
	 * Receiver name can be specified later using #setReceiverName method
	 * @param streamName name of the stream that will be create
	 * @param cfg configuration (optional)
	 * @exception #StreamCreateProblemExImpl
	 */
	BulkDataNTReceiverStream(const char* streamName, const ReceiverStreamConfiguration &cfg=ReceiverStreamConfiguration(), bool enabledCallingCBforAllFlows=true);

	/**
	 * Receiver stream constructor where we specify receiver name.
	 * @param receiverName receiver's name that it is easier to distinguish between differnet receivers in the ssytem.<commit_msg>- added member: flowUnicastPort_m where unicat (if used) port is stored - added getNextFlowUnicastPort() method which returns port for flow (if unicast)<commit_after>#ifndef _BULK_DATA_NT_RECEIVER_STREAM_H_
#define _BULK_DATA_NT_RECEIVER_STREAM_H_
/*******************************************************************************
 * ALMA - Atacama Large Millimiter Array
 * (c) European Southern Observatory, 2011
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 *
 * "@(#) $Id: bulkDataNTReceiverStream.h,v 1.20 2012/10/15 09:46:17 bjeram Exp $"
 *
 * who       when      what
 * --------  --------  ----------------------------------------------
 * bjeram  2011-04-19  created
 */

/************************************************************************
 *
 *----------------------------------------------------------------------
 */

#ifndef __cplusplus
#error This is a C++ include file and cannot be used from plain C
#endif

#include "bulkDataNTStream.h"
#include "bulkDataNTReceiverFlow.h"
#include <map>

namespace AcsBulkdata
{



//TBD: actually we can move lots of stuff from BulkDataNTReceiverStream template class which do not depend on template parameter
class BulkDataNTReceiverStreamBase : public BulkDataNTStream
{
public:
	BulkDataNTReceiverStreamBase(const char* streamName, const ReceiverStreamConfiguration &cfg):
		BulkDataNTStream(streamName, cfg), receiverName_m("DefaultReceiver")
	{
		flowUnicastPort_m = (cfg.isUseIncrementUnicastPort()) ? (cfg.getBaseUnicastPort()) : 0;
	}

	BulkDataNTReceiverStreamBase( const char* receiverName, const char* streamName, const ReceiverStreamConfiguration &cfg):
			BulkDataNTStream(streamName, cfg), receiverName_m(receiverName)
	{
		flowUnicastPort_m = (cfg.isUseIncrementUnicastPort()) ? (cfg.getBaseUnicastPort()) : ReceiverFlowConfiguration::DEFAULT_UNICAST_PORT/*=0*/;
	}

	/**
	 * Set receiver name (in receiver callback). Nothing to do with stream/flow name!
	 * @param recvName the name of receiver
	 */
	void setReceiverName(char * recvName) { receiverName_m = recvName; }

	/**
	 * Set receiver name (in receiver callback). Nothing to do with stream/flow name!
	 * @param recvName
	 */
	void setReceiverName(const char * recvName) { receiverName_m = recvName; }

	/**
	 * Gives the name (of previously set) receiver name
	 * @return receiver name
	 */
	const char* getReceiverName() { return receiverName_m.c_str(); }

	/**
	 * Returns next flow unicast port, and prepare the next one (increment by one) that will be returned by next call.
	 * If useIncrementUnicastPort was set to false it returns #ReceiverFlowConfiguration::DEFAULT_UNICAST_PORT (=0) (and does not increment)
	 */
	unsigned short getNextFlowUnicastPort()
	{
		unsigned short port=flowUnicastPort_m;
		if (flowUnicastPort_m!=ReceiverFlowConfiguration::DEFAULT_UNICAST_PORT/*=0*/) flowUnicastPort_m++;
		return port;
	}

protected:

	std::string receiverName_m;
	unsigned short flowUnicastPort_m; /// if we decide to use incremental port number for flow (unicast)

};//BulkDataNTReceiverStreamBase

template<class TReceiverCallback>
class BulkDataNTReceiverStream : public BulkDataNTReceiverStreamBase

//, public AcsBulkdata::BulkDataNTDDSSubscriber

{
public:

	/**
	 * Receiver stream constructor where we do not specify receiver name.
	 * Receiver name can be specified later using #setReceiverName method
	 * @param streamName name of the stream that will be create
	 * @param cfg configuration (optional)
	 * @exception #StreamCreateProblemExImpl
	 */
	BulkDataNTReceiverStream(const char* streamName, const ReceiverStreamConfiguration &cfg=ReceiverStreamConfiguration(), bool enabledCallingCBforAllFlows=true);

	/**
	 * Receiver stream constructor where we specify receiver name.
	 * @param receiverName receiver's name that it is easier to distinguish between differnet receivers in the ssytem.
{'fraction_non_alphanumeric': 0.14188939524571992, 'fraction_numerical': 0.01157778051484173, 'mean_word_length': 4.162110616656071, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4555092', 'n_tokens_mistral': 2325, 'n_tokens_neox': 2161, 'n_words': 794}