Example #1
0
	void open() {
		leftInput->open();
		rightInput->open();

		auto leftInputRegister = leftInput->getOutput();
		auto rightRegister = rightInput->getOutput();
		rightRegisterPtr = rightRegister[rightRegisterId];
		leftRegister.resize(leftInputRegister.size());
		for(auto& r: leftRegister) {
			outputRegister.push_back(&r);
		}
		for(auto& r_p: rightRegister) {
			outputRegister.push_back(r_p);
		}

		Register* leftRegisterPtr = leftInputRegister[leftRegisterId];
		while (leftInput->next()) {
			std::vector<Register> temp;
			for(auto& r : leftInputRegister) {
				temp.push_back(*r);
			}
			hashTable.insert(std::make_pair(*leftRegisterPtr, temp));
		}
		leftInput->close();

		getNewTupleFromRight = true;

	};
Example #2
0
File: main.cpp Project: 1KoT1/qTox
int main(int argc, char *argv[])
{
    qInstallMessageHandler(logMessageHandler);
    QApplication a(argc, argv);

    logFileStream.reset(new QTextStream);
    logFileFile.reset(new QFile(QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator()
                                                + "AppData" + QDir::separator() + "Roaming" + QDir::separator() + "tox")+QDir::separator()+"qtox.log"));
    if (logFileFile->open(QIODevice::Append))
    {
        logFileStream->setDevice(logFileFile.get());
        *logFileStream << QDateTime::currentDateTime().toString("\nyyyy-MM-dd HH:mm:ss' Updater file logger starting\n'");
    }
    else
    {
        qWarning() << "Couldn't open log file!\n";
        logFileStream.release();
    }

    long unsigned int bufsize=100;
    char buf[100];
    GetUserNameA(buf, &bufsize);
    qDebug() << "Updater running as user" << buf;

    Widget w;
    w.show();

    return a.exec();
}
Example #3
0
int main(int argc, char *argv[])
{
    qInstallMessageHandler(logMessageHandler);
    QApplication a(argc, argv);
    Settings s;

    logFileStream.reset(new QTextStream);
    logFileFile.reset(new QFile(s.getSettingsDirPath()+"qtox.log"));
    if (logFileFile->open(QIODevice::Append))
    {
        logFileStream->setDevice(logFileFile.get());
        *logFileStream << QDateTime::currentDateTime().toString("\nyyyy-MM-dd HH:mm:ss' Updater file logger starting\n'");
    }
    else
    {
        qWarning() << "Couldn't open log file!\n";
        logFileStream.release();
    }

    long unsigned int bufsize=100;
    char buf[100];
    GetUserNameA(buf, &bufsize);
    qDebug() << "Updater running as user" << buf;

    Widget w(s);
    w.show();

    return a.exec();
}
Example #4
0
void runTest(std::unique_ptr<VideoFrameWriter> writer)
{
    writer->open();
    ptime timestamp = microsec_clock::universal_time();
    vector<unsigned char> buffer(width * width * 3);
    for (int i = 0; i < frames; i++){
        for (int r = 0, p = 0; r < width; r++){
            for (int c = 0; c < width; c++, p += 3){
                buffer[p] = width - c;
                buffer[p + 2] = r;
            }
        }

        int boxPos = (i * (width - box_size)) / frames;
        for (int r = 0; r < box_size; r++){
            for (int c = 0; c < box_size; c++){
                int p = (boxPos + r) * width * 3 + (boxPos + c) * 3;
                buffer[p] = 255;
                buffer[p + 1] = i < 5 ? 0 : 255;
                buffer[p + 2] = i < 5 ? 0 : 255;
            }
        }

        TimestampedUnsignedCharVector message(timestamp, buffer);
        writer->write(TimestampedVideoFrame(width, width, 3, message));
        timestamp += milliseconds(frame_length);
    }

    writer->close();
}
Example #5
0
int Plugin_Open(int samplerate, int numchannels, int bitspersamp, int bufferlenms, int prebufferms)
{
	conversion_factor = (samplerate * bitspersamp * numchannels) / 8;
	num_channels = numchannels;
	bits_per_sample = bitspersamp;

	int output_delay_time = Global::Settings.output_buffer_lenght; 
	PrebufferBytesCount = ConvertMilisecondsToBytesCount(output_delay_time);
	
	forwarder->Open(samplerate, numchannels, bitspersamp, bufferlenms, prebufferms);
	return streamManager->open(samplerate, numchannels, bitspersamp);
}
    CommunicationManagerFixture() {
        vdstestlib::DirConfig stor_config(getStandardConfig(true));
        stor_config.getConfig("stor-server").set("node_index", "1");
        addSlobrokConfig(stor_config, slobrok);

        node = std::make_unique<TestServiceLayerApp>(stor_config.getConfigId());
        comm_mgr = std::make_unique<CommunicationManager>(node->getComponentRegister(),
                                                          stor_config.getConfigId());
        bottom_link = new DummyStorageLink();
        comm_mgr->push_back(std::unique_ptr<StorageLink>(bottom_link));
        comm_mgr->open();
    }
Example #7
0
 void SetUp()
 {
   QJsonValue setup_params, test_params;
   Config().GetParams("BinReaderTest", &setup_params, &test_params);
   tmpdir = setup_params.toObject().value("tmpdir").toString();
   AssertBug(QDir(tmpdir).mkpath(tmpdir), _THIS_LINE_);
   filename = tmpdir + "/test.bin";
   file = std::make_unique<QFile>(filename);
   AssertBug(file->open(QIODevice::WriteOnly | QIODevice::Truncate),
             _THIS_LINE_);
   stream = std::make_unique<QDataStream>(file.get());    
 }
Example #8
0
File: main.cpp Project: CCJY/coliru
 void on_connect(std::string const& host, std::string const& port)
 {
     try {
         udp::resolver resolver(m_IOService);
         m_ReceiverEndpoint = *resolver.resolve(udp::resolver::query(udp::v4(), host, port));
         m_pSocket = std::unique_ptr<boost::asio::ip::udp::socket>(new boost::asio::ip::udp::socket(m_IOService));
         m_pSocket->open(udp::v4());
     }
     catch (std::exception& e)
     {
         std::cerr << e.what() << std::endl;
     }
 }
void on_initialize(const string_t& address)
{
    // Build our listener's URI from the configured address and the hard-coded path "blackjack/dealer"

    uri_builder uri(address);
    uri.append_path(U("blackjack/dealer"));

    auto addr = uri.to_uri().to_string();
    g_httpDealer = std::unique_ptr<BlackJackDealer>(new BlackJackDealer(addr));
    g_httpDealer->open().wait();

    ucout << utility::string_t(U("Listening for requests at: ")) << addr << std::endl;

    return;
}
Example #10
0
static bool create_sink(std::unique_ptr<AbstractSink> &sink, const std::wstring fileName, const uint64_t &timestamp, const bool &keep_failed)
{
	if(_wcsicmp(fileName.c_str(), L"-") == 0)
	{
		sink.reset(new StdOutSink());
	}
	else if(_wcsicmp(fileName.c_str(), L"NUL") == 0)
	{
		sink.reset(new NullSink());
	}
	else
	{
		sink.reset(new FileSink(fileName, timestamp, keep_failed));
	}

	return sink ? sink->open() : false;
}
Example #11
0
    backend_t(const std::string& filename, std::size_t interval) :
        counter(0),
        interval(interval),
        stream(new std::ofstream)
    {
        BOOST_ASSERT(interval > 0);

        stream->exceptions(std::ifstream::failbit | std::ifstream::badbit);

        try {
            stream->open(filename, std::ios::app);
        } catch (const std::system_error& err) {
            // Transform unspecified ios category into the system one to obtain readable message.
            throw std::system_error(err.code().value(), std::system_category());
        } catch (const std::exception&) {
            throw std::system_error(errno, std::system_category());
        }
    }
int Plugin_Open(int samplerate, int numchannels, int bitspersamp, int bufferlenms, int prebufferms)
{
	start_t = GetTickCount();
	w_offset = 0;
	writtenbytes = 0;
	numchan = numchannels;
	srate = samplerate;
	bps = bitspersamp;

	PrebufferBytesCount = ConvertMilisecondsToBytesCount(PrebufferTime);
	
	//forwarder->SetOutputDelay(BytesPerSecondCount);// 1 second
	forwarder->Open(samplerate, numchannels, bitspersamp, bufferlenms, prebufferms);
	outputStream->Initialize(samplerate, numchannels, bitspersamp);

	streamManager->open();	//mpdClient->play();

	return 0;
}
Example #13
0
void
BouncerTest::setUp() {
    try{
        vdstestlib::DirConfig config(getStandardConfig(true));
        _node.reset(new TestServiceLayerApp(
                DiskCount(1), NodeIndex(2), config.getConfigId()));
        _upper.reset(new DummyStorageLink());
        _manager = new Bouncer(_node->getComponentRegister(),
                               config.getConfigId());
        _lower = new DummyStorageLink();
        _upper->push_back(std::unique_ptr<StorageLink>(_manager));
        _upper->push_back(std::unique_ptr<StorageLink>(_lower));
        _upper->open();
    } catch (std::exception& e) {
        std::cerr << "Failed to static initialize objects: " << e.what()
                  << "\n";
    }
    _node->getClock().setAbsoluteTimeInSeconds(10);
}
Example #14
0
bool OptionHandler::generateWaveformData(
    const boost::filesystem::path& input_filename,
    const boost::filesystem::path& output_filename,
    const Options& options)
{
    const std::unique_ptr<ScaleFactor> scale_factor = createScaleFactor(options);

    const boost::filesystem::path output_file_ext = output_filename.extension();

    const std::unique_ptr<AudioFileReader> audio_file_reader =
        createAudioFileReader(input_filename);

    if (audio_file_reader == nullptr) {
        error_stream << "Unknown file type: " << input_filename << '\n';
        return false;
    }

    if (!audio_file_reader->open(input_filename.c_str())) {
        return false;
    }

    WaveformBuffer buffer;
    WaveformGenerator processor(buffer, *scale_factor);

    if (!audio_file_reader->run(processor)) {
        return false;
    }

    assert(output_file_ext == ".dat" || output_file_ext == ".json");

    const int bits = options.getBits();

    if (output_file_ext == ".dat") {
        return buffer.save(output_filename.c_str(), bits);
    }
    else {
        return buffer.saveAsJson(output_filename.c_str(), bits);
    }
}
ModulePackage::ModulePackage(std::unique_ptr<QFile> file)
{
    enum {
        HEAD,
        BRACE,
        BODY
    } state = HEAD;

    enum {
        OPERATOR,
        FUNCTION,
        TERMINAL
    } type;
    OperatorModule::StaticInfo opStatics;
    FunctionModule::StaticInfo funcStatics;
    OperatorInterface opInter;
    FunctionInterface funcInter;
    QList<QByteArray> head;
    QString description;
    QLibrary lib;
    name_ = QFileInfo(*file).baseName();
    if (file->open(QFile::ReadOnly)) {
        while (!file->atEnd()) {
            QByteArray line = file->readLine().trimmed();
            if (! line.isEmpty()) {
                switch (state) {
                case HEAD:
                    head = line.split(':');
                    head[0] = head.at(0).trimmed();
                    head[1] = head.at(1).trimmed().toUpper();
                    if (head.at(1) == "OPERATOR") {
                        type = OPERATOR;
                        //opInter = new OperatorInterface;
                    } else if (head.at(1) == "FUNCTION") {
                        type = FUNCTION;
                        //funcInter = new FunctionInterface;
                    } else if (head.at(1) == "TERMINAL") {
                        type = TERMINAL;
                    }
                    state = BRACE;
                    break;
                case BRACE:
                    if (line == "{") state = BODY;
                    break;
                case BODY:
                    if (line == "}") {
                        switch (type) {
                        case OPERATOR:
                            modules.operators.append(OperatorModule(head.at(0), description, this, opInter, opStatics));
                            break;
                        case FUNCTION:
                            modules.functions.append(FunctionModule(head.at(0), description, this, funcInter, funcStatics));
                            break;
                        case TERMINAL:
                            modules.terminals.append(TerminalModule(head.at(0), description, this, (std::unique_ptr<CAS::AbstractArithmetic>(*)(const std::string &))lib.resolve(head[0] + "_jmodule")));
                            break;
                        }
                        state = HEAD;
                    } else {
                        auto colonPos = line.indexOf(':');
                        auto key = line.left(colonPos).trimmed();
                        auto value = line.right(line.length() - colonPos - 2).trimmed();
                        if (key == "description") {
                            description = value;
                        } else if (key == "matches") {
                            if (type == OPERATOR) {
                                opStatics.matches = std::make_shared<QString>(value);
                            } else if (type == FUNCTION) {
                                QList<QByteArray> matchParts = value.split(',');
                                funcStatics.matches = std::make_shared<QPair<QString, unsigned int>>(QString(matchParts.at(0)), matchParts.at(1).toUInt());
                            }
                        } else if (key == "priority") {
                            if (type == OPERATOR) opStatics.priority = value.toUInt();
                            else if (type == FUNCTION) funcStatics.priority = value.toUInt();
                        } else if (type == OPERATOR && key == "associativity") {
                            if (value == "left") opStatics.associativity = OperatorInterface::LEFT;
                            else if (value == "right") opStatics.associativity = OperatorInterface::RIGHT;
                        } else if (key == "lib") {
                            lib.setFileName(value);
                            std::string dbg = QString(head[0]).toStdString();
                            if (type == OPERATOR) opInter = ((OperatorInterface(*)())lib.resolve(head[0] + "_jmodule"))();
                            else if (type == FUNCTION) funcInter = ((FunctionInterface(*)())lib.resolve(head[0] + "_jmodule"))();
                        }
                    }
                }
            }
        }
    }
}
Example #16
0
int main(int argc, char *argv[])
{
    qInstallMessageHandler(logMessageHandler); // Enable log as early as possible
    QApplication a(argc, argv);
    a.setApplicationName("qTox");
    a.setOrganizationName("Tox");
    a.setApplicationVersion("\nGit commit: " + QString(GIT_VERSION));

#ifdef HIGH_DPI
    a.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
#endif

    qsrand(time(0));
    Settings::getInstance();
    Translator::translate();

    // Process arguments
    QCommandLineParser parser;
    parser.setApplicationDescription("qTox, version: " + QString(GIT_VERSION) + "\nBuilt: " + __TIME__ + " " + __DATE__);
    parser.addHelpOption();
    parser.addVersionOption();
    parser.addPositionalArgument("uri", QObject::tr("Tox URI to parse"));
    parser.addOption(QCommandLineOption("p", QObject::tr("Starts new instance and loads specified profile."), QObject::tr("profile")));
    parser.process(a);

#ifndef Q_OS_ANDROID
    IPC& ipc = IPC::getInstance();
#endif

    sodium_init(); // For the auto-updater

#ifdef LOG_TO_FILE
    logFileStream.reset(new QTextStream);
    logFileFile.reset(new QFile(Settings::getInstance().getSettingsDirPath()+"qtox.log"));
    if (logFileFile->open(QIODevice::Append))
    {
        logFileStream->setDevice(logFileFile.get());
        *logFileStream << QDateTime::currentDateTime().toString("\nyyyy-MM-dd HH:mm:ss' file logger starting\n'");
    }
    else
    {
        qWarning() << "Couldn't open log file!\n";
        logFileStream.release();
    }
#endif

    // Windows platform plugins DLL hell fix
    QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath());
    a.addLibraryPath("platforms");

    qDebug() << "built on: " << __TIME__ << __DATE__ << "(" << TIMESTAMP << ")";
    qDebug() << "commit: " << GIT_VERSION << "\n";

#if defined(Q_OS_MACX) && defined(QT_RELEASE)
    osx::moveToAppFolder();
#endif

    // Install Unicode 6.1 supporting font
    QFontDatabase::addApplicationFont("://DejaVuSans.ttf");

    // Check whether we have an update waiting to be installed
#if AUTOUPDATE_ENABLED
    if (AutoUpdater::isLocalUpdateReady())
        AutoUpdater::installLocalUpdate(); ///< NORETURN
#endif


#ifndef Q_OS_ANDROID
    // Inter-process communication
    ipc.registerEventHandler("uri", &toxURIEventHandler);
    ipc.registerEventHandler("save", &toxSaveEventHandler);
    ipc.registerEventHandler("activate", &toxActivateEventHandler);

    if (parser.isSet("p"))
    {
        QString profileName = parser.value("p");
        if (Profile::exists(profileName))
        {
            qDebug() << "Setting profile to" << profileName;
            if (Profile::isEncrypted(profileName))
            {
                Settings::getInstance().setCurrentProfile(profileName);
            }
            else
            {
                Profile* profile = Profile::loadProfile(profileName);
                if (!profile)
                {
                    qCritical() << "-p profile" << profileName + ".tox" << " couldn't be loaded";
                    return EXIT_FAILURE;
                }
                Nexus::getInstance().setProfile(profile);
            }
        }
        else
        {
            qCritical() << "-p profile" << profileName + ".tox" << "doesn't exist";
            return EXIT_FAILURE;
        }
    }

    if (parser.positionalArguments().size() > 0)
    {
        QString firstParam(parser.positionalArguments()[0]);
        // Tox URIs. If there's already another qTox instance running, we ask it to handle the URI and we exit
        // Otherwise we start a new qTox instance and process it ourselves
        if (firstParam.startsWith("tox:"))
        {
            if (ipc.isCurrentOwner()) // Don't bother sending an event if we're going to process it ourselves
            {
                handleToxURI(firstParam.toUtf8());
            }
            else
            {
                time_t event = ipc.postEvent("uri", firstParam.toUtf8());
                ipc.waitUntilAccepted(event);
                // If someone else processed it, we're done here, no need to actually start qTox
                if (!ipc.isCurrentOwner())
                    return EXIT_SUCCESS;
            }
        }
        else if (firstParam.endsWith(".tox"))
        {
            if (ipc.isCurrentOwner()) // Don't bother sending an event if we're going to process it ourselves
            {
                handleToxSave(firstParam.toUtf8());
            }
            else
            {
                time_t event = ipc.postEvent("save", firstParam.toUtf8());
                ipc.waitUntilAccepted(event);
                // If someone else processed it, we're done here, no need to actually start qTox
                if (!ipc.isCurrentOwner())
                    return EXIT_SUCCESS;
            }
        }
        else
        {
            fprintf(stderr, "Invalid argument\n");
            return EXIT_FAILURE;
        }
    }
    else if (!ipc.isCurrentOwner() && !parser.isSet("p"))
    {
        time_t event = ipc.postEvent("activate");
        if (!ipc.waitUntilAccepted(event, 2))
        {
            return EXIT_SUCCESS;
        }
    }
#endif

    // Autologin
    if (Settings::getInstance().getAutoLogin())
    {
        QString profileName = Settings::getInstance().getCurrentProfile();
        if (Profile::exists(profileName) && !Profile::isEncrypted(profileName))
        {
            Profile* profile = Profile::loadProfile(profileName);
            if (profile)
                Nexus::getInstance().setProfile(profile);
        }
    }

    Nexus::getInstance().start();

    // Run
    int errorcode = a.exec();

#ifdef LOG_TO_FILE
    logFileStream.release();
#endif

    Nexus::destroyInstance();
    CameraSource::destroyInstance();
    Settings::destroyInstance();
    qDebug() << "Clean exit with status"<<errorcode;
    return errorcode;
}
Example #17
0
 void open(const char* fname)
 {
     buf_->open(fname, std::ios::out | std::ios::trunc);
 }