Exemplo n.º 1
0
/*!
 * \brief Uploads a \a file to \a path.
 *
 * \a Path should start with '/', append by bucket name and file path.
 * eg: /demobucket/upload.png. If the path is a directory, it MUST end with '/'.
 *
 * Sets \a autoMkdir to true if auto mkdir needed (10 at most).
 *
 * Sets \a appendFileMD5 to true if append file MD5 value needed. If this value
 * is different from the server computed, 406 Not Accepted will be recieved.
 *
 * Sets \a fileSecret as file secret key. ONLY picture spaces support secret.
 * If this is set, the file could not access directly by URL,
 * use THUMB_SEPERATOR + SECRET instead. eg, if THUMB_SEPERATOR is "!",
 * secret is "bac" and file upload path is "/folder/test.jpg", the image accessed
 * URL will be http://BUCKET/folder/test.jpg!bac.
 *
 * Extra parameters should be stored in \a params.
 *
 * \sa QUpYun::uploadFile(const QString &, const QString &, bool, bool, const QString &, const RequestParams &)
 * \sa QUpYun::requestUploadFinished(bool, const PicInfo &)
 */
void QUpYun::uploadFile(const QString &path,
                        QFile *file,
                        bool autoMkdir,
                        bool appendFileMD5,
                        const QString &fileSecret,
                        const RequestParams &params)
{
    if (!file->isOpen()) {
        file->open(QFile::ReadOnly);
    }
    RequestParams newParams(params);
    QByteArray data = file->readAll();
    if (appendFileMD5) {
        static QByteArray CONTENT_MD5("Content-MD5");
        newParams.insert(CONTENT_MD5, d->md5(data));
    }
    if (!fileSecret.isEmpty()) {
        static QByteArray CONTENT_SECRET("Content-Secret");
        newParams.insert(CONTENT_SECRET, fileSecret.toUtf8());
    }
    QNetworkReply *reply = d->sendRequest(QNetworkAccessManager::PutOperation,
                                          d->formatPath(path),
                                          data,
                                          autoMkdir,
                                          newParams);
    d->requests.insert(reply, Upload);
}
Exemplo n.º 2
0
// Main minimising method
mat MyMinimizer::minimise(double chisq)
{
    ++currentIt;
    if (currentIt > maxIterations)
    {
        finished = true;
        return newParams;
    }

    if ((chisq < lastChiSq) && ((lastChiSq - chisq) < convLimit))
    {
        // then this parameter has converged and we move on to the next
        currentParameter++;

        if (currentParameter > nParameters-1)
        {
            currentParameter = 0;
            currentCycle++;
            if (currentCycle > minCycles)
            {
                finished = true;
                return newParams;
            }				
        }
        lastChiSq = chisq;	
        newParams(currentParameter,0) = parameters(currentParameter,0)+currentStepsize;	
        return newParams;	
    }
    else
    {
        // We continue with the current parameter
        if (chisq < lastChiSq)
        {
            lastChiSq = chisq;
            newParams(currentParameter,0) = parameters(currentParameter,0)+currentStepsize;
            return newParams;
        }
        else
        {
            lastChiSq = chisq;
            currentStepsize = - currentStepsize * 0.5;
            newParams(currentParameter,0) = parameters(currentParameter,0)+currentStepsize;
            return newParams;
        }
    }
}
Exemplo n.º 3
0
boost::signals2::connection PhysicsSpace::connectCollision(const CollisionEventType::slot_type &listener, 
                                                           UInt64 Category,
                                                           Real32 SpeedThreshold,
                                                           boost::signals2::connect_position at)
{
    CollisionListenParams newParams(Category, SpeedThreshold, &listener);
    _CollisionListenParamsVec.push_back(newParams);

    return Inherited::connectCollision(listener,at);
}