示例#1
0
bool Foam::regIOobject::checkIn()
{
    if (!registered_)
    {
        // multiple checkin of same object is disallowed - this would mess up
        // any mapping
        registered_ = db().checkIn(*this);

        if
        (
            registered_
         && readOpt() == MUST_READ_IF_MODIFIED
         && time().runTimeModifiable()
        )
        {
            if (watchIndex_ != -1)
            {
                FatalErrorInFunction
                    << "Object " << objectPath()
                    << " already watched with index " << watchIndex_
                    << abort(FatalError);
            }

            fileName f = filePath();
            if (!f.size())
            {
                // We don't have this file but would like to re-read it.
                // Possibly if master-only reading mode.
                f = objectPath();
            }
            watchIndex_ = time().addWatch(f);
        }

        // check-in on defaultRegion is allowed to fail, since subsetted meshes
        // are created with the same name as their originating mesh
        if (!registered_ && debug && name() != polyMesh::defaultRegion)
        {
            if (debug == 2)
            {
                // for ease of finding where attempted duplicate check-in
                // originated
                FatalErrorInFunction
                    << "failed to register object " << objectPath()
                    << " the name already exists in the objectRegistry" << endl
                    << "Contents:" << db().sortedToc()
                    << abort(FatalError);
            }
            else
            {
                WarningInFunction
                    << "failed to register object " << objectPath()
                    << " the name already exists in the objectRegistry"
                    << endl;
            }
        }
    }

    return registered_;
}
void QOfonoModemInterface::onModemInterfacesChanged(const QStringList &interfaces)
{
    if (interfaces.contains(privateData()->interfaceName)) {
        Q_ASSERT(!objectPath().isEmpty());
        if (!dbusInterface()) {
            setDbusInterface(createDbusInterface(objectPath()), NULL);
        }
    } else {
        setDbusInterface(NULL, NULL);
    }
}
void NetworkRegistrationWatcher::getPropertiesAsyncCallback(QDBusPendingCallWatcher *watcher)
{
    QDBusPendingReply<QVariantMap> reply = *watcher;
    if (reply.error().isValid()) {
        log_error("DBus call to interface %s function GetProperties of path %s failed: %s",
                  interface().toStdString().c_str(),
                  objectPath().toStdString().c_str(),
                  reply.error().message().toStdString().c_str());
        return;
    }

    QVariantMap map = reply.argumentAt<0>();
    foreach (const QString &key, map.keys())
        emit propertyChanged(objectPath(), key, map.value(key));
}
Foam::Istream& Foam::regIOobject::readStream()
{
    if (IFstream::debug)
    {
        Info<< "regIOobject::readStream() : "
            << "reading object " << name()
            << " from file " << objectPath()
            << endl;
    }

    if (readOpt() == NO_READ)
    {
        FatalErrorIn("regIOobject::readStream()")
            << "NO_READ specified for read-constructor of object " << name()
            << " of class " << headerClassName()
            << abort(FatalError);
    }

    // Construct object stream and read header if not already constructed
    if (!isPtr_)
    {
        if (!(isPtr_ = objectStream()))
        {
            FatalIOError
            (
                "regIOobject::readStream()",
                __FILE__,
                __LINE__,
                objectPath(),
                0
            )   << "cannot open file"
                << exit(FatalIOError);
        }
        else if (!readHeader(*isPtr_))
        {
            FatalIOErrorIn("regIOobject::readStream()", *isPtr_)
                << "problem while reading header for object " << name()
                << exit(FatalIOError);
        }
    }

    if (!lastModified_)
    {
        lastModified_ = lastModified(filePath());
    }

    return *isPtr_;
}
void QOfonoModemInterface::objectPathChanged(const QString &path, const QVariantMap *)
{
    // The base implementation would immediately create the D-Bus interface
    // object. However we need to check if our interface is actually available
    // and postpone creation of the D-Bus interface object if our interface
    // isn't there (see onModemInterfacesChanged below)
    bool wasReady = isReady();

    Private *d_ptr = privateData();
    if (!d_ptr->modem.isNull()) {
        disconnect(d_ptr->modem.data(), SIGNAL(interfacesChanged(QStringList)),
            this, SLOT(onModemInterfacesChanged(QStringList)));
        d_ptr->modem.reset();
    }

    setDbusInterface(NULL, NULL);

    d_ptr->modem = QOfonoModem::instance(objectPath());
    connect(d_ptr->modem.data(), SIGNAL(interfacesChanged(QStringList)),
        this, SLOT(onModemInterfacesChanged(QStringList)));

    Q_EMIT modemPathChanged(path);
    onModemInterfacesChanged(d_ptr->modem->interfaces());
    if (wasReady != isReady()) {
        Q_EMIT readyChanged();
    }
}
Foam::Istream& Foam::regIOobject::readStream(const word& expectName)
{
    if (IFstream::debug)
    {
        Info<< "regIOobject::readStream(const word&) : "
            << "reading object " << name()
            << " from file " << objectPath()
            << endl;
    }

    // Construct IFstream if not already constructed
    if (!isPtr_)
    {
        readStream();

        // Check the className of the regIOobject
        // dictionary is an allowable name in case the actual class
        // instantiated is a dictionary
        if
        (
            expectName.size()
         && headerClassName() != expectName
         && headerClassName() != "dictionary"
        )
        {
            FatalIOErrorIn("regIOobject::readStream(const word&)", *isPtr_)
                << "unexpected class name " << headerClassName()
                << " expected " << expectName << endl
                << "    while reading object " << name()
                << exit(FatalIOError);
        }
    }

    return *isPtr_;
}
void regIOobject::checkIn()
{
    if (!registered_)
    {
        // Attempt to register object with objectRegistry
        if (!db().checkIn(*this))
        {
            // Disallow checkin of same object twice since would mess up
            // any mapping.
            // Check on defaultRegion is needed to prevent subsetted meshes
            // (which are created with same name as their originating mesh)
            // from upsetting this.
            if (debug && name() != polyMesh::defaultRegion)
            {
                WarningIn("regIOobject::checkIn()")
                    << "failed to register object " << objectPath()
                    << " the name already exists in the objectRegistry"
                    << endl;
            }
        }
        else
        {
            registered_ = true;
        }
    }
}
示例#8
0
InputEventRecorder::EventDelivery::EventDelivery(int timeOffset, QObject *obj, QEvent *ev):
    m_TimeOffset(timeOffset),
    m_ClsName(obj->metaObject()->className()),
    m_ObjName(objectPath(obj)),
    m_Ev(ev)
{
}
NetworkRegistrationWatcher::NetworkRegistrationWatcher(const QString path, QObject *parent) :
    ModemWatcher(path, OfonoConstants::OFONO_NETWORKREGISTRATION_INTERFACE, parent)
{
    QDBusConnection::systemBus().connect(OfonoConstants::OFONO_SERVICE, objectPath(),
                                         interface(), "PropertyChanged",
                                         this, SLOT(onPropertyChanged(QString, QDBusVariant)));

    QObject::connect(this, SIGNAL(interfaceAvailableChanged(bool)),
                     this, SLOT(getPropertiesAsync()));
}
void NetworkRegistrationWatcher::getPropertiesAsync()
{
    if (!interfaceAvailable())
        return;

    QDBusInterface dbusInterface(OfonoConstants::OFONO_SERVICE, objectPath(), interface(),
                                 QDBusConnection::systemBus());
    if (!dbusInterface.isValid()) {
        log_error("Dbus interface %s of path %s is invalid.",
                  interface().toStdString().c_str(),
                  objectPath().toStdString().c_str());
        return;
    }

    QDBusPendingCall async = dbusInterface.asyncCall("GetProperties");
    QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this);
    QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
                     this, SLOT(getPropertiesAsyncCallback(QDBusPendingCallWatcher*)));
}
void OutgoingStreamTubeChannel::onContactsRetrieved(
        const QUuid &uuid,
        const QList<Tp::ContactPtr> &contacts)
{
    if (!isValid()) {
        debug() << "Invalidated OutgoingStreamTubeChannel not emitting queued connection event";
        return;
    }

    if (!mPriv->pendingNewConnections.contains(uuid)) {
        if (mPriv->pendingClosedConnections.contains(uuid)) {
            // closed connection
            Private::ClosedConnection conn = mPriv->pendingClosedConnections.take(uuid);

            // First, do removeConnection() so connectionClosed is emitted, and anybody connected to it
            // (like StreamTubeServer) has a chance to recover the source address / contact
            removeConnection(conn.id, conn.error, conn.message);

            // Remove stuff from our hashes
            mPriv->contactsForConnections.remove(conn.id);

            QHash<QPair<QHostAddress, quint16>, uint>::iterator srcAddrIter =
                mPriv->connectionsForSourceAddresses.begin();
            while (srcAddrIter != mPriv->connectionsForSourceAddresses.end()) {
                if (srcAddrIter.value() == conn.id) {
                    srcAddrIter = mPriv->connectionsForSourceAddresses.erase(srcAddrIter);
                } else {
                    ++srcAddrIter;
                }
            }

            QHash<uchar, uint>::iterator credIter = mPriv->connectionsForCredentials.begin();
            while (credIter != mPriv->connectionsForCredentials.end()) {
                if (credIter.value() == conn.id) {
                    credIter = mPriv->connectionsForCredentials.erase(credIter);
                } else {
                    ++credIter;
                }
            }
        } else {
            warning() << "No pending connections found in OSTC" << objectPath() << "for contacts"
                << contacts;
        }

        return;
    }

    // new connection
    QPair<uint, QDBusVariant> connectionProperties = mPriv->pendingNewConnections.take(uuid);

    // Add it to our connections hash
    foreach (const Tp::ContactPtr &contact, contacts) {
        mPriv->contactsForConnections.insert(connectionProperties.first, contact);
    }
示例#12
0
Tp::ChannelDetails BaseChannel::details() const
{
    Tp::ChannelDetails details;
    details.channel = QDBusObjectPath(objectPath());
    details.properties.unite(immutableProperties());

    foreach(const AbstractChannelInterfacePtr & iface, mPriv->interfaces) {
        details.properties.unite(iface->immutableProperties());
    }

    return details;
}
void NetworkRegistrationWatcher::getProperties()
{
    if (!interfaceAvailable())
        return;

    QDBusMessage request = QDBusMessage::createMethodCall(OfonoConstants::OFONO_SERVICE,
                                                          objectPath(), interface(),
                                                          "GetProperties");
    QDBusReply<QVariantMap> reply = QDBusConnection::systemBus().call(request);
    if (reply.error().isValid()) {
        log_error("DBus call to interface %s function GetProperties of path %s failed: %s",
                  interface().toStdString().c_str(),
                  objectPath().toStdString().c_str(),
                  reply.error().message().toStdString().c_str());
        return;
    }

    QVariantMap map = reply.value();
    foreach (const QString &key, map.keys())
        emit propertyChanged(objectPath(), key, map.value(key));
}
示例#14
0
bool Foam::IOobject::headerOk()
{
    bool ok = true;

    Istream* isPtr = objectStream();

    // If the stream has failed return
    if (!isPtr)
    {
        if (objectRegistry::debug)
        {
            Info
                << "IOobject::headerOk() : "
                << "file " << objectPath() << " could not be opened"
                << endl;
        }

        ok = false;
    }
    else
    {
        // Try reading header
        if (!readHeader(*isPtr))
        {
            if (objectRegistry::debug)
            {
                IOWarningIn("IOobject::headerOk()", (*isPtr))
                    << "failed to read header of file " << objectPath()
                    << endl;
            }

            ok = false;
        }
    }

    delete isPtr;

    return ok;
}
示例#15
0
void PathObject::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* /*widget*/)
{
    QGraphicsScene* objScene = scene();
    if(!objScene) return;

    QPen paintPen = pen();
    painter->setPen(paintPen);
    updateRubber(painter);
    if(option->state & QStyle::State_Selected)  { paintPen.setStyle(Qt::DashLine); }
    if(objScene->property(ENABLE_LWT).toBool()) { paintPen = lineWeightPen(); }
    painter->setPen(paintPen);

    painter->drawPath(objectPath());
}
void Foam::unwatchedIOdictionary::addWatch()
{
    if (readOpt() == MUST_READ_IF_MODIFIED)
    {
        fileName f = filePath();
        if (!f.size())
        {
            // We don't have this file but would like to re-read it.
            // Possibly if master-only reading mode.
            f = objectPath();
        }

        if (findIndex(files_, f) != -1)
        {
            FatalErrorIn("regIOobject::addWatch()")
                << "Object " << objectPath() << " of type " << type()
                << " already watched" << abort(FatalError);
        }

        // If master-only reading only the master will have all dependencies
        // so scatter these to slaves
        bool masterOnly =
            global()
         && (
                regIOobject::fileModificationChecking == timeStampMaster
             || regIOobject::fileModificationChecking == inotifyMaster
            );

        if (masterOnly && Pstream::parRun())
        {
            Pstream::scatter(files_);
        }

        addWatch(f);
    }
}
示例#17
0
bool isoBubble::write() const
{
    // Create the path to the instance directory.
    mkDir(path());

    fileName outFileName = paddWithZeros(objectPath());

    if (OFstream::debug)
    {
        Info<< "regIOobject::write() : "
            << "writing file " << outFileName << endl; 
    }

    bubblePtr_->write(outFileName);

    return true;
}
示例#18
0
/// Constructor. Creates new adaptor for the given manager with the given
/// dbus connection. The connection \a conn is not retained.
PropertyAdaptor::PropertyAdaptor(PropertyPrivate* propertyPrivate, QDBusConnection *conn)
    : QDBusAbstractAdaptor(propertyPrivate), propertyPrivate(propertyPrivate), connection(conn)
{
    // Start listening to the QDBusServiceWathcer, to know when our client has
    // exited.
    sconnect(&serviceWatcher, SIGNAL(serviceUnregistered(const QString&)),
             this, SLOT(onClientExited(const QString&)));
    serviceWatcher.setConnection(*conn);

    sconnect(propertyPrivate, SIGNAL(valueChanged(const QVariantList&, const quint64&)),
             this, SIGNAL(ValueChanged(const QVariantList&, const quint64&)));

    // Start listening to ValueChanged signals. We only listen to the
    // same bus we're on: that means if the same property is provided
    // both on session and on system bus, overhearing won't work.
    connection->connect("", objectPath(), DBUS_INTERFACE, "ValueChanged",
                        this, SLOT(onValueChanged(QVariantList, quint64)));
}
Foam::fileName Foam::fileOperations::masterFileOperation::filePath
(
    const bool checkGlobal,
    const IOobject& io
) const
{
Pout<< "Starting filePath for:" << io.objectPath() << endl;

    fileName objPath;
    pathType searchType = fileOperation::NOTFOUND;
    word newInstancePath;
    if (Pstream::master())
    {
        objPath = filePath(checkGlobal, io, searchType, newInstancePath);
    }
    label masterType(searchType);
    Pstream::scatter(masterType);
    searchType = pathType(masterType);

    if
    (
        searchType == fileOperation::FINDINSTANCE
     || searchType == fileOperation::PROCESSORSFINDINSTANCE
    )
    {
        // Note: PROCESSORSFINDINSTANCE should never appear since our filePath
        // does not know about it

        Pstream::scatter(newInstancePath);
    }

    if (!Pstream::master())
    {
        objPath = objectPath(io, searchType, newInstancePath);
    }

Pout<< "Returning from file searching:" << endl
    << "    objectPath:" << io.objectPath() << endl
    << "    filePath  :" << objPath << endl
    << endl;
    return objPath;
}
示例#20
0
void testGetInstance(CIMClient& client, const char* ns)
{

   CIMInstance instance;
   Array<CIMKeyBinding> keyBindings;
   keyBindings.append(CIMKeyBinding(PROPERTY_NAME_INSTANCEID,
                                INSTANCEID_VALUE,
                                CIMKeyBinding::STRING));

   CIMObjectPath objectPath(String::EMPTY, ns,
                  CIM_QUERYCAPCLASS_NAME, keyBindings);

   instance = client.getInstance(ns, objectPath, false);

   Array<Uint16> providerReturnedVal;

   Uint32 prop = instance.findProperty(CIMName(PROPERTY_NAME_CQLFEATURES));
   instance.getProperty(prop).getValue().get(providerReturnedVal);

   _checkIfReturnedValueIsCorrect(providerReturnedVal);
}
bool Foam::regIOobject::writeObject
(
    IOstream::streamFormat fmt,
    IOstream::versionNumber ver,
    IOstream::compressionType cmp
) const
{
    if (!good())
    {
        SeriousErrorInFunction
            << "bad object " << name()
            << endl;

        return false;
    }

    if (instance().empty())
    {
        SeriousErrorInFunction
            << "instance undefined for object " << name()
            << endl;

        return false;
    }



    //- uncomment this if you want to write global objects on master only
    //bool isGlobal = global();
    bool isGlobal = false;

    if (instance() == time().timeName())
    {
        // Mark as written to local directory
        isGlobal = false;
    }
    else if
    (
        instance() != time().system()
     && instance() != time().caseSystem()
     && instance() != time().constant()
     && instance() != time().caseConstant()
    )
    {
        // Update instance
        const_cast<regIOobject&>(*this).instance() = time().timeName();

        // Mark as written to local directory
        isGlobal = false;
    }

    if (OFstream::debug)
    {
        if (isGlobal)
        {
            Pout<< "regIOobject::write() : "
                << "writing (global) file " << objectPath();
        }
        else
        {
            Pout<< "regIOobject::write() : "
                << "writing (local) file " << objectPath();
        }
    }


    bool osGood = false;


    // Everyone check or just master
    bool masterOnly =
        isGlobal
     && (
            regIOobject::fileModificationChecking == timeStampMaster
         || regIOobject::fileModificationChecking == inotifyMaster
        );


    if (Pstream::master() || !masterOnly)
    {
        //if (mkDir(path()))
        //{
        //    // Try opening an OFstream for object
        //    OFstream os(objectPath(), fmt, ver, cmp);
        //
        //    // If any of these fail, return (leave error handling to Ostream
        //    // class)
        //    if (!os.good())
        //    {
        //        return false;
        //    }
        //
        //    if (!writeHeader(os))
        //    {
        //        return false;
        //    }
        //
        //    // Write the data to the Ostream
        //    if (!writeData(os))
        //    {
        //        return false;
        //    }
        //
        //    writeEndDivider(os);
        //
        //    osGood = os.good();
        //}
        osGood = fileHandler().writeObject(*this, fmt, ver, cmp);
    }
    else
    {
        // Or scatter the master osGood?
        osGood = true;
    }

    if (OFstream::debug)
    {
        Pout<< " .... written" << endl;
    }

    // Only update the lastModified_ time if this object is re-readable,
    // i.e. lastModified_ is already set
    if (watchIndices_.size())
    {
        time().setUnmodified(watchIndices_.last());
    }

    return osGood;
}
Foam::fvSchemes::fvSchemes(const objectRegistry& obr)
:
    IOdictionary
    (
        IOobject
        (
            "fvSchemes",
            obr.time().system(),
            obr,
//             IOobject::MUST_READ,
            IOobject::READ_IF_PRESENT,  // Allow default dictionary creation
            IOobject::NO_WRITE
        )
    ),
    ddtSchemes_
    (
        ITstream
        (
            objectPath() + "::ddtSchemes",
            tokenList()
        )()
    ),
    defaultDdtScheme_
    (
        ddtSchemes_.name() + "::default",
        tokenList()
    ),
    d2dt2Schemes_
    (
        ITstream
        (
            objectPath() + "::d2dt2Schemes",
            tokenList()
        )()
    ),
    defaultD2dt2Scheme_
    (
        d2dt2Schemes_.name() + "::default",
        tokenList()
    ),
    interpolationSchemes_
    (
        ITstream
        (
            objectPath() + "::interpolationSchemes",
            tokenList()
        )()
    ),
    defaultInterpolationScheme_
    (
        interpolationSchemes_.name() + "::default",
        tokenList()
    ),
    divSchemes_
    (
        ITstream
        (
            objectPath() + "::divSchemes",
            tokenList()
        )()
    ),
    defaultDivScheme_
    (
        divSchemes_.name() + "::default",
        tokenList()
    ),
    gradSchemes_
    (
        ITstream
        (
            objectPath() + "::gradSchemes",
            tokenList()
        )()
    ),
    defaultGradScheme_
    (
        gradSchemes_.name() + "::default",
        tokenList()
    ),
    snGradSchemes_
    (
        ITstream
        (
            objectPath() + "::snGradSchemes",
            tokenList()
        )()
    ),
    defaultSnGradScheme_
    (
        snGradSchemes_.name() + "::default",
        tokenList()
    ),
    laplacianSchemes_
    (
        ITstream
        (
            objectPath() + "::laplacianSchemes",
            tokenList()
        )()
    ),
    defaultLaplacianScheme_
    (
        laplacianSchemes_.name() + "::default",
        tokenList()
    ),
    fluxRequired_
    (
        ITstream
        (
            objectPath() + "::fluxRequired",
            tokenList()
        )()
    ),
    defaultFluxRequired_(false),
    cacheFields_
    (
        ITstream
        (
            objectPath() + "::cacheFields",
            tokenList()
        )()
    )
{
    if (!headerOk())
    {
        if (debug)
        {
            InfoIn
            (
                "fvSchemes::fvSchemes(const objectRegistry& obr)"
            )   << "fvSchemes dictionary not found.  Creating default."
                << endl;
        }

        regIOobject::write();
    }

    read();
}
示例#23
0
bool Foam::regIOobject::writeObject
(
    IOstream::streamFormat fmt,
    IOstream::versionNumber ver,
    IOstream::compressionType cmp
) const
{
    if (!good())
    {
        SeriousErrorIn("regIOobject::write()")
            << "bad object " << name()
            << endl;

        return false;
    }

    if (instance().empty())
    {
        SeriousErrorIn("regIOobject::write()")
            << "instance undefined for object " << name()
            << endl;

        return false;
    }

    if
    (
        instance() != time().timeName()
     && instance() != time().system()
     && instance() != time().caseSystem()
     && instance() != time().constant()
     && instance() != time().caseConstant()
    )
    {
        const_cast<regIOobject&>(*this).instance() = time().timeName();
    }

    mkDir(path());

    if (OFstream::debug)
    {
        Info<< "regIOobject::write() : "
            << "writing file " << objectPath();
    }


    bool osGood = false;

    {
        // Try opening an OFstream for object
        OFstream os(objectPath(), fmt, ver, cmp);

        // If any of these fail, return (leave error handling to Ostream class)
        if (!os.good())
        {
            return false;
        }

        if (!writeHeader(os))
        {
            return false;
        }

        // Write the data to the Ostream
        if (!writeData(os))
        {
            return false;
        }

        writeEndDivider(os);

        osGood = os.good();
    }

    if (OFstream::debug)
    {
        Info<< " .... written" << endl;
    }

    // Only update the lastModified_ time if this object is re-readable,
    // i.e. lastModified_ is already set
    if (lastModified_)
    {
        lastModified_ = lastModified(objectPath());
    }

    return osGood;
}
示例#24
0
void PD_caltechImp::loadDataset(const string &path)
{
    train.push_back(vector< Ptr<Object> >());
    test.push_back(vector< Ptr<Object> >());
    validation.push_back(vector< Ptr<Object> >());

    createDirectory((path + "../images/"));

    vector<string> objectNames;
    getDirList(path, objectNames);
    for (vector<string>::iterator it=objectNames.begin(); it!=objectNames.end(); ++it)
    {
        Ptr<PD_caltechObj> curr(new PD_caltechObj);
        curr->name = *it;

        string objectPath(path + "../images/" + curr->name + "/");
        createDirectory(objectPath);

        string seqImagesPath(path + curr->name + "/");
        vector<string> seqNames;
        getDirList(seqImagesPath, seqNames);
        for (vector<string>::iterator itSeq=seqNames.begin(); itSeq!=seqNames.end(); ++itSeq)
        {
            string &seqName = *itSeq;

            createDirectory((objectPath + seqName));

            FILE *f = fopen((seqImagesPath + seqName).c_str(), "rb");

            #define SKIP 28+8+512
            fseek(f, SKIP, SEEK_CUR);

            unsigned int header[9];
            size_t res = fread(header, 9, 4, f);
            double fps;
            res = fread(&fps, 1, 8, f);
            fseek(f, 432, SEEK_CUR);

            /*printf("width %u\n", header[0]);
            printf("height %u\n", header[1]);
            printf("imageBitDepth %u\n", header[2]);
            printf("imageBitDepthReal %u\n", header[3]);
            printf("imageSizeBytes %u\n", header[4]);
            printf("imageFormat %u\n", header[5]);
            printf("numFrames %u\n", numFrames);
            printf("fps %f\n", fps);
            printf("trueImageSize %u\n", header[8]);*/
            unsigned int numFrames = header[6];

            string ext;
            switch (header[5])
            {
            case 100:
            case 200:
                ext = "raw";
                break;
            case 101:
                ext = "brgb8";
                break;
            case 102:
            case 201:
                ext = "jpg";
                break;
            case 103:
                ext = "jbrgb";
                break;
            case 001:
            case 002:
                ext = "png";
                break;
            }

            for (unsigned int i=0; i<numFrames; ++i)
            {
                unsigned int size;
                res = fread(&size, 1, 4, f);

                char imgName[20];
                sprintf(imgName, "/%u.%s", i, ext.c_str());
                curr->imageNames.push_back(imgName);

                // comment fseek and uncomment next block to unpack all frames
                fseek(f, size, SEEK_CUR);
                /*char *img = new char[size];
                fread(img, size, 1, f);
                string imgPath(objectPath + seqName + imgName);
                FILE *fImg = fopen(imgPath.c_str(), "wb");
                fwrite(img, size, 1, fImg);
                fclose(fImg);
                delete[] img;*/

                fseek(f, 12, SEEK_CUR);
            }

            if (0 != res) // should fix unused variable warning
            {
                res = 0;
            }

            fclose(f);
        }

        train.back().push_back(curr);
    }
}
示例#25
0
QString QOfonoModemInterface::modemPath() const
{
    return objectPath();
}
示例#26
0
Foam::fvSchemes::fvSchemes(const objectRegistry& obr)
:
    IOdictionary
    (
        IOobject
        (
            "fvSchemes",
            obr.time().system(),
            obr,
            (
                obr.readOpt() == IOobject::MUST_READ
             || obr.readOpt() == IOobject::READ_IF_PRESENT
              ? IOobject::MUST_READ_IF_MODIFIED
              : obr.readOpt()
            ),
            IOobject::NO_WRITE
        )
    ),
    ddtSchemes_
    (
        ITstream
        (
            objectPath() + ".ddtSchemes",
            tokenList()
        )()
    ),
    defaultDdtScheme_
    (
        ddtSchemes_.name() + ".default",
        tokenList()
    ),
    d2dt2Schemes_
    (
        ITstream
        (
            objectPath() + ".d2dt2Schemes",
            tokenList()
        )()
    ),
    defaultD2dt2Scheme_
    (
        d2dt2Schemes_.name() + ".default",
        tokenList()
    ),
    interpolationSchemes_
    (
        ITstream
        (
            objectPath() + ".interpolationSchemes",
            tokenList()
        )()
    ),
    defaultInterpolationScheme_
    (
        interpolationSchemes_.name() + ".default",
        tokenList()
    ),
    divSchemes_
    (
        ITstream
        (
            objectPath() + ".divSchemes",
            tokenList()
        )()
    ),
    defaultDivScheme_
    (
        divSchemes_.name() + ".default",
        tokenList()
    ),
    gradSchemes_
    (
        ITstream
        (
            objectPath() + ".gradSchemes",
            tokenList()
        )()
    ),
    defaultGradScheme_
    (
        gradSchemes_.name() + ".default",
        tokenList()
    ),
    snGradSchemes_
    (
        ITstream
        (
            objectPath() + ".snGradSchemes",
            tokenList()
        )()
    ),
    defaultSnGradScheme_
    (
        snGradSchemes_.name() + ".default",
        tokenList()
    ),
    laplacianSchemes_
    (
        ITstream
        (
            objectPath() + ".laplacianSchemes",
            tokenList()
        )()
    ),
    defaultLaplacianScheme_
    (
        laplacianSchemes_.name() + ".default",
        tokenList()
    ),
    fluxRequired_
    (
        ITstream
        (
            objectPath() + ".fluxRequired",
            tokenList()
        )()
    ),
    defaultFluxRequired_(false),
    steady_(false)
{
    if
    (
        readOpt() == IOobject::MUST_READ
     || readOpt() == IOobject::MUST_READ_IF_MODIFIED
     || (readOpt() == IOobject::READ_IF_PRESENT && headerOk())
    )
    {
        read(schemesDict());
    }
}
void NetworkRegistrationWatcher::onPropertyChanged(QString name, QDBusVariant value)
{
    emit propertyChanged(objectPath(), name, value.variant());
}
示例#28
0
Foam::fvSchemes::fvSchemes(const objectRegistry& obr)
    :
    IOdictionary
    (
       IOobject
       (
           "fvSchemes",
           obr.time().system(),
           obr,
           (
               obr.readOpt() == IOobject::MUST_READ
               ? IOobject::MUST_READ_IF_MODIFIED
               : obr.readOpt()
           ),
           IOobject::NO_WRITE
       )
    ),
    ddtSchemes_
    (
       ITstream
       (
           objectPath() + "::ddtSchemes",
           tokenList()
       )()
    ),
    defaultDdtScheme_
    (
       ddtSchemes_.name() + "::default",
       tokenList()
    ),
    d2dt2Schemes_
    (
       ITstream
       (
           objectPath() + "::d2dt2Schemes",
           tokenList()
       )()
    ),
    defaultD2dt2Scheme_
    (
       d2dt2Schemes_.name() + "::default",
       tokenList()
    ),
    interpolationSchemes_
    (
       ITstream
       (
           objectPath() + "::interpolationSchemes",
           tokenList()
       )()
    ),
    defaultInterpolationScheme_
    (
       interpolationSchemes_.name() + "::default",
       tokenList()
    ),
    divSchemes_
    (
       ITstream
       (
           objectPath() + "::divSchemes",
           tokenList()
       )()
    ),
    defaultDivScheme_
    (
       divSchemes_.name() + "::default",
       tokenList()
    ),
    gradSchemes_
    (
       ITstream
       (
           objectPath() + "::gradSchemes",
           tokenList()
       )()
    ),
    defaultGradScheme_
    (
       gradSchemes_.name() + "::default",
       tokenList()
    ),
    snGradSchemes_
    (
       ITstream
       (
           objectPath() + "::snGradSchemes",
           tokenList()
       )()
    ),
    defaultSnGradScheme_
    (
       snGradSchemes_.name() + "::default",
       tokenList()
    ),
    laplacianSchemes_
    (
       ITstream
       (
           objectPath() + "::laplacianSchemes",
           tokenList()
       )()
    ),
    defaultLaplacianScheme_
    (
       laplacianSchemes_.name() + "::default",
       tokenList()
    ),
    fluxRequired_
    (
       ITstream
       (
           objectPath() + "::fluxRequired",
           tokenList()
       )()
    ),
    defaultFluxRequired_(false)
{
    // persistent settings across reads is incorrect
    clear();

    if
    (
        readOpt() == IOobject::MUST_READ
        || readOpt() == IOobject::MUST_READ_IF_MODIFIED
    )
    {
        read(schemesDict());
    }
}
NetworkRegistrationWatcher::~NetworkRegistrationWatcher()
{
    QDBusConnection::systemBus().disconnect(OfonoConstants::OFONO_SERVICE, objectPath(),
                                            interface(), "PropertyChanged",
                                            this, SLOT(onPropertyChanged(QString, QDBusVariant)));
}