int FloatingObject::PrepareTimePointing(FunctorParams *functorParams) { // Pass it to the pseudo functor of the interface if (this->HasInterface(INTERFACE_TIME_POINT)) { TimePointInterface *interface = this->GetTimePointInterface(); assert(interface); return interface->InterfacePrepareTimePointing(functorParams, this); } return FUNCTOR_CONTINUE; }
int F::PrepareTimePointing(FunctorParams *functorParams) { // At this stage we require <f> to have a @startid - eventually we can // modify this method and set as start the parent <harm> so @startid would not be // required anymore // Pass it to the pseudo functor of the interface TimePointInterface *interface = this->GetTimePointInterface(); assert(interface); return interface->InterfacePrepareTimePointing(functorParams, this); }
int Measure::FillStaffCurrentTimeSpanningEnd(FunctorParams *functorParams) { FillStaffCurrentTimeSpanningParams *params = dynamic_cast<FillStaffCurrentTimeSpanningParams *>(functorParams); assert(params); std::vector<Object *>::iterator iter = params->m_timeSpanningElements.begin(); while (iter != params->m_timeSpanningElements.end()) { Measure *endParent = NULL; if ((*iter)->HasInterface(INTERFACE_TIME_SPANNING)) { TimeSpanningInterface *interface = (*iter)->GetTimeSpanningInterface(); assert(interface); if (interface->GetEnd()) { endParent = dynamic_cast<Measure *>(interface->GetEnd()->GetFirstParent(MEASURE)); } } if (!endParent && (*iter)->HasInterface(INTERFACE_LINKING)) { LinkingInterface *interface = (*iter)->GetLinkingInterface(); assert(interface); if (interface->GetNextLink()) { // We should have one because we allow only control Event (dir and dynam) to be linked as target TimePointInterface *nextInterface = interface->GetNextLink()->GetTimePointInterface(); assert(nextInterface); endParent = dynamic_cast<Measure *>(nextInterface->GetStart()->GetFirstParent(MEASURE)); } } assert(endParent); // We have reached the end of the spanning - remove it from the list of running elements if (endParent == this) { iter = params->m_timeSpanningElements.erase(iter); } else { ++iter; } } return FUNCTOR_CONTINUE; }
int Measure::PrepareTimestampsEnd(FunctorParams *functorParams) { PrepareTimestampsParams *params = dynamic_cast<PrepareTimestampsParams *>(functorParams); assert(params); ArrayOfObjectBeatPairs::iterator iter = params->m_tstamps.begin(); // Loop throught the object/beat pairs and create the TimestampAttr when necessary while (iter != params->m_tstamps.end()) { // -1 means that we have a @tstamp (start) to add to the current measure if ((*iter).second.first == -1) { TimePointInterface *interface = ((*iter).first)->GetTimePointInterface(); assert(interface); TimestampAttr *timestampAttr = m_timestampAligner.GetTimestampAtTime((*iter).second.second); interface->SetStart(timestampAttr); // purge the list of unmatched element is this is a TimeSpanningInterface element if ((*iter).first->HasInterface(INTERFACE_TIME_SPANNING)) { TimeSpanningInterface *tsInterface = ((*iter).first)->GetTimeSpanningInterface(); assert(tsInterface); if (tsInterface->HasStartAndEnd()) { auto item = std::find_if(params->m_timeSpanningInterfaces.begin(), params->m_timeSpanningInterfaces.end(), [tsInterface](std::pair<TimeSpanningInterface *, ClassId> pair) { return (pair.first == tsInterface); }); if (item != params->m_timeSpanningInterfaces.end()) { // LogDebug("Found it!"); params->m_timeSpanningInterfaces.erase(item); } } } // remove it iter = params->m_tstamps.erase(iter); } // 0 means that we have a @tstamp2 (end) to add to the current measure else if ((*iter).second.first == 0) { TimeSpanningInterface *interface = ((*iter).first)->GetTimeSpanningInterface(); assert(interface); TimestampAttr *timestampAttr = m_timestampAligner.GetTimestampAtTime((*iter).second.second); interface->SetEnd(timestampAttr); // We can check if the interface is now fully mapped (start / end) and purge the list of unmatched // elements if (interface->HasStartAndEnd()) { auto item = std::find_if(params->m_timeSpanningInterfaces.begin(), params->m_timeSpanningInterfaces.end(), [interface]( std::pair<TimeSpanningInterface *, ClassId> pair) { return (pair.first == interface); }); if (item != params->m_timeSpanningInterfaces.end()) { // LogDebug("Found it!"); params->m_timeSpanningInterfaces.erase(item); } } iter = params->m_tstamps.erase(iter); } // we have not reached the correct end measure yet else { (*iter).second.first--; ++iter; } } return FUNCTOR_CONTINUE; }