unsigned qCreateSink(void) { Sink *sink = new Sink(); if (!sink) { qLog() << "qCreateSink(): failed to instantiate new sink" << flush; return 0; } g_Ticker.addTickee(sink->ptr()); return sink->key(); }
void Dict::write(Sink &sink) const { sink.beginDict(isSimple()); for (const_iterator it = begin(); it != end(); it++) { if (!it->second->canWrite(sink)) continue; sink.beginInsert(it->first); it->second->write(sink); } sink.endDict(); }
void _UnixDo(Source & so,Sink & si) { stringGB s; so >> s; so.shouldBeEnd(); si.noOutput(); system(s.value().chars()); };
void _SetWreathOrder(Source & so,Sink & si) { stringGB name; list<stringGB> L; so >> name; GBInputSpecial(L,so); T * p = Name2Instance<AdmissibleOrder>::s_find(name); if(!p) { vector<vector<Variable> > VARS; vector<AdmissibleOrder *> ORDS; typedef list<stringGB>::const_iterator LI; LI w = L.begin(), e = L.end(); AdmissibleOrder * q; while(w!=e) { q = Name2Instance<AdmissibleOrder>::s_find((*w).value()); ORDS.push_back(q); ++w; }; DBG(); p = new WreathOrder(VARS,ORDS); Name2Instance<AdmissibleOrder>::s_add(name,p); }; GBInput(*p,so); so.shouldBeEnd(); si.noOutput(); };
std::streamsize copy_impl( Source& src, Sink& snk, std::streamsize buffer_size, mpl::false_, mpl::true_ ) { typedef typename char_type_of<Source>::type char_type; typedef std::pair<char_type*, char_type*> pair_type; detail::basic_buffer<char_type> buf(buffer_size); pair_type p = snk.output_sequence(); std::streamsize total = 0; std::ptrdiff_t capacity = p.second - p.first; while (true) { std::streamsize amt = iostreams::read( src, buf.data(), buffer_size < capacity - total ? buffer_size : static_cast<std::streamsize>(capacity - total) ); if (amt == -1) break; std::copy(buf.data(), buf.data() + amt, p.first + total); total += amt; } return total; }
void _GroebnerCutOffSum(Source & so,Sink & si) { int n; so >> n; so.shouldBeEnd(); si.noOutput(); run->setSumNumberCutOff(n); };
void _GroebnerCutOffFlag(Source & so,Sink & si) { int n; so >> n; so.shouldBeEnd(); run->setCutOffFlag(n!=0); si.noOutput(); };
void CollectionLinkHeaderItem::Dump_(Sink& sink) const { Header hdr{}; hdr.offset = ToFilePos(data->ptr); hdr.count = data->ptr.As0<CollectionLinkItem>().entries.size(); sink.WriteGen(hdr); }
void add_slot(Sink& aSink, SinkFunction aSinkFunction) { typename LockingPolicy::scope_lock sl(*this); if (slots().find(&aSink) != slots().end()) throw slot_already_added(); detail::do_bind<ParameterCount>()(aSink, aSinkFunction, slots()[&aSink]); aSink.signal_created(*this); }
int main(void) { File *aviFile = new File(); Demux *aviDemux = new Demux(); Codec *h264 = new Codec(); Sink *imageSink = new Sink(); Component *com = new Component(); aviDemux->setProcessComponent(aviFile); h264->setProcessComponent(aviDemux); com->setProcessComponent(h264); imageSink->setProcessComponent(com); imageSink->dataProcess(NULL, NULL); return 0; }
void add_slot(const Key& aKey, Sink& aSink, SinkFunction aSinkFunction) { typename LockingPolicy::scope_lock sl(*this); if (slots().find(std::make_pair(aKey, &aSink)) != slots().end()) throw slot_already_added(); detail::do_bind<ParameterCount>()(aSink, aSinkFunction, slots()[std::make_pair(aKey, &aSink)]); aSink.signal_created(*this); }
void OutputVisitor::s_put(const tRational<LINTEGER> & x,Sink & si) { if(x.denominator().zero()) { si << x.numerator().internal(); } else { Sink sink(si.outputFunction("Divide",2L)); sink << x.numerator().internal() << x.denominator().internal(); }; };
void _RunGBAlg(Source & source,Sink & sink) { asStringGB name; source >> name; source.shouldBeEnd(); sink.noOutput(); GBALG_STORAGE::const_iterator w = gbalg_storage.find(name.value()); if(w==gbalg_storage.end()) DBG(); (*w).second->perform(); };
void Serialize(Sink & sink) { SortPostings(); BuildDictionary(); TextIndexHeader header; uint64_t const startPos = sink.Pos(); // Will be filled in later. header.Serialize(sink); SerializeDictionary(sink, header, startPos); SerializePostingsLists(sink, header, startPos); uint64_t const finishPos = sink.Pos(); sink.Seek(startPos); header.Serialize(sink); sink.Seek(finishPos); }
void CollectionLinkItem::Dump_(Sink& sink) const { Entry ee{}; for (const auto& e : entries) { ee.name_0 = ToFilePos(e.name_0->ptr); ee.name_1 = ToFilePos(e.name_1->ptr); sink.WriteGen(ee); } }
void _CppTeXTheFile(Source & so,Sink & si) { stringGB format; so >> format; StringAccumulator x; x.add(PlatformSpecific::s_latex_command()); x.add(format.value().chars()); so.shouldBeEnd(); si.noOutput(); system(x.chars()); };
void _ShowTeX(Source & so,Sink & si) { stringGB format; so >> format; StringAccumulator x; x.add(PlatformSpecific::s_dvi_viewer()); x.add(format.value().chars()); x.add(PlatformSpecific::s_background()); so.shouldBeEnd(); si.noOutput(); system(x.chars()); };
void DataItem::Dump_(Sink& sink) const { Header hdr; hdr.type = type; hdr.offset_unit = offset_unit; hdr.field_8 = field_8; hdr.length = GetSize() - sizeof(Header); sink.WriteGen(hdr); ItemWithChildren::Dump_(sink); }
ssize_t BufferRefSource::sendto(Sink& sink) { if (pos_ == buffer_.size()) return 0; ssize_t result = sink.write(buffer_.data() + pos_, buffer_.size() - pos_); if (result > 0) pos_ += result; return result; }
ERL_NIF_TERM compress(task_t *task) { ERL_NIF_TERM result; snappy::ByteArraySource source(reinterpret_cast<const char*>(task->data.data), task->data.size); Sink sink; try { snappy::Compress(&source, &sink); result = enif_make_tuple3(task->env, atom_ok, task->ref, enif_make_binary(task->env, &sink.GetBinary())); } catch (std::exception &e) { result = enif_make_tuple2(task->env, atom_error, enif_make_string(task->env, "Failed to compress", ERL_NIF_LATIN1)); } return result; }
void _GetAllCommands(Source & so,Sink & si) { so.shouldBeEnd(); list<simpleString> L; getAllCommands(L); long sz = L.size(); Sink sink(si.outputFunction("List",sz)); GBStream << "Begin loop\n"; list<simpleString>::const_iterator w = L.begin(); for(long i=1L;i<=sz;++i,++w) { sink.putString((*w).chars()); }; GBStream << "Done with " << sz << "elements!\n"; };
void Sink::sink_cb(pa_context *, const pa_sink_info *i, int eol, void *userdata) { cout << "Sink::sink_cb" << endl; Sink *p = reinterpret_cast<Sink *>(userdata); Device::Private *dd = p->Device::d; if (eol) return; if (!i) { cout << "Sink callback failure" << endl; return; } if ( dd->valid ) assert ( i->index == dd->index ); //p->mSinkInfo = *i; cout << i->name << " " << i->description << endl; dd->name = QString(i->name); dd->description = QString(i->description); dd->sampleSpec = i->sample_spec; dd->channelMap = i->channel_map; dd->owner = i->owner_module; dd->volume = i->volume; dd->muted = i->mute; dd->monitor= i->monitor_source; dd->monitorName = QString(i->monitor_source_name); dd->latency = i->latency; dd->driver = QString(i->driver); dd->baseVolume = i->base_volume; dd->card = i->card; dd->configuredLatency = i->configured_latency; dd->valid = true; if(dd->proplist != 0) pa_proplist_free(dd->proplist); dd->proplist = pa_proplist_copy(i->proplist); emit p->updated(); }
bool tryOpen(const string plugin) { if (plugin_handler.load(plugin)) { sink = plugin_handler.openSink(); if (sink) { if (sink->open()) return true; delete sink; sink = 0; } plugin_handler.unload(); } else std::cout << "auto_sink: Could not load " << plugin << std::endl; return false; }
void _registerStartingRelations(Source & so,Sink & si) { int m; so >> m; so.shouldBeEnd(); int id = BaRoutineFactory::s_getCurrent().ID(); if(false) { } #ifdef WANT_MNGRSUPER else if(id==PDRoutineFactory::s_ID) { ((MngrSuper *)run)->RegisterStartingRelations(m); } #endif si.noOutput(); } /* _registerStartingRelations */
void _namedRegisterStartingRelations(Source & so,Sink & si) { stringGB item_name; so >> item_name; so.shouldBeEnd(); si.noOutput(); GBList<Polynomial>* p = Pools<GBList<Polynomial> >::s_lookup_error(GBStream,item_name.value()); if(p) { registerStartingRelationsHelper(*p); } else { GBStream << "There is no GBList of polynomials called \"" << item_name << "\"\n"; }; };
void _DeclareProgrammableVariableNotDefault(Source & so,Sink & sink) { asStringGB type, name; so >> type >> name; TYPEINFO::const_iterator w = d_type_info.find(type.value()); if(w==d_type_info.end()) { GBStream << "Cannot find the type " << type.value() << "\n"; DBG(); }; d_name_to_type[name.value()] = type.value(); void (*func)(const simpleString &,Source & so) = (*w).second.d_construct_not_default; if(!func) DBG(); func(name.value(),so); so.shouldBeEnd(); sink.noOutput(); };
void DumpableSource::Dump_(Sink& sink) const { auto offset = GetOffset(); auto rem_size = GetSize(); while (rem_size) { auto x = GetTemporaryEntry(offset); NEPTOOLS_ASSERT(x.offset <= offset); auto ptroff = offset - x.offset; auto size = std::min(rem_size, x.size - ptroff); sink.Write({x.ptr + ptroff, size}); offset += size; rem_size -= size; } }
void _PrintProgrammableVariable(Source & so,Sink & si) { asStringGB name; so >> name; NAME2TYPE::const_iterator w = d_name_to_type.find(name.value()); if(w==d_name_to_type.end()) { GBStream << name.value() << " is not a programmable variable" << " and, therefore, cannot be printed.\n"; } else { TYPEINFO::const_iterator ww = d_type_info.find((*w).second); void (*func)(const simpleString &,MyOstream &) = (*ww).second.d_print; if(!func) DBG(); func(name.value(),GBStream); }; so.shouldBeEnd(); si.noOutput(); };
/*------------------------------------------------------------------------------ * The function for each thread. * Read the presented data *----------------------------------------------------------------------------*/ void MultiThreadedConnector :: sinkThread( int ixSink ) { ThreadData * threadData = &threads[ixSink]; Sink * sink = sinks[ixSink].get(); while ( running ) { // wait for some data to become available pthread_mutex_lock( &mutexProduce); while ( running && threadData->isDone ) { pthread_cond_wait( &condProduce, &mutexProduce); } if ( !running ) { pthread_mutex_unlock( &mutexProduce); break; } if ( threadData->accepting ) { if ( sink->canWrite( 0, 0) ) { try { sink->write( dataBuffer, dataSize); } catch ( Exception & e ) { // something wrong. don't accept more data, try to // reopen the sink next time around threadData->accepting = false; } } else { reportEvent( 4, "MultiThreadedConnector :: sinkThread can't write ", ixSink); // don't care if we can't write } } threadData->isDone = true; pthread_cond_broadcast( &condProduce); pthread_mutex_unlock( &mutexProduce); if ( !threadData->accepting ) { if ( reconnect ) { // if we're not accepting, try to reopen the sink try { sink->close(); sink->open(); threadData->accepting = sink->isOpen(); } catch ( Exception & e ) { // don't care, just try and try again } } else { // if !reconnect, just stop the connector running = false; } } } }
void _ConstructSheets(Source & so,Sink & si) { simpleString filename("build_output.tex"); ofstream output(filename.chars()); MyOstream output2(output); #ifdef WANT_MNGRADAPTER PartialGB & pgb = (PartialGB &) ((ManagerAdapter *)run)->PARTIALGB(); Spreadsheet x(pgb,AdmissibleOrder::s_getCurrent()); #endif #ifdef WANT_MNGRSUPER FactControl & fc = (FactControl &) ((MngrSuper *)run)->GetFactBase(); // GBStream << fc; #if 1 const GBList<int> VEC(fc.indicesOfPermanentFacts()); GBList<int>::const_iterator VECB = VEC.begin(); vector<GroebnerRule> vec; const int VECSZ = VEC.size(); vec.reserve(VECSZ); for(int iii=1;iii<=VECSZ;++iii,++VECB) { vec.push_back(fc.fact(*VECB)); }; Sheet1 x(vec,AdmissibleOrder::s_getCurrent()); #else Spreadsheet x(fc,AdmissibleOrder::s_getCurrent()); x.uglyprint(GBStream); #endif TeXSink tex_sink(output2); #if 0 TeX1Display tester(tex_sink,x,AdmissibleOrder::s_getCurrent()); #endif #if 0 list<GroebnerRule> L; copy(x.d_rules.begin(),x.d_rules.end(),back_inserter(L)); TeX2Display tester(tex_sink,L,AdmissibleOrder::s_getCurrent()); #endif #if 1 TeX3Display tester(tex_sink,x,AdmissibleOrder::s_getCurrent()); #endif tester.perform(); #endif GBStream << '\n'; so.shouldBeEnd(); si.noOutput(); os.flush(); output.close(); };