// Revisionist method. QString qtractorMidiClip::createFilePathRevision ( bool bForce ) { QString sFilename = filename(); // Check file-hash reference... if (m_iRevision > 0 && m_pKey) { FileKey fkey(m_pKey); FileHash::ConstIterator fiter = g_hashFiles.constFind(fkey); if (fiter != g_hashFiles.constEnd() && fiter.value() > 1) m_iRevision = 0; } if (m_iRevision == 0 || bForce) { qtractorTrack *pTrack = track(); qtractorSession *pSession = qtractorSession::getInstance(); if (pTrack && pSession) sFilename = pSession->createFilePath(pTrack->trackName(), "mid"); sFilename = qtractorMidiFile::createFilePathRevision(sFilename); #ifdef CONFIG_DEBUG qDebug("qtractorMidiClip::createFilePathRevision(%d): \"%s\" (%d)", int(bForce), sFilename.toUtf8().constData(), m_iRevision); #endif m_iRevision = 0; } ++m_iRevision; return sFilename; }
table& set_function( std::true_type, T&& key, TFx&& fx ) { typedef typename std::decay<TFx>::type clean_fx; std::string fkey( key ); lua_CFunction freefunc = &detail::lua_cfun; auto hint = funcs.find( fkey ); detail::lua_func* target = nullptr; if ( hint == funcs.end( ) ) { std::shared_ptr<detail::lua_func> sptr( new detail::lambda_lua_func<clean_fx>( std::forward<TFx>( fx ) ) ); hint = funcs.emplace_hint( hint, fkey, std::move( sptr ) ); } target = hint->second.get( ); (*target)( state( ) ); }
// Manage local hash key. void qtractorMidiClip::insertHashKey (void) { if (m_pKey) { // Increment file-hash reference... FileKey fkey(m_pKey); FileHash::Iterator fiter = g_hashFiles.find(fkey); if (fiter == g_hashFiles.end()) fiter = g_hashFiles.insert(fkey, 0); ++fiter.value(); // Insert actual clip-hash reference.... g_hashTable.insert(*m_pKey, m_pData); } }
void qtractorMidiClip::removeHashKey (void) { if (m_pKey) { // Decrement file-hash reference... FileKey fkey(m_pKey); FileHash::Iterator fiter = g_hashFiles.find(fkey); if (fiter != g_hashFiles.end()) { if (--fiter.value() < 1) g_hashFiles.remove(fkey); } // Remove actual clip-hash reference.... g_hashTable.remove(*m_pKey); } }
/* -------------------------------------------------------------------- */ BOOL KBReady(void) { int c; if (getkey) return (TRUE); if (kbhit()) { c = getch(); if (!c) { fkey(); return (FALSE); } else ungetch(c); getkey = 1; return (TRUE); } else return (FALSE); }