<commit_before>#ifndef RDO_PATTERN_H
#define RDO_PATTERN_H

#include "rdo_lib/rdo_runtime/rdotrace.h"
#include "rdo_lib/rdo_runtime/rdo_resource.h"
#include "rdo_lib/rdo_runtime/rdocalc.h"

namespace rdoRuntime {

class RDORuntime;
class RDOIrregEvent;
class RDORule;
class RDOKeyboard;

// ----------------------------------------------------------------------------
// ---------- RDOPattern
// ----------------------------------------------------------------------------
class RDOPattern: public RDORuntimeParent, public RDOTraceableObject
{
public:
	void addPreSelectRelRes(CREF(LPRDOCalc) pCalc)
	{
		CalcList::iterator it = m_preSelectRelRes.begin();
		while ( it != m_preSelectRelRes.end() )
		{
			if ((*it)->compare(pCalc))
			{
				return;
			}
			it++;
		}
		m_preSelectRelRes.push_back(pCalc);
	}

protected:
	RDOPattern( PTR(RDORuntime) runtime, bool trace );
	virtual ~RDOPattern() {}

	typedef  std::vector<LPRDOCalc>                   CalcList;
	typedef  std::vector<RDOResource::ConvertStatus>  ConvertStatusList;

	CalcList m_preSelectRelRes;

	void preSelectRelRes(PTR(RDORuntime) runtime)
	{
		runCalcs(m_preSelectRelRes, runtime);
	}

	void runCalcs(REF(CalcList) calcList, PTR(RDORuntime) runtime)
	{
		STL_FOR_ALL(CalcList, calcList, calcIt)
			(*calcIt)->calcValue(runtime);
	}
	bool runCalcsBool(REF(CalcList) calcList, PTR(RDORuntime) runtime)
	{
		STL_FOR_ALL(CalcList, calcList, calcIt)
		{
			if ( !(*calcIt)->calcValue( runtime ).getAsBool() ) return false;
		}
		return true;
	}
};

// ----------------------------------------------------------------------------
// ---------- RDOPatternIrregEvent
// ----------------------------------------------------------------------------
class RDOPatternIrregEvent: public RDOPattern
{
friend class RDOIrregEvent;

public:
	RDOPatternIrregEvent( PTR(RDORuntime) rTime, bool trace );

	void addConvertorCalc  ( CREF(LPRDOCalc) pCalc             ) { m_convertor.push_back( pCalc );        }
	void addConvertorStatus( RDOResource::ConvertStatus status ) { m_convertorStatus.push_back( status ); }
	void addEraseCalc      ( CREF(LPRDOCalc) pCalc             ) { m_erase.push_back( pCalc );            }
	void setTime           ( CREF(LPRDOCalc) timeCalc          ) { m_timeCalc = timeCalc;	              }

	void convertEvent(PTR(RDORuntime) runtime)
	{
		preSelectRelRes(runtime);
		runCalcs(m_convertor, runtime);
	}
	void convertErase(PTR(RDORuntime) runtime)
	{
		runCalcs(m_erase, runtime);
	}

	double getNextTimeInterval( PTR(RDORuntime) runtime );

	LPIIrregEvent createActivity(LPIBaseOperationContainer parent, PTR(RDORuntime) runtime, CREF(tstring) oprName);

private:
	LPRDOCalc         m_timeCalc;
	CalcList          m_convertor;
	ConvertStatusList m_convertorStatus;
	CalcList          m_erase;
};

// ----------------------------------------------------------------------------
// ---------- RDOPatternEvent
// ----------------------------------------------------------------------------
class RDOPatternEvent: public RDOPattern
{
friend class RDOEvent;

public:
	RDOPatternEvent( PTR(RDORuntime) rTime, bool trace );

	void addConvertorCalc  ( CREF(LPRDOCalc) pCalc                 ) { m_convertor.push_back( pCalc );        }
	void addConvertorStatus( RDOResource::ConvertStatus status     ) { m_convertorStatus.push_back( status ); }
	void addEraseCalc      ( PTR(RDOCalc) calc                     ) { m_erase.push_back( calc );             }

	void convertEvent( PTR(RDORuntime) runtime )
	{
		preSelectRelRes( runtime );
		runCalcs( m_convertor, runtime );
	}
	void convertErase( PTR(RDORuntime) runtime )
	{
		runCalcs( m_erase, runtime );
	}

	LPIEvent createActivity(LPIBaseOperationContainer parent, PTR(RDORuntime) runtime, CREF(tstring) oprName);

private:
	std::vector< PTR(RDOCalc) >                   m_convertor;
	std::vector< RDOResource::ConvertStatus >     m_convertorStatus;
	std::vector< PTR(RDOCalc) >                   m_erase;
};

// ----------------------------------------------------------------------------
// ---------- RDOPatternRule
// ----------------------------------------------------------------------------
class RDOPatternRule: public RDOPattern
{
friend class RDORule;

public:
	RDOPatternRule( PTR(RDORuntime) rTime, bool trace );

	void addChoiceFromCalc ( CREF(LPRDOCalc) pCalc             ) { m_choiceFrom.push_back( pCalc );       }
	void addConvertorCalc  ( CREF(LPRDOCalc) pCalc             ) { m_convertor.push_back( pCalc );        }
	void addConvertorStatus( RDOResource::ConvertStatus status ) { m_convertorStatus.push_back( status ); }
	void addEraseCalc      ( CREF(LPRDOCalc) pCalc             ) { m_erase.push_back( pCalc );            }

	bool choiceFrom( PTR(RDORuntime) runtime )
	{
		preSelectRelRes( runtime );
		return runCalcsBool( m_choiceFrom, runtime );<commit_msg> - fix after merge<commit_after>#ifndef RDO_PATTERN_H
#define RDO_PATTERN_H

#include "rdo_lib/rdo_runtime/rdotrace.h"
#include "rdo_lib/rdo_runtime/rdo_resource.h"
#include "rdo_lib/rdo_runtime/rdocalc.h"

namespace rdoRuntime {

class RDORuntime;
class RDOIrregEvent;
class RDORule;
class RDOKeyboard;

// ----------------------------------------------------------------------------
// ---------- RDOPattern
// ----------------------------------------------------------------------------
class RDOPattern: public RDORuntimeParent, public RDOTraceableObject
{
public:
	void addPreSelectRelRes(CREF(LPRDOCalc) pCalc)
	{
		CalcList::iterator it = m_preSelectRelRes.begin();
		while ( it != m_preSelectRelRes.end() )
		{
			if ((*it)->compare(pCalc))
			{
				return;
			}
			it++;
		}
		m_preSelectRelRes.push_back(pCalc);
	}

protected:
	RDOPattern( PTR(RDORuntime) runtime, bool trace );
	virtual ~RDOPattern() {}

	typedef  std::vector<LPRDOCalc>                   CalcList;
	typedef  std::vector<RDOResource::ConvertStatus>  ConvertStatusList;

	CalcList m_preSelectRelRes;

	void preSelectRelRes(PTR(RDORuntime) runtime)
	{
		runCalcs(m_preSelectRelRes, runtime);
	}

	void runCalcs(REF(CalcList) calcList, PTR(RDORuntime) runtime)
	{
		STL_FOR_ALL(CalcList, calcList, calcIt)
			(*calcIt)->calcValue(runtime);
	}
	bool runCalcsBool(REF(CalcList) calcList, PTR(RDORuntime) runtime)
	{
		STL_FOR_ALL(CalcList, calcList, calcIt)
		{
			if ( !(*calcIt)->calcValue( runtime ).getAsBool() ) return false;
		}
		return true;
	}
};

// ----------------------------------------------------------------------------
// ---------- RDOPatternIrregEvent
// ----------------------------------------------------------------------------
class RDOPatternIrregEvent: public RDOPattern
{
friend class RDOIrregEvent;

public:
	RDOPatternIrregEvent( PTR(RDORuntime) rTime, bool trace );

	void addConvertorCalc  ( CREF(LPRDOCalc) pCalc             ) { m_convertor.push_back( pCalc );        }
	void addConvertorStatus( RDOResource::ConvertStatus status ) { m_convertorStatus.push_back( status ); }
	void addEraseCalc      ( CREF(LPRDOCalc) pCalc             ) { m_erase.push_back( pCalc );            }
	void setTime           ( CREF(LPRDOCalc) timeCalc          ) { m_timeCalc = timeCalc;	              }

	void convertEvent(PTR(RDORuntime) runtime)
	{
		preSelectRelRes(runtime);
		runCalcs(m_convertor, runtime);
	}
	void convertErase(PTR(RDORuntime) runtime)
	{
		runCalcs(m_erase, runtime);
	}

	double getNextTimeInterval( PTR(RDORuntime) runtime );

	LPIIrregEvent createActivity(LPIBaseOperationContainer parent, PTR(RDORuntime) runtime, CREF(tstring) oprName);

private:
	LPRDOCalc         m_timeCalc;
	CalcList          m_convertor;
	ConvertStatusList m_convertorStatus;
	CalcList          m_erase;
};

// ----------------------------------------------------------------------------
// ---------- RDOPatternEvent
// ----------------------------------------------------------------------------
class RDOPatternEvent: public RDOPattern
{
friend class RDOEvent;

public:
	RDOPatternEvent( PTR(RDORuntime) rTime, bool trace );

	void addConvertorCalc  ( CREF(LPRDOCalc) pCalc             ) { m_convertor.push_back( pCalc );        }
	void addConvertorStatus( RDOResource::ConvertStatus status ) { m_convertorStatus.push_back( status ); }
	void addEraseCalc      ( CREF(LPRDOCalc) pCalc             ) { m_erase.push_back( pCalc );            }

	void convertEvent( PTR(RDORuntime) runtime )
	{
		preSelectRelRes( runtime );
		runCalcs( m_convertor, runtime );
	}
	void convertErase( PTR(RDORuntime) runtime )
	{
		runCalcs( m_erase, runtime );
	}

	LPIEvent createActivity(LPIBaseOperationContainer parent, PTR(RDORuntime) runtime, CREF(tstring) oprName);

private:
	CalcList          m_convertor;
	ConvertStatusList m_convertorStatus;
	CalcList          m_erase;
};

// ----------------------------------------------------------------------------
// ---------- RDOPatternRule
// ----------------------------------------------------------------------------
class RDOPatternRule: public RDOPattern
{
friend class RDORule;

public:
	RDOPatternRule( PTR(RDORuntime) rTime, bool trace );

	void addChoiceFromCalc ( CREF(LPRDOCalc) pCalc             ) { m_choiceFrom.push_back( pCalc );       }
	void addConvertorCalc  ( CREF(LPRDOCalc) pCalc             ) { m_convertor.push_back( pCalc );        }
	void addConvertorStatus( RDOResource::ConvertStatus status ) { m_convertorStatus.push_back( status ); }
	void addEraseCalc      ( CREF(LPRDOCalc) pCalc             ) { m_erase.push_back( pCalc );            }

	bool choiceFrom( PTR(RDORuntime) runtime )
	{
		preSelectRelRes( runtime );
		return runCalcsBool( m_choiceFrom, runtime );
{'fraction_non_alphanumeric': 0.22556943423952977, 'fraction_numerical': 0.0, 'mean_word_length': 2.1393739703459635, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 16, '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': '4888370', 'n_tokens_mistral': 3236, 'n_tokens_neox': 3043, 'n_words': 540}