int main() { Impl i; i.enter_state(active_open{}, closed{}, listen{}); i.enter_state(passive_open{}, closed{}, listen{}); i.enter_state(send_syn{}, closed{}, syn_sent{}); }
void put(const K& k, U v) { if (!v) impl.erase(k); else impl.insert(k, std::move(v)); }
static OSStatus OutputIOProc(AudioDeviceID inDevice, const AudioTimeStamp* /*inNow*/, const AudioBufferList* /*inputData*/, const AudioTimeStamp* /*inInputTime*/, AudioBufferList* outputData, const AudioTimeStamp* /*inOutputTime*/, void* inClientData) { Impl* impl = reinterpret_cast<Impl*>(inClientData); switch (impl->m_outputProcState) { case kStarting: impl->m_outputProcState = kRunning; break; case kStopRequested: AudioDeviceStop(inDevice, OutputIOProc); impl->m_outputProcState = kOff; return noErr; default: break; } /* char buf[512] = {0}; sprintf(buf, "Received %i bytes of audio data\n", inputData->mBuffers[0].mDataByteSize); impl->m_logger(2, buf);*/ impl->read(reinterpret_cast<unsigned char*>(outputData->mBuffers[0].mData), outputData->mBuffers[0].mDataByteSize / impl->m_format.mBytesPerFrame); return noErr; }
la_int64_t OdinPatcher::Impl::laSkipCb(archive *a, void *userdata, la_int64_t request) { (void) a; Impl *impl = static_cast<Impl *>(userdata); bool ret = true; #ifdef __ANDROID__ if (impl->fd >= 0) { if (lseek64(impl->fd, request, SEEK_CUR) < 0) { LOGE("%s: Failed to seek: %s", impl->info->inputPath().c_str(), strerror(errno)); ret = false; } } else { #endif if (!impl->laFile.seek(request, io::File::SeekCurrent)) { LOGE("%s: Failed to seek: %s", impl->info->inputPath().c_str(), impl->laFile.errorString().c_str()); ret = false; } #ifdef __ANDROID__ } #endif if (ret) { impl->bytes += request; impl->updateProgress(impl->bytes, impl->maxBytes); } else { impl->error = ErrorCode::FileSeekError; } return ret ? request : -1; }
void put(const K& k, V v) { if (v == V()) impl.erase(k); else impl.insert(k, std::move(v)); }
const V *search(const K& k) const { const_iterator it = impl.find(k); if (it == impl.end()) return nullptr; return &it->second; }
static void* StartRoutineWrapper(void* data) { Impl* impl = (Impl*) data; impl->StartRoutine(impl->Data); return NULL; }
int main() { Impl impl; impl.run(); Interface& intf = impl; intf.run(); return 0; }
VampFeatureList * PluginAdapterBase::Impl::vampGetRemainingFeatures(VampPluginHandle handle) { #ifdef DEBUG_PLUGIN_ADAPTER std::cerr << "PluginAdapterBase::Impl::vampGetRemainingFeatures(" << handle << ")" << std::endl; #endif Impl *adapter = lookupAdapter(handle); if (!adapter) return 0; return adapter->getRemainingFeatures((Plugin *)handle); }
void insert(const K& k, V v) { // As far as I can tell, this is the simplest way to // implement move-only insert-with-replacement. iterator it = impl.lower_bound(k); // invariant: if it is valid, it->first >= k if (it != impl.end() && it->first == k) it->second = std::move(v); else it = impl.insert(std::pair<K, V>(std::move(k), std::move(v))).first; return (void)&it->second; }
VampFeatureList * PluginAdapterBase::Impl::vampProcess(VampPluginHandle handle, const float *const *inputBuffers, int sec, int nsec) { #ifdef DEBUG_PLUGIN_ADAPTER std::cerr << "PluginAdapterBase::Impl::vampProcess(" << handle << ", " << sec << ", " << nsec << ")" << std::endl; #endif Impl *adapter = lookupAdapter(handle); if (!adapter) return 0; return adapter->process((Plugin *)handle, inputBuffers, sec, nsec); }
void PluginAdapterBase::Impl::vampSetParameter(VampPluginHandle handle, int param, float value) { #ifdef DEBUG_PLUGIN_ADAPTER std::cerr << "PluginAdapterBase::Impl::vampSetParameter(" << handle << ", " << param << ", " << value << ")" << std::endl; #endif Impl *adapter = lookupAdapter(handle); if (!adapter) return; Plugin::ParameterList &list = adapter->m_parameters; ((Plugin *)handle)->setParameter(list[param].identifier, value); adapter->markOutputsChanged((Plugin *)handle); }
unsigned int PluginAdapterBase::Impl::vampGetOutputCount(VampPluginHandle handle) { #ifdef DEBUG_PLUGIN_ADAPTER std::cerr << "PluginAdapterBase::Impl::vampGetOutputCount(" << handle << ")" << std::endl; #endif Impl *adapter = lookupAdapter(handle); // std::cerr << "vampGetOutputCount: handle " << handle << " -> adapter "<< adapter << std::endl; if (!adapter) return 0; return adapter->getOutputCount((Plugin *)handle); }
void PluginAdapterBase::Impl::vampCleanup(VampPluginHandle handle) { #ifdef DEBUG_PLUGIN_ADAPTER std::cerr << "PluginAdapterBase::Impl::vampCleanup(" << handle << ")" << std::endl; #endif Impl *adapter = lookupAdapter(handle); if (!adapter) { delete ((Plugin *)handle); return; } adapter->cleanup(((Plugin *)handle)); }
VampOutputDescriptor * PluginAdapterBase::Impl::vampGetOutputDescriptor(VampPluginHandle handle, unsigned int i) { #ifdef DEBUG_PLUGIN_ADAPTER std::cerr << "PluginAdapterBase::Impl::vampGetOutputDescriptor(" << handle << ", " << i << ")" << std::endl; #endif Impl *adapter = lookupAdapter(handle); // std::cerr << "vampGetOutputDescriptor: handle " << handle << " -> adapter "<< adapter << std::endl; if (!adapter) return 0; return adapter->getOutputDescriptor((Plugin *)handle, i); }
static LRESULT WINAPI MessageRouter(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { if (message == WM_CREATE) { SetWindowLong(hWnd, 0, (LONG)lParam); } else { Impl* pThis = (Impl*)GetWindowLong(hWnd, 0); if (pThis != nullptr) { return pThis->WndProc(hWnd,message,wParam,lParam); } } return DefWindowProc(hWnd, message, wParam, lParam); }
void PluginAdapterBase::Impl::vampSelectProgram(VampPluginHandle handle, unsigned int program) { #ifdef DEBUG_PLUGIN_ADAPTER std::cerr << "PluginAdapterBase::Impl::vampSelectProgram(" << handle << ", " << program << ")" << std::endl; #endif Impl *adapter = lookupAdapter(handle); if (!adapter) return; Plugin::ProgramList &list = adapter->m_programs; ((Plugin *)handle)->selectProgram(list[program]); adapter->markOutputsChanged((Plugin *)handle); }
int PluginAdapterBase::Impl::vampInitialise(VampPluginHandle handle, unsigned int channels, unsigned int stepSize, unsigned int blockSize) { #ifdef DEBUG_PLUGIN_ADAPTER std::cerr << "PluginAdapterBase::Impl::vampInitialise(" << handle << ", " << channels << ", " << stepSize << ", " << blockSize << ")" << std::endl; #endif Impl *adapter = lookupAdapter(handle); if (!adapter) return 0; bool result = ((Plugin *)handle)->initialise(channels, stepSize, blockSize); adapter->markOutputsChanged((Plugin *)handle); return result ? 1 : 0; }
la_ssize_t OdinPatcher::Impl::laReadCb(archive *a, void *userdata, const void **buffer) { (void) a; Impl *impl = static_cast<Impl *>(userdata); *buffer = impl->laBuf; uint64_t bytesRead; bool ret = true; #ifdef __ANDROID__ if (impl->fd >= 0) { ssize_t n = read(impl->fd, impl->laBuf, sizeof(impl->laBuf)); if (n < 0) { LOGE("%s: Failed to read: %s", impl->info->inputPath().c_str(), strerror(errno)); ret = false; } else { bytesRead = n; } } else { #endif ret = impl->laFile.read(impl->laBuf, sizeof(impl->laBuf), &bytesRead); if (!ret && impl->laFile.error() == io::File::ErrorEndOfFile) { ret = true; } if (!ret) { LOGE("%s: Failed to read: %s", impl->info->inputPath().c_str(), impl->laFile.errorString().c_str()); } #ifdef __ANDROID__ } #endif if (ret) { impl->bytes += bytesRead; impl->updateProgress(impl->bytes, impl->maxBytes); } else { impl->error = ErrorCode::FileReadError; } return ret ? (la_ssize_t) bytesRead : -1; }
static DWORD WINAPI MyThread( LPVOID lpThreadParameter ){ Impl *This = (Impl*)lpThreadParameter; DWORD threadidx = GetCurrentThreadId(); while (!This->m_exit){ if (WAIT_OBJECT_0 == This->m_queueSemaphore.WaitAndDec(1000)) { std::shared_ptr<MyTaskData> task; task = This->getTaskAndPop(threadidx); assert(task); // run task->Run(); } } return 0; }
void connect(const std::string& srcPortName, Impl& dstImpl, const std::string& dstPortName) { if (!hasOutputPort(srcPortName)) throwPortError(srcPortName); if (!dstImpl.hasInputPort(dstPortName)) throwPortError(dstPortName); // The value on the output port may already be set if (!dstImpl._manuallySetPortsMap.count(dstPortName)) std::runtime_error(std::string("The value on port: ") + dstPortName + "is already set"); _outputMap.find(srcPortName) ->second.connect(dstImpl._inputMap.find(dstPortName)->second); }
int main (int argc, char* argv[]) { Impl impl; Global& global = impl; A& a = impl; B& b = impl; impl.A1(); impl.B1(); impl.AB1(); impl.AB2(); impl.AB3(); std::cout << std::endl; a.A1(); b.B1(); std::cout << std::endl; a.AB1(); a.AB2(); a.AB3(); std::cout << std::endl; b.AB1(); b.AB2(); b.AB3(); std::cout << std::endl; global.A1(); global.B1(); global.AB1(); global.AB2(); // global.AB3(); // Does not compile return 0; }
Edges edges() const noexcept { return shape_.edges(); }
Vertices vertices() const noexcept { return transformMesh_.vertices(); }
size_t size() const { return impl.size(); }
void clear() { impl.clear(); }
void erase(const K& k) { impl.erase(k); }
const_iterator end() const { return impl.end(); }
bool empty() const { return impl.empty(); }
Triangles triangles() const noexcept { return transformMesh_.triangles(); }