<commit_before>// Copyright (c) <NAME>, 2015. All rights reserved. PROVIDED "AS IS"
// WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. See LICENSE file for details.

package sim

import (
	"log"

	"my/itto/verify/packet"
	"my/itto/verify/packet/itto"
)

type SimMessage struct {
	Pam     packet.ApplicationMessage
	Session *Session
	sim     Sim
}

func NewSimMessage(sim Sim, pam packet.ApplicationMessage) *SimMessage {
	s := sim.Session(pam.Flow())
	m := &SimMessage{
		Pam:     pam,
		Session: &s,
		sim:     sim,
	}
	return m
}

func (m *SimMessage) IgnoredBySubscriber() bool {
	if m.sim.Subscr() == nil {
		return false
	}
	var oid packet.OptionId
	switch im := m.Pam.Layer().(type) {
	case *itto.IttoMessageAddOrder:
		oid = im.OId
	case *itto.IttoMessageAddQuote:
		oid = im.OId
	case *itto.IttoMessageOptionsTrade:
		oid = im.OId
	case *itto.IttoMessageOptionsCrossTrade:
		oid = im.OId
	}
	return oid.Valid() && !m.sim.Subscr().Subscribed(oid)
}

func (m *SimMessage) MessageOperations() []SimOperation {
	var ops []SimOperation
	addOperation := func(origOrderId packet.OrderId, operation SimOperation) {
		opop := operation.getOperation()
		opop.m = m
		opop.sim = m.sim
		opop.origOrderId = origOrderId
		ops = append(ops, operation)
	}
	addOperationReplace := func(origOrderId packet.OrderId, orderSide itto.OrderSide) {
		opRemove := &OperationRemove{}
		opAdd := &OperationAdd{
			// unknown: optionId; maybe unknown: OrderSide.Side
			order:     orderFromItto(packet.OptionIdUnknown, orderSide),
			Operation: Operation{sibling: opRemove},
		}
		addOperation(origOrderId, opRemove)
		addOperation(packet.OrderIdUnknown, opAdd)
	}
	switch im := m.Pam.Layer().(type) {
	case *itto.IttoMessageAddOrder:
		var oid packet.OptionId
		if !m.IgnoredBySubscriber() {<commit_msg>sim:SimMessage: use packet.TradeMessage interface<commit_after>// Copyright (c) <NAME>, 2015. All rights reserved. PROVIDED "AS IS"
// WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. See LICENSE file for details.

package sim

import (
	"log"

	"my/itto/verify/packet"
	"my/itto/verify/packet/itto"
)

type SimMessage struct {
	Pam     packet.ApplicationMessage
	Session *Session
	sim     Sim
}

func NewSimMessage(sim Sim, pam packet.ApplicationMessage) *SimMessage {
	s := sim.Session(pam.Flow())
	m := &SimMessage{
		Pam:     pam,
		Session: &s,
		sim:     sim,
	}
	return m
}

func (m *SimMessage) IgnoredBySubscriber() bool {
	if m.sim.Subscr() == nil {
		return false
	}
	var oid packet.OptionId
	if m, ok := m.Pam.Layer().(packet.TradeMessage); ok {
		oid, _, _ = m.TradeInfo()
	}
	return oid.Valid() && !m.sim.Subscr().Subscribed(oid)
}

func (m *SimMessage) MessageOperations() []SimOperation {
	var ops []SimOperation
	addOperation := func(origOrderId packet.OrderId, operation SimOperation) {
		opop := operation.getOperation()
		opop.m = m
		opop.sim = m.sim
		opop.origOrderId = origOrderId
		ops = append(ops, operation)
	}
	addOperationReplace := func(origOrderId packet.OrderId, orderSide itto.OrderSide) {
		opRemove := &OperationRemove{}
		opAdd := &OperationAdd{
			// unknown: optionId; maybe unknown: OrderSide.Side
			order:     orderFromItto(packet.OptionIdUnknown, orderSide),
			Operation: Operation{sibling: opRemove},
		}
		addOperation(origOrderId, opRemove)
		addOperation(packet.OrderIdUnknown, opAdd)
	}
	switch im := m.Pam.Layer().(type) {
	case *itto.IttoMessageAddOrder:
		var oid packet.OptionId
		if !m.IgnoredBySubscriber() {
{'fraction_non_alphanumeric': 0.12634643377001456, 'fraction_numerical': 0.0023289665211062593, 'mean_word_length': 4.113095238095238, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5965031', 'n_tokens_mistral': 1263, 'n_tokens_neox': 1196, 'n_words': 287}