当前位置: 首页>>代码示例>>C++>>正文


C++ ConfigManager::intAt方法代码示例

本文整理汇总了C++中ConfigManager::intAt方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigManager::intAt方法的具体用法?C++ ConfigManager::intAt怎么用?C++ ConfigManager::intAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConfigManager的用法示例。


在下文中一共展示了ConfigManager::intAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DatabaseError

Market::Market(const ConfigManager<>& config, QObject* parent)
    : QObject(parent)
{
    qDebug() << "[Market] Ładowanie danych konfiguracyjnych...";

    qint32 sessionOnInterval = config.intAt("SESSION ON DURATION");
    qint32 sessionOffInterval = config.intAt("SESSION OFF DURATION");

    int serverPort = config.intAt("SERVER PORT");

    QString dbUserName = config["DATABASE USERNAME"];
    QString dbPassword = config["DATABASE PASSWORD"];
    QString dbName = config["DATABASE NAME"];
    QString dbHost = config["DATABASE HOST"];
    int dbPort = config.intAt("DATABASE PORT");

    _database = QSqlDatabase::addDatabase("QPSQL",
                                          QLatin1String("Rynki finansowe 1"));

    _database.setHostName(dbHost);
    _database.setDatabaseName(dbName);
    _database.setUserName(dbUserName);
    _database.setPassword(dbPassword);
    _database.setPort(dbPort);

    qDebug() << "[Market] Otwieranie nowego połączenia z bazą danych...";
    if(!_database.open())
    {
        qDebug() << "[Market] Wykryto błąd" << _database.lastError().text()
                 << "podczas otwierania nowego połączenia z bazą daynch.";
        throw DatabaseError();
    }

    _database.driver()->subscribeToNotification(BUY_TRANSACTIONS_CHANNEL);
    _database.driver()->subscribeToNotification(SELL_TRANSACTIONS_CHANNEL);
    _database.driver()->subscribeToNotification(TRANSACTION_CHANNEL);

    qDebug() << "[Market] Ustanowiono połączenie z bazą danych.";

    //qDebug() << "Database tables:\n" << _database.tables();

    qDebug() << "[Market] Uruchamianie serwera...";
    _server = new Server(this, serverPort);

    _sessionOffTimer = new QTimer(this);
    _sessionOffTimer->setInterval(sessionOffInterval * 1000);

    _sessionOnTimer = new QTimer(this);
    _sessionOnTimer->setInterval(sessionOnInterval * 1000);


    connect(_server, SIGNAL(registerUserRequestFromServer(Connection*, QString)),
            this,     SLOT(registerNewUser(Connection*, QString)) );

    connect(_server, SIGNAL(loginUserRequestFromServer(Connection*, NetworkProtocol::DTO::Types::UserIdType, QString)),
            this,     SLOT(loginUser(Connection*, NetworkProtocol::DTO::Types::UserIdType, QString)));

    connect(_database.driver(), SIGNAL(notification(const QString&, QSqlDriver::NotificationSource,
                                       const QVariant&)),
            this,               SLOT(notificationHandler(const QString&, QSqlDriver::NotificationSource,
                                     const QVariant&)));

    connect(_server, SIGNAL(sellStock(NetworkProtocol::DTO::Types::UserIdType, NetworkProtocol::DTO::Types::StockIdType,
                                      NetworkProtocol::DTO::Types::AmountType, NetworkProtocol::DTO::Types::PriceType)),
            this,     SLOT(sellStock(NetworkProtocol::DTO::Types::UserIdType, NetworkProtocol::DTO::Types::StockIdType,
                                     NetworkProtocol::DTO::Types::AmountType, NetworkProtocol::DTO::Types::PriceType)));

    connect(_server, SIGNAL(buyStock(NetworkProtocol::DTO::Types::UserIdType, NetworkProtocol::DTO::Types::StockIdType,
                                     NetworkProtocol::DTO::Types::AmountType, NetworkProtocol::DTO::Types::PriceType)),
            this,     SLOT(buyStock(NetworkProtocol::DTO::Types::UserIdType, NetworkProtocol::DTO::Types::StockIdType,
                                    NetworkProtocol::DTO::Types::AmountType, NetworkProtocol::DTO::Types::PriceType)));

    connect(_server, SIGNAL(getMyStocks(NetworkProtocol::DTO::Types::UserIdType)),
            this,     SLOT(getMyStocks(NetworkProtocol::DTO::Types::UserIdType)));

    connect(_server, SIGNAL(getMyOrders(NetworkProtocol::DTO::Types::UserIdType)),
            this, SLOT(getMyOrders(NetworkProtocol::DTO::Types::UserIdType)));

    connect(_server, SIGNAL(getStockInfo(NetworkProtocol::DTO::Types::UserIdType,
                                         NetworkProtocol::DTO::Types::StockIdType)),
            this,     SLOT(getStockInfo(NetworkProtocol::DTO::Types::UserIdType,
                                        NetworkProtocol::DTO::Types::StockIdType)));

    connect(_server, SIGNAL(cancelOrder(NetworkProtocol::DTO::Types::UserIdType,
                                        NetworkProtocol::DTO::Types::StockIdType)),
            this,     SLOT(cancelOrder(NetworkProtocol::DTO::Types::UserIdType,
                                       NetworkProtocol::DTO::Types::StockIdType)));

    connect(_sessionOnTimer, SIGNAL(timeout()),
            this,             SLOT(stopSession()));

    connect(_sessionOffTimer, SIGNAL(timeout()),
            this,              SLOT(startSession()));


    qDebug() << "[Market] Serwer jest aktywny.";
    startSession();
}
开发者ID:jam231,项目名称:sia,代码行数:98,代码来源:market.cpp


注:本文中的ConfigManager::intAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。