//..............................................................................
//
// $(pluginName) layer
//

import "doc_Layer.jnc"

//..............................................................................

class $(layerClass):
	doc.Layer,
	log.Filter
{
	ui.BoolProperty* m_txProp;
	ui.BoolProperty* m_rxProp;

	construct(doc.PluginHost* pluginHost);

	override bool filter(
		uint64_t timestamp,
		uint64_t recordCode,
		void const* p,
		size_t size
		);
}

// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

$(layerClass).construct(doc.PluginHost* pluginHost)
{
	basetype.construct(pluginHost);

	m_txProp = m_pluginHost.m_propertyGrid.createBoolProperty("TX", "Show TX records in the log");
	m_rxProp = m_pluginHost.m_propertyGrid.createBoolProperty("RX", "Show RX records in the log");
	m_txProp.m_value = true;
	m_rxProp.m_value = true;

	pluginHost.m_log.addFilter(this);
}

bool $(layerClass).filter(
	uint64_t timestamp,
	uint64_t recordCode,
	void const* p,
	size_t size
	)
{
	switch (recordCode)
	{
	case log.StdRecordCode.Tx:
		return m_txProp.m_value;

	case log.StdRecordCode.Rx:
		return m_rxProp.m_value;

	default:
		return true; // everything else is visible
	}
}

//..............................................................................
