本文整理汇总了C++中DataProvider类的典型用法代码示例。如果您正苦于以下问题:C++ DataProvider类的具体用法?C++ DataProvider怎么用?C++ DataProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DataProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: s_OnNewFolder
HRESULT CFolderViewCommandProvider::s_OnNewFolder(IShellItemArray * /* psiItemArray */, IUnknown * /* pv */)
{
DataProvider dataProvider;
dataProvider.logInfo("Create new folder");
//SendMessage(pici->hwnd, 0x111, 0x7103, 0);
return S_OK;
}
示例2: execute
void CameraBuffer::execute(DataProvider& provider)
{
// get the input data
Id2DataPair inputMapper(INPUT);
provider.receiveInputData(inputMapper);
// try to get a free buffer
Data* buffer = 0;
try
{
buffer = m_buffers(0);
}
catch(Timeout&)
{
}
if(buffer)
{
// there was a free buffer
DataContainer bufferContainer(buffer);
// remember it in the recycling access
m_buffers.add(bufferContainer);
Id2DataPair outputMapper(OUTPUT, inputMapper.data());
Id2DataPair bufferMapper(BUFFER, bufferContainer);
Id2DataPair idMapper(INDEX, DataContainer(new UInt32(m_id)));
// send it to the output (together with the input image and the current index)
provider.sendOutputData(outputMapper && bufferMapper && idMapper);
}
// increase the index
++m_id;
}
示例3: main
int main()
{
GenericObjectFactory<int, BaseFigure> figureFactory;
figureFactory.add<Square>((int)FigureTypes::square);
figureFactory.add<Circle>((int)FigureTypes::circle);
figureFactory.add<Arc>((int)FigureTypes::anc);
figureFactory.add<Polygon_Line>((int)FigureTypes::polygon_line);
figureFactory.add<Polygon>((int)FigureTypes::polygon);
DataProvider provider;
WDraw drawer;
try {
int objects_num = provider.rdInt();
for (int i = 0; i < objects_num; ++i) {
int id = provider.rdInt();
BaseFigure *figure = figureFactory.get(id)();
std::cout << int(figure->type()) << std::endl;
figure->read(provider);
figure->draw(drawer);
}
provider.rdDouble();
}
catch (ReadError) {
std::cerr << "Reading error." << std::endl;
}
catch (EndOfFile) {
std::cerr << "End of file reached." << std::endl;
}
system("pause");
}
示例4: generate
void Rnn::generate(DataProvider& dp) {
int wordId = 0;
std::string word;
dp.randomWord(wordId, word);
std::cout << word << " ";
Vector Htm1(firstWordHidden_);
Vector htm1P(firstCharHidden_);
for (int i=0; i<20; i++) {
word = generator_.generate(wordId, Htm1, htm1P);
word.pop_back(); // removing the underscore
Htm1.copy(generator_.Ht_);
htm1P.copy(generator_.hp_[generator_.lastChar - 1]);
wordId = dp.getWordId(word);
if (wordId != 0) {
std::cout << "#" << word << " ";
} else {
std::cout << word << " ";
}
}
std::cout << std::endl;
}
示例5: read
void Polygon::read(DataProvider &provider) {
points.clear();
int params_num = provider.rdInt();
for (int i = 0; i < params_num / 2; ++i) {
double x = provider.rdDouble(),
y = provider.rdDouble();
points.push_back(Point2d(x, y));
}
}
示例6: execute
void ExceptionOperator::execute(DataProvider& provider)
{
Id2DataPair input(INPUT);
provider.receiveInputData(input);
provider.sleep(100);
if(m_throwExecute)
throw OperatorError(*this, "Failed to execute operator.");
}
示例7: data_read_callback
static ssize_t
data_read_callback(void *opaque, void *buf, size_t buflen)
{
DataProvider *provider = static_cast<DataProvider *>(opaque);
if(!provider)
{
errno = EINVAL;
return -1;
}
return provider->read(buf, buflen);
}
示例8: fetch
void StationScheduleModel::fetch(const QString &name, const QString &code)
{
DataProvider *provider = DataProvider::instance();
if (!error().isEmpty())
setError(QString());
m_departureSchedules.clear();
m_arrivalSchedules.clear();
provider->fetchStationSchedule(name, code);
setName(name);
setCode(code);
}
示例9: execute
void ParameterOperator::execute(DataProvider& provider)
{
Id2DataPair input1(INPUT_1);
Id2DataPair input2(INPUT_2);
provider.receiveInputData(input1 && input2);
// execute...
Id2DataPair output1(OUTPUT_1, input1.data());
Id2DataPair output2(OUTPUT_2, input2.data());
provider.sendOutputData(output1 && output2);
}
示例10: execute
void ReadDirectory::execute(DataProvider& provider)
{
if (m_files.size() == 0)
throw OperatorError(*this, "Directory is empty.");
Data* data = 0;
std::size_t index = m_currentIndex;
do
{
boost::filesystem::path file(m_files[index]);
index = (index + 1) % m_files.size();
std::string ext = file.extension().string();
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
if (ext == ".png" || ext == ".jpg" || ext == ".jpeg")
{
data = new cvsupport::Image(file.string());
}
}
while (data == 0 && index != m_currentIndex);
m_currentIndex = index;
if (data == 0)
throw OperatorError(*this, "Found no usable file in selected directory.");
DataContainer container(data);
Id2DataPair outputDataMapper(OUTPUT, container);
provider.sendOutputData(outputDataMapper);
}
示例11: execute
void Send::execute(DataProvider& provider)
{
Id2DataPair inputMapper(INPUT);
provider.receiveInputData(inputMapper);
m_server->send(inputMapper.data());
}
示例12: data_seek_callback
static off_t
data_seek_callback(void *opaque, off_t offset, int whence)
{
DataProvider *provider = static_cast<DataProvider *>(opaque);
if(!provider)
{
errno = EINVAL;
return -1;
}
if(whence != SEEK_SET && whence != SEEK_CUR && whence != SEEK_END)
{
errno = EINVAL;
return -1;
}
return provider->seek(offset, whence);
}
示例13: train
void Rnn::train(DataProvider& dp,
bool doTrain,
double& seconds,
double& wordEntropy,
double& charEntropy,
int& nChars) {
dp.initIterator();
int nWords = dp.getNumTokens();
wordEntropy = 0.0;
charEntropy = 0.0;
double loss = 0.0;
nChars = 0;
int now = 0;
int next = 0;
std::string nextWord;
auto tic = std::chrono::steady_clock::now();
auto toc = std::chrono::steady_clock::now();
seconds = 0.0;
for (int i=0; i<nWords; i++) {
if ( i%10000 == 0 && i>0 ) {
toc = std::chrono::steady_clock::now();
seconds = std::chrono::duration_cast<std::chrono::milliseconds>
(toc - tic).count() / 1000.0;
if (VERBOSE) {
printf("train=%d token %8d/%8d ", doTrain, i, nWords);
printf("char-entropy=%12.6e ", charEntropy / nChars);
printf("word-entropy=%12.6e ", charEntropy / i);
printf("word-model-entropy=%12.6e ", wordEntropy / i);
printf("loss=%12.6e ", loss);
printf("time=%-8.0f ", seconds);
printf("sec/epoch=%-8.0f ", seconds / i * nWords);
printf("words/sec=%-8.0f ", i / seconds);
printf("chars/sec=%-8.0f ", nChars / seconds);
std::cout << std::endl;
if (doTrain) {
// generate(dp);
}
}
}
dp.getToken(now, next, nextWord);
forward(now, next, nextWord, doTrain, wordEntropy, charEntropy, nChars);
loss = model_.alpha_ * wordEntropy + (1.0 - model_.alpha_) * charEntropy;
}
}
示例14: execute
void Merge::execute(DataProvider& provider)
{
if (m_list == 0)
{
Id2DataPair dataMapper(INPUT_NUM_ITEMS);
provider.receiveInputData(dataMapper);
ReadAccess access(dataMapper.data());
try
{
m_numItems = toInt(access.get());
}
catch (BadCast&)
{
throw InputError(INPUT_NUM_ITEMS, *this, "Number of items must be an integer.");
}
m_list = new List();
}
if (m_list->content().size() < m_numItems)
{
RecycleAccess recycler;
{
Id2DataPair dataMapper(INPUT_DATA);
provider.receiveInputData(dataMapper);
recycler.add(dataMapper.data());
}
Data* data = recycler.get();
m_list->content().push_back(data);
}
if (m_list->content().size() == m_numItems)
{
DataContainer out(m_list);
m_list = 0;
m_numItems = 0;
Id2DataPair dataMapper(OUTPUT, out);
provider.sendOutputData(dataMapper);
}
}
示例15: execute
void TestOperator::execute(DataProvider& provider)
{
if(m_throwException)
{
throw InternalError("Funny exception.");
}
Id2DataPair input1(INPUT_1);
Id2DataPair input2(INPUT_2);
provider.receiveInputData(input1 && input2);
// execute...
m_numExecutes++;
boost::this_thread::sleep_for(boost::chrono::milliseconds(m_sleepTime));
Id2DataPair output1(OUTPUT_1, input1.data());
Id2DataPair output2(OUTPUT_2, input2.data());
provider.sendOutputData(output1 && output2);
}