<commit_before>/*************************************************************************
 * Copyright (c) 2013 eProsima. All rights reserved.
 *
 * This copy of FastCdr is licensed to you under the terms described in the
 * EPROSIMARTPS_LIBRARY_LICENSE file included in this distribution.
 *
 *************************************************************************/

/*
 * StatelessWriter.cpp
 *
 *  Created on: Feb 25, 2014
 *      Author: <NAME>
 *      email:  <EMAIL>
 *              <EMAIL>
 */

#include "eprosimartps/writer/StatelessWriter.h"
#include "eprosimartps/writer/ReaderLocator.h"
#include "eprosimartps/dds/ParameterList.h"

namespace eprosima {
namespace rtps {



StatelessWriter::StatelessWriter(const WriterParams_t* param,uint32_t payload_size):
		RTPSWriter(param->historySize,payload_size)
{
	m_pushMode = param->pushMode;
	//writer_cache.changes.reserve(param->historySize);

	m_stateType = STATELESS;
	//locator lists:
	unicastLocatorList = param->unicastLocatorList;
	multicastLocatorList = param->multicastLocatorList;
	topicKind = param->topicKind;
	m_topicName = param->topicName;
	m_topicDataType = param->topicDataType;
	this->m_userDefinedId = param->userDefinedId;
}




StatelessWriter::~StatelessWriter()
{

	pDebugInfo("StatelessWriter destructor"<<endl;);
}

bool StatelessWriter::reader_locator_add(ReaderLocator& a_locator) {

	for(std::vector<ReaderLocator>::iterator rit=reader_locator.begin();rit!=reader_locator.end();++rit){
		if(rit->locator == a_locator.locator)
			return false;
	}
	a_locator.requested_changes.clear();
	a_locator.unsent_changes.clear();
	for(std::vector<CacheChange_t*>::iterator it = m_writer_cache.m_changes.begin();
			it!=m_writer_cache.m_changes.end();++it){
		a_locator.unsent_changes.push_back((*it));
	}
	reader_locator.push_back(a_locator);
	return true;
}

bool StatelessWriter::reader_locator_remove(Locator_t& locator) {
	std::vector<ReaderLocator>::iterator it;
	for(it=reader_locator.begin();it!=reader_locator.end();++it){<commit_msg>Fixed StatelessWriter when adding new reader locator<commit_after>/*************************************************************************
 * Copyright (c) 2013 eProsima. All rights reserved.
 *
 * This copy of FastCdr is licensed to you under the terms described in the
 * EPROSIMARTPS_LIBRARY_LICENSE file included in this distribution.
 *
 *************************************************************************/

/*
 * StatelessWriter.cpp
 *
 *  Created on: Feb 25, 2014
 *      Author: <NAME>
 *      email:  <EMAIL>
 *              <EMAIL>
 */

#include "eprosimartps/writer/StatelessWriter.h"
#include "eprosimartps/writer/ReaderLocator.h"
#include "eprosimartps/dds/ParameterList.h"

namespace eprosima {
namespace rtps {



StatelessWriter::StatelessWriter(const WriterParams_t* param,uint32_t payload_size):
		RTPSWriter(param->historySize,payload_size)
{
	m_pushMode = param->pushMode;
	//writer_cache.changes.reserve(param->historySize);

	m_stateType = STATELESS;
	//locator lists:
	unicastLocatorList = param->unicastLocatorList;
	multicastLocatorList = param->multicastLocatorList;
	topicKind = param->topicKind;
	m_topicName = param->topicName;
	m_topicDataType = param->topicDataType;
	this->m_userDefinedId = param->userDefinedId;
}




StatelessWriter::~StatelessWriter()
{

	pDebugInfo("StatelessWriter destructor"<<endl;);
}

bool StatelessWriter::reader_locator_add(ReaderLocator& a_locator) {

	for(std::vector<ReaderLocator>::iterator rit=reader_locator.begin();rit!=reader_locator.end();++rit){
		if(rit->locator == a_locator.locator)
			return false;
	}
	a_locator.requested_changes.clear();
	a_locator.unsent_changes.clear();
	for(std::vector<CacheChange_t*>::iterator it = m_writer_cache.m_changes.begin();
			it!=m_writer_cache.m_changes.end();++it){
		a_locator.unsent_changes.push_back((*it));
	}
	reader_locator.push_back(a_locator);
	if(!a_locator.unsent_changes.empty())
		this->unsent_changes_not_empty();
	return true;
}

bool StatelessWriter::reader_locator_remove(Locator_t& locator) {
	std::vector<ReaderLocator>::iterator it;
	for(it=reader_locator.begin();it!=reader_locator.end();++it){
{'fraction_non_alphanumeric': 0.19132530120481928, 'fraction_numerical': 0.005783132530120482, 'mean_word_length': 6.452423698384201, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 38, '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': '2472482', 'n_tokens_mistral': 1436, 'n_tokens_neox': 1370, 'n_words': 209}