コード例 #1
0
ファイル: ai_measurement.cpp プロジェクト: 8l/rose
 // obtain read or write variables processed by all nested loops, if any
 void getVariablesProcessedByInnerLoops (SgScopeStatement* current_loop_body, bool isRead, std::set<SgInitializedName*>& var_set)
 {
   // AST query to find all loops
   // add all read/write variables into the var_set
   VariantVector vv;
   vv.push_back(V_SgForStatement);  
   vv.push_back(V_SgFortranDo);  
   Rose_STL_Container<SgNode*> nodeList = NodeQuery::querySubTree(current_loop_body, vv); 
   for (Rose_STL_Container<SgNode *>::iterator i = nodeList.begin(); i != nodeList.end(); i++)
   {
     SgStatement* loop = isSgStatement(*i);
     if (debug)
       cout<< "Found nested loop at line:"<< loop->get_file_info()->get_line()<<endl;
     std::set<SgInitializedName*> src_var_set ;
     if (isRead)
       src_var_set = LoopLoadVariables[loop];
     else
       src_var_set = LoopStoreVariables[loop];
     std::set<SgInitializedName*>::iterator j; 
     if (debug)
       cout<< "\t Insert processed variable:"<<endl;
     for (j= src_var_set.begin(); j!= src_var_set.end(); j++)
     {
        var_set.insert(*j);
       if (debug)
         cout<< "\t \t "<<(*j)->get_name()<<endl;
     }
   }
 }
コード例 #2
0
VariantVector ParticleEmitter::GetParticleBillboardsAttr() const
{
    VariantVector ret;
    if (!serializeParticles_)
    {
        ret.push_back((int)billboards_.size());
        return ret;
    }

    ret.reserve(billboards_.size() * 7 + 1);
    ret.push_back((int)billboards_.size());

    for (auto i = billboards_.begin(); i != billboards_.end(); ++i)
    {
        ret.push_back(i->position_);
        ret.push_back(i->size_);
        ret.push_back(Vector4(i->uv_.min_.x_, i->uv_.min_.y_, i->uv_.max_.x_, i->uv_.max_.y_));
        ret.push_back(i->color_);
        ret.push_back(i->rotation_);
        ret.push_back(i->direction_);
        ret.push_back(i->enabled_);
    }

    return ret;
}
コード例 #3
0
VariantVector AnimationController::GetAnimationsAttr() const
{
    VariantVector ret;
    ret.reserve(animations_.size() * 5);
    for (auto i = animations_.begin(); i != animations_.end(); ++i)
    {
        ret.push_back(i->name_);
        ret.push_back(i->speed_);
        ret.push_back(i->targetWeight_);
        ret.push_back(i->fadeTime_);
        ret.push_back(i->autoFadeTime_);
    }
    return ret;
}
コード例 #4
0
 void registerAstSubtreeIds (SgNode* root)
 {
   // We only care about located nodes for now since they are visible to users in source code
   // we have to include SgProject and SgSourceFile nodes also.
   VariantVector vv;  
   vv.push_back(V_SgProject);
   vv.push_back(V_SgSourceFile);
   vv.push_back(V_SgLocatedNode);
   Rose_STL_Container <SgNode*> nodeList = NodeQuery::querySubTree (root, vv);
   for (Rose_STL_Container <SgNode*>::iterator iter = nodeList.begin(); iter != nodeList.end(); iter++)
   {
     SgNode* n = (*iter);
     setId (n);
   } 
 }
コード例 #5
0
VariantVector AnimationController::GetNodeAnimationStatesAttr() const
{
    VariantVector ret;
    ret.reserve(nodeAnimationStates_.size() * 3 + 1);
    ret.push_back((int)nodeAnimationStates_.size());
    for (auto i = nodeAnimationStates_.begin(); i != nodeAnimationStates_.end(); ++i)
    {
        AnimationState* state = *i;
        Animation* animation = state->GetAnimation();
        ret.push_back(GetResourceRef(animation, Animation::GetTypeStatic()));
        ret.push_back(state->IsLooped());
        ret.push_back(state->GetTime());
    }
    return ret;
}
コード例 #6
0
ファイル: XMLElement.cpp プロジェクト: rokups/Urho3D
VariantVector XMLElement::GetVariantVector() const
{
    VariantVector ret;

    XMLElement variantElem = GetChild("variant");
    while (variantElem)
    {
        ret.push_back(variantElem.GetVariant());
        variantElem = variantElem.GetNext("variant");
    }

    return ret;
}
コード例 #7
0
VariantVector ParticleEmitter::GetParticlesAttr() const
{
    VariantVector ret;
    if (!serializeParticles_)
    {
        ret.push_back((int)particles_.size());
        return ret;
    }

    ret.reserve(particles_.size() * 8 + 1);
    ret.push_back((int)particles_.size());
    for (auto i = particles_.begin(); i != particles_.end(); ++i)
    {
        ret.push_back(i->velocity_);
        ret.push_back(i->size_);
        ret.push_back(i->timer_);
        ret.push_back(i->timeToLive_);
        ret.push_back(i->scale_);
        ret.push_back(i->rotationSpeed_);
        ret.push_back(i->colorIndex_);
        ret.push_back(i->texIndex_);
    }
    return ret;
}
コード例 #8
0
VariantVector ConnectionSettings::getChildren(ConnectionSettings *parent)
{
    VariantVector vector;

    // Get children
    auto children = SmartObject::getChildren();

    for (auto it = children.begin(); it != children.end(); ++it) {

        auto child = static_cast<ConnectionSettings *>(*it);

        // Add to collection
        vector.push_back(child->toVariantMap());
    }

    return vector;
}
コード例 #9
0
/**
 *
 * Saves connection settings given an array of settings. This also destroys
 * their pointers if destroy is true
 *
 * @param settings An array of connection settings
 * @param format The file format to use
 * @param filename The filename to save to
 * @return void
 */
void ConnectionSettings::save(
        std::vector<ConnectionSettings *> &settings, FileFormat format,
        std::string filename)
{
    VariantVector connections;
    FileStream *stream;

    for (auto it = settings.cbegin(); it != settings.cend(); ++it) {

        auto connection = (*it);

        if (connection->getParent() == nullptr) {

            // Add to collection
            connections.push_back(connection->toVariantMap());
        }
    }

    switch (format) {
        case FileFormat::BINARY:

            stream = new BinaryFileStream();
            break;
        case FileFormat::JSON:

            stream = new JsonFileStream();
    }

    // Open stream
    stream->open(filename, std::ios::out);

    // Save connections
    *stream << connections;

    // Close stream
    stream->close();

    // Free memory
    delete stream;
}
コード例 #10
0
//----------------------------------------------------------------------------
//
STDMETHODIMP CAnchoAddonService::getAllWindows(LPDISPATCH aCreator, BOOL aPopulate, VARIANT* aRet)
{
  if (!aCreator) {
    return E_POINTER;
  }
  ENSURE_RETVAL(aRet);

  VariantVector windowInfos;
  HWND hIEFrame = NULL;
  do {
    hIEFrame = ::FindWindowEx(NULL, hIEFrame, L"IEFrame", NULL);
    if (hIEFrame) {
      CComVariant info;
      if (S_OK != createIDispatchFromCreator(aCreator, &info)) {
        return E_FAIL;
      }
      CIDispatchHelper infoHelper(info.pdispVal);
      fillWindowInfo(hIEFrame, infoHelper);

      windowInfos.push_back(info);
    }
  }while(hIEFrame);
  return constructSafeArrayFromVector(windowInfos, *aRet);
}
コード例 #11
0
/**
 *
 * Executes a query and returns the result
 *
 * @param VariantVector arguments The query arguments. The first argument should
 * be the query and any subsequent arguments are the bind parameters
 *
 * @return The results from the query
 */
QueryResult DatabaseConnection::execute(VariantVector arguments)
{
    int i;
    int count;
    QueryResult result;
    ResultSet *sqlResult;
    ResultSetMetaData *sqlMetadata;

    result = connect();
    if (result.error.isError) {

        // There was an error connecting. Return the result.
        return result;
    }

    PreparedStatement *sqlStatement = nullptr;

    try {

        // Prepare query
        sqlStatement = connection->prepareStatement(
            arguments.front().toString());

        if (arguments.size() > 1) {

            // Bind arguments
            int i = 1;
            for (auto it = arguments.begin() + 1; it != arguments.end(); ++it) {

                sqlStatement->setString(i, it->toString());

                i++;
            }
        }

        // Execute query
        sqlStatement->execute();

        // Fetch results
        sqlResult = sqlStatement->getResultSet();
    } catch (SQLException &e) {

        if (sqlStatement != nullptr) {

            // Free memory
            delete sqlStatement;
        }

        result.error.isError = true;
        result.error.code = e.getErrorCode();
        result.error.string = e.getSQLState() + ": " + e.what();

        return result;
    }

    sqlMetadata = sqlResult->getMetaData();

    count = sqlMetadata->getColumnCount();

    for (i = 1; i <= count; i++) {

        // Add to collection
        result.columns.push_back(sqlMetadata->getColumnName(i).asStdString());
    }

    // Read rows
    while (sqlResult->next()) {
        VariantVector row;
        for (i = 1; i <= count; i++) {
            Variant column;

            switch (sqlMetadata->getColumnType(i)) {
            default:
            case ::DataType::UNKNOWN:
            case ::DataType::CHAR:
            case ::DataType::VARCHAR:
            case ::DataType::LONGVARCHAR:
            case ::DataType::BINARY:
            case ::DataType::VARBINARY:
            case ::DataType::LONGVARBINARY:
            case ::DataType::TIMESTAMP:
            case ::DataType::DATE:
            case ::DataType::GEOMETRY:
            case ::DataType::ENUM:
            case ::DataType::SET:
            case ::DataType::BIGINT:
            case ::DataType::REAL:
            case ::DataType::DOUBLE:
            case ::DataType::DECIMAL:
                // @TODO: store binary, timestamp, date, & geometry differently
                // Also numeric types (need to be added to Variant class)
                column = sqlResult->getString(i).asStdString();
                break;
            case ::DataType::SQLNULL:
                column = Variant();
                break;
            case ::DataType::BIT:
            case ::DataType::TINYINT:
            case ::DataType::SMALLINT:
            case ::DataType::MEDIUMINT:
            case ::DataType::INTEGER:
            case ::DataType::NUMERIC:
                column = sqlResult->getInt(i);
                break;
            case ::DataType::YEAR:
                column = static_cast<unsigned short>(sqlResult->getUInt(i));
                break;
            }

            // Add column to collection
            row.push_back(column);
        }

        // Add row to collection
        result.rows.push_back(row);
    }

    // Free memory
    delete sqlResult;
    delete sqlStatement;

    return result;
}
コード例 #12
0
ファイル: SceneResolver.cpp プロジェクト: rokups/Urho3D
void SceneResolver::Resolve()
{
    // Nodes do not have component or node ID attributes, so only have to go through components
    ea::hash_set<StringHash> noIDAttributes;
    for (auto i = components_.begin(); i !=
        components_.end(); ++i)
    {
        Component* component = i->second;
        if (!component || noIDAttributes.contains(component->GetType()))
            continue;

        bool hasIDAttributes = false;
        const ea::vector<AttributeInfo>* attributes = component->GetAttributes();
        if (!attributes)
        {
            noIDAttributes.insert(component->GetType());
            continue;
        }

        for (unsigned j = 0; j < attributes->size(); ++j)
        {
            const AttributeInfo& info = attributes->at(j);
            if (info.mode_ & AM_NODEID)
            {
                hasIDAttributes = true;
                unsigned oldNodeID = component->GetAttribute(j).GetUInt();

                if (oldNodeID)
                {
                    auto k = nodes_.find(oldNodeID);

                    if (k != nodes_.end() && k->second)
                    {
                        unsigned newNodeID = k->second->GetID();
                        component->SetAttribute(j, Variant(newNodeID));
                    }
                    else
                        URHO3D_LOGWARNING("Could not resolve node ID " + ea::to_string(oldNodeID));
                }
            }
            else if (info.mode_ & AM_COMPONENTID)
            {
                hasIDAttributes = true;
                unsigned oldComponentID = component->GetAttribute(j).GetUInt();

                if (oldComponentID)
                {
                    auto k = components_.find(
                        oldComponentID);

                    if (k != components_.end() && k->second)
                    {
                        unsigned newComponentID = k->second->GetID();
                        component->SetAttribute(j, Variant(newComponentID));
                    }
                    else
                        URHO3D_LOGWARNING("Could not resolve component ID " + ea::to_string(oldComponentID));
                }
            }
            else if (info.mode_ & AM_NODEIDVECTOR)
            {
                hasIDAttributes = true;
                Variant attrValue = component->GetAttribute(j);
                const VariantVector& oldNodeIDs = attrValue.GetVariantVector();

                if (oldNodeIDs.size())
                {
                    // The first index stores the number of IDs redundantly. This is for editing
                    unsigned numIDs = oldNodeIDs[0].GetUInt();
                    VariantVector newIDs;
                    newIDs.push_back(numIDs);

                    for (unsigned k = 1; k < oldNodeIDs.size(); ++k)
                    {
                        unsigned oldNodeID = oldNodeIDs[k].GetUInt();
                        auto l = nodes_.find(oldNodeID);

                        if (l != nodes_.end() && l->second)
                            newIDs.push_back(l->second->GetID());
                        else
                        {
                            // If node was not found, retain number of elements, just store ID 0
                            newIDs.push_back(0);
                            URHO3D_LOGWARNING("Could not resolve node ID " + ea::to_string(oldNodeID));
                        }
                    }

                    component->SetAttribute(j, newIDs);
                }
            }
        }

        // If component type had no ID attributes, cache this fact for optimization
        if (!hasIDAttributes)
            noIDAttributes.insert(component->GetType());
    }

    // Attributes have been resolved, so no need to remember the nodes after this
    Reset();
}