void RenderMaterial::bind(RenderMaterial::Pass pass, RenderMaterialInstance *materialInstance, bool instanced) const
{
	if(materialInstance)
	{
		uint32 numVariables = (uint32)m_variables.Size();
		for(uint32 i=0; i<numVariables; i++)
		{
			const Variable &variable = *m_variables[i];
			bindVariable(pass, variable, materialInstance->m_data+variable.getDataOffset());
		}
	}
}
Exemple #2
0
/*!
  \overload

  If \a localName is a valid \l {QXmlName::isNCName()} {NCName}, this
  function is equivalent to the following snippet.

  \snippet doc/src/snippets/code/src_xmlpatterns_api_qxmlquery.cpp 2

  A QXmlName is constructed from \a localName, and is passed
  to the appropriate overload along with \a device.

  \sa QXmlName::isNCName()
 */
void QXmlQuery::bindVariable(const QString &localName, QIODevice *device)
{
    bindVariable(QXmlName(d->namePool, localName), device);
}
Exemple #3
0
/*!
  \overload

  This function constructs a QXmlName from \a localName using the
  query's \l {QXmlNamePool} {namespace}. The function then behaves as
  the overloaded function. It is equivalent to the following snippet.

  \snippet doc/src/snippets/code/src_xmlpatterns_api_qxmlquery.cpp 0
 */
void QXmlQuery::bindVariable(const QString &localName, const QXmlItem &value)
{
    bindVariable(QXmlName(d->namePool, localName), value);
}
Exemple #4
0
/*!
 \overload

 Has the same behavior and effects as the function being overloaded, but takes
 the variable name \a localName as a QString. \a query is used as in the
 overloaded function.

  \since 4.5
 */
void QXmlQuery::bindVariable(const QString &localName, const QXmlQuery &query)
{
    return bindVariable(QXmlName(d->namePool, localName), query);
}
Exemple #5
0
/***************************************************************************//**

********************************************************************************/
bool WindowIterator::nextImpl(store::Item_t& aResult, PlanState& planState) const
{
  store::Iterator_t iterator;

  WindowState* state;
  DEFAULT_STACK_INIT(WindowState, state, planState);

  // Pull the next tuple from the input stream
  while (consumeNext(aResult, theTupleIter, planState))
  {
    // Create the temp sequence where to materialize the result of the domain
    // expr (lazily if theLazyEval flag is true).
    iterator = new PlanIteratorWrapper(theInputIter, planState);
    state->theDomainSeq = GENV_STORE.createTempSeq(iterator, theLazyEval);

    // Its clever to switch quite early to avoid a lot of if-else statements
    if (theWindowType == WindowIterator::SLIDING)
    {
      // Get the next item from the domain sequence
      // TODO: can the xs_integer be hoisted?
      while (state->theDomainSeq->containsItem(xs_integer(state->theCurInputPos)))
      {
        // If the current item satisfies the start condition, create a candidate
        // window starting at the current domain item.
        if (theStartClause.evaluate(planState,
                                    state->theDomainSeq,
                                    state->theCurInputPos))
        {
          state->theOpenWindows.push_back(WindowDef(state->theCurInputPos));
        }

        // For each candidate window, check if the current domain item satisfies
        // the end condition. Notice that before evaluating the end condition
        // expr, we must rebind the internal vars of the start condition, because
        // those varaibles may be refrenced in the end cond expr.
        state->theCurWindow = state->theOpenWindows.begin();

        while ( state->theCurWindow != state->theOpenWindows.end() )
        {
          if (state->theCurWindow->theEndPos == 0)
          {
            theStartClause.bindIntern(planState,
                                      state->theDomainSeq,
                                      state->theCurWindow->theStartPos);

            ulong lCurPos = state->theCurInputPos;
            if ( theEndClause.evaluate(planState,
                                       state->theDomainSeq,
                                       lCurPos))
            {
              state->theCurWindow->theEndPos = lCurPos;
            }
          }

          ++state->theCurWindow;
        }

        // Try to return closed windows to the consumer iterator. Notice that
        // windows must be sorted according to the position of their starting
        // items in the domain sequence. So, we can return a closed window only
        // if it appears as the first window in state->theOpenWindows.
        state->theCurWindow = state->theOpenWindows.begin();

        while (!state->theOpenWindows.empty())
        {
          if (state->theCurWindow->theEndPos != 0)
          {
            // The current window is closed and its starting item is before the
            // stating items of all other windows (open or closed) in the domain
            // sequence. So, (a) bind the window var and the external vars of 
            // the start and end conditions, (b) remove the window from the set
            // of candidate windows, (c) purge from the domain temp seq any item
            // that we know for sure they will not be needed in subsequent 
            // evaluations of the start and/or end conditions, and (d) return to
            // the caller a new tuple that consists of the current input tuple
            // augmented with one column per variable that was bound in this step.
            theStartClause.bindExtern(planState,
                                      state->theDomainSeq,
                                      state->theCurWindow->theStartPos);

            theEndClause.bindExtern(planState,
                                    state->theDomainSeq,
                                    state->theCurWindow->theEndPos);

            bindVariable(planState,
                         state->theDomainSeq,
                         state->theCurWindow->theStartPos,
                         state->theCurWindow->theEndPos);

            state->theCurWindow = state->theOpenWindows.erase(state->theCurWindow);

            //doGarbageCollection(state);

            if (theTreatIter)
            {
              store::Item_t tmp;
              while (consumeNext(tmp, theTreatIter, planState))
              {
                ;
              }

              theTreatIter->reset(planState);
            }

            STACK_PUSH(true, state);
          }
          else
          {
            break;
          }
        }

        ++state->theCurInputPos;
      }
    }
    else //Tumpling window
    {
      // Doing this switch now also avoids further overhad
      if (theEndClause.theHasEndClause)
      {
        while (state->theDomainSeq->containsItem(xs_integer(state->theCurInputPos)))
        {
          if (state->theOpenWindows.empty() &&
              theStartClause.evaluate(planState,
                                      state->theDomainSeq,
                                      state->theCurInputPos))
          {
            theStartClause.bindExtern(planState,
                                      state->theDomainSeq,
                                      state->theCurInputPos);

            state->theOpenWindows.push_back(state->theCurInputPos);
          }

          if ( !state->theOpenWindows.empty() &&
               theEndClause.evaluate(planState,
                                     state->theDomainSeq,
                                     state->theCurInputPos))
          {
            theEndClause.bindExtern(planState,
                                    state->theDomainSeq,
                                    state->theCurInputPos);

            bindVariable(planState,
                         state->theDomainSeq,
                         state->theOpenWindows[0].theStartPos,
                         state->theCurInputPos);

            state->theOpenWindows.pop_back();

            assert(state->theOpenWindows.empty());

            if (theTreatIter)
            {
              store::Item_t tmp;
              while (consumeNext(tmp, theTreatIter, planState))
              {
                ;
              }

              theTreatIter->reset(planState);
            }

            STACK_PUSH(true, state);

            doGarbageCollection(state);
          }

          ++state->theCurInputPos;
        }
      }
      else
      {
        while (state->theDomainSeq->containsItem(xs_integer(state->theCurInputPos)))
        {
          if (theStartClause.evaluate(planState,
                                      state->theDomainSeq,
                                      state->theCurInputPos))
          {
            if (!state->theOpenWindows.empty())
            {
              //In no case there should be more than 1 position inside
              assert(state->theOpenWindows.size() == 1);

              theStartClause.bindExtern(planState,
                                        state->theDomainSeq,
                                        state->theOpenWindows[0].theStartPos);

              bindVariable(planState,
                           state->theDomainSeq,
                           state->theOpenWindows[0].theStartPos,
                           state->theCurInputPos  - 1);

              state->theOpenWindows.pop_back();

              assert(state->theOpenWindows.empty());

              if (theTreatIter)
              {
                store::Item_t tmp;
                while (consumeNext(tmp, theTreatIter, planState))
                {
                  ;
                }

                theTreatIter->reset(planState);
              }

              STACK_PUSH(true, state);

              --state->theCurInputPos;
              doGarbageCollection(state);
              ++state->theCurInputPos;
            }

            state->theOpenWindows.push_back(state->theCurInputPos);
          }

          ++state->theCurInputPos;
        }
      }
    }

    // Check if we have open and/or closed windows
    state->theCurWindow = state->theOpenWindows.begin();

    while (state->theCurWindow != state->theOpenWindows.end())
    {
      if (!theEndClause.theOnlyEnd || state->theCurWindow->theEndPos != 0)
      {
        if (state->theCurWindow->theEndPos == 0)
          state->theCurWindow->theEndPos = state->theCurInputPos - 1;

        bindVariable(planState,
                     state->theDomainSeq,
                     state->theOpenWindows[0].theStartPos,
                     state->theCurWindow->theEndPos);

        theStartClause.bindExtern(planState,
                                  state->theDomainSeq,
                                  state->theOpenWindows[0].theStartPos);

        theEndClause.bindExtern(planState,
                                state->theDomainSeq,
                                state->theCurWindow->theEndPos);

        state->theCurWindow = state->theOpenWindows.erase(state->theCurWindow);

        if (theTreatIter)
        {
          store::Item_t tmp;
          while (consumeNext(tmp, theTreatIter, planState))
          {
            ;
          }

          theTreatIter->reset(planState);
        }

        STACK_PUSH(true, state);
      }
      else
      {
        ++state->theCurWindow;
      }
    }

    theInputIter->reset(planState);
    state->reset(planState);
  }

  STACK_PUSH(false, state);
  STACK_END(state);
}