@@ -170,6 +170,29 @@ uint16 InfoObjectCommon::getSourceTypeIndex() const
170170 return m_sourceTypeIndex;
171171}
172172
173+ bool InfoObjectCommon::operator ==(const InfoObjectCommon& other) const
174+ {
175+ return isEqual (other);
176+ }
177+
178+ bool InfoObjectCommon::isEqual (const InfoObjectCommon& other) const
179+ {
180+ return isEqual (other, false );
181+ }
182+
183+ bool InfoObjectCommon::isSimilar (const InfoObjectCommon& other) const
184+ {
185+ return isEqual (other, true );
186+ }
187+
188+ bool InfoObjectCommon::isEqual (const InfoObjectCommon& other, bool similar) const
189+ {
190+ if (getInfoObjectType () != other.getInfoObjectType ()) return false ;
191+ if (m_sampleRate != other.m_sampleRate ) return false ;
192+ if (!similar && getIdentifier ().trim () != other.getIdentifier ().trim ()) return false ;
193+ return checkEqual (other, similar);
194+ }
195+
173196// DataChannel
174197
175198DataChannel::DataChannel (DataChannelTypes type, float sampleRate, GenericProcessor* source, uint16 subproc) :
@@ -297,6 +320,16 @@ void DataChannel::setDefaultNameAndDescription()
297320 setIdentifier (" genericdata.continuous" );
298321}
299322
323+ bool DataChannel::checkEqual (const InfoObjectCommon& other, bool similar) const
324+ {
325+ const DataChannel& o = dynamic_cast <const DataChannel&>(other);
326+ if (m_bitVolts != o.m_bitVolts ) return false ;
327+ if (!similar && m_unitName != o.m_unitName ) return false ;
328+ if (similar)
329+ return hasSimilarMetadata (o);
330+ else return hasSameMetadata (o);
331+ }
332+
300333// EventChannel
301334EventChannel::EventChannel (EventChannelTypes type, unsigned int nChannels, unsigned int dataLength, float sampleRate, GenericProcessor* source, uint16 subproc)
302335 : InfoObjectCommon(source->eventChannelCount++, source->eventChannelTypeCount[type]++, sampleRate, source, subproc),
@@ -418,6 +451,56 @@ void EventChannel::setDefaultNameAndDescription()
418451 setIdentifier (" genericevent" );
419452}
420453
454+
455+ BaseType EventChannel::getEquivalentMetaDataType (const EventChannel& ev)
456+ {
457+ switch (ev.getChannelType ())
458+ {
459+ case EventChannel::TEXT:
460+ return MetaDataDescriptor::CHAR;
461+ case EventChannel::INT8_ARRAY:
462+ return MetaDataDescriptor::INT8;
463+ case EventChannel::UINT8_ARRAY:
464+ return MetaDataDescriptor::UINT8;
465+ case EventChannel::INT16_ARRAY:
466+ return MetaDataDescriptor::INT16;
467+ case EventChannel::UINT16_ARRAY:
468+ return MetaDataDescriptor::UINT16;
469+ case EventChannel::INT32_ARRAY:
470+ return MetaDataDescriptor::INT32;
471+ case EventChannel::UINT32_ARRAY:
472+ return MetaDataDescriptor::UINT32;
473+ case EventChannel::INT64_ARRAY:
474+ return MetaDataDescriptor::INT64;
475+ case EventChannel::UINT64_ARRAY:
476+ return MetaDataDescriptor::UINT64;
477+ case EventChannel::FLOAT_ARRAY:
478+ return MetaDataDescriptor::FLOAT;
479+ case EventChannel::DOUBLE_ARRAY:
480+ return MetaDataDescriptor::DOUBLE;
481+ default :
482+ return MetaDataDescriptor::UINT8;
483+ }
484+ }
485+
486+ BaseType EventChannel::getEquivalentMetaDataType () const
487+ {
488+ return getEquivalentMetaDataType (*this );
489+ }
490+
491+ bool EventChannel::checkEqual (const InfoObjectCommon& other, bool similar) const
492+ {
493+ const EventChannel& o = dynamic_cast <const EventChannel&>(other);
494+ if (m_type != o.m_type ) return false ;
495+ if (m_numChannels != o.m_numChannels ) return false ;
496+ if (m_length != o.m_length ) return false ;
497+ if (similar && !hasSimilarMetadata (o)) return false ;
498+ if (!similar && !hasSameMetadata (o)) return false ;
499+ if (similar && !hasSimilarEventMetadata (o)) return false ;
500+ if (!similar && !hasSameEventMetadata (o)) return false ;
501+ return true ;
502+ }
503+
421504// SpikeChannel
422505
423506SpikeChannel::SpikeChannel (ElectrodeTypes type, GenericProcessor* source, const Array<const DataChannel*>& sourceChannels, uint16 subproc)
@@ -549,6 +632,27 @@ void SpikeChannel::setDefaultNameAndDescription()
549632 setIdentifier (" spikesource" );
550633}
551634
635+ bool SpikeChannel::checkEqual (const InfoObjectCommon& other, bool similar) const
636+ {
637+ const SpikeChannel& o = dynamic_cast <const SpikeChannel&>(other);
638+ if (m_type != o.m_type ) return false ;
639+ if (m_numPostSamples != o.m_numPostSamples ) return false ;
640+ if (m_numPreSamples != o.m_numPreSamples ) return false ;
641+
642+ int nChans = m_channelBitVolts.size ();
643+ if (nChans != o.m_channelBitVolts .size ()) return false ;
644+ for (int i = 0 ; i < nChans; i++)
645+ {
646+ if (m_channelBitVolts[i] != o.m_channelBitVolts [i]) return false ;
647+ }
648+
649+ if (similar && !hasSimilarMetadata (o)) return false ;
650+ if (!similar && !hasSameMetadata (o)) return false ;
651+ if (similar && !hasSimilarEventMetadata (o)) return false ;
652+ if (!similar && !hasSameEventMetadata (o)) return false ;
653+ return true ;
654+ }
655+
552656// ConfigurationObject
553657ConfigurationObject::ConfigurationObject (String identifier, GenericProcessor* source, uint16 subproc)
554658 : SourceProcessorInfo(source, subproc)
0 commit comments