コード例 #1
0
ファイル: CFScript.cpp プロジェクト: cdaffara/symbiandump-mw1
// -----------------------------------------------------------------------------
// CCFScript::EvaluateScript
// -----------------------------------------------------------------------------
//
TBool CCFScript::EvaluateScript( const CCFContextObject& aContext,
    TInt& aContextLevelDelay )
    {
    FUNC_LOG;

    TBool evaluated( EFalse );
    TInt delayRequirement( 0 );
    TInt delay( 0 );

    TPtrC name( iInfo->Name() );
    INFO_2( "CCFScript::EvaluateScript - Evaluating script NAME=[%S] ID=[%d] with context:",
        &name, iInfo->Id() );
    INFO_3( ">> %S: %S: %S", &aContext.Source(), &aContext.Type(), &aContext.Value() );

    // Evaluate first all operations requiring all context indications.
    for ( TInt index = 0; index < iRequiresAll.Count(); ++index )
        {
        if ( iRequiresAll[ index ]->Evaluate( aContext, delay ) )
            {
            evaluated = ETrue;
            if ( delay > delayRequirement )
                {
                delayRequirement = delay;
                }
            }
        }

    for ( TInt j = 0; j < iScriptSubscriptions.Count(); ++j )
        {
        CCFScriptSubscription* subscription = iScriptSubscriptions[ j ];
        if ( subscription->Match( aContext ) )
            {
            if ( subscription->NotifyListeners( aContext, delay ) )
                {
                evaluated = ETrue;
                }

            if ( delay > delayRequirement )
                {
                delayRequirement = delay;
                }
            break;
            }
        }

    if ( delayRequirement > 0 )
        {
        aContextLevelDelay = delayRequirement;
        }

    INFO_3( "CCFScript::EvaluateScript - Evaluated script ID=[%d]: CtxLevDelay=%dms, (1=evaluated, 0=no evaluation): %d",
            iInfo->Id(), aContextLevelDelay, evaluated );

    return evaluated;
    }
コード例 #2
0
/*!\brief Calculates the cost to reach each other node from the start node.
 *
 * \param start_node
 *  The node to start searching from.
 *
 * \return A vector containing the cost to reach each node from the start, as
 *  well as the path taken for each node.
 */
std::vector<DijkstraInfo> ALGraph::Dijkstra(unsigned start_node) const
{
    --start_node; // Bah, indices.
    std::priority_queue<AdjInfo> to_check;
    std::vector<bool> evaluated(myNodes.size(), false);
    std::vector<DijkstraInfo> info(myNodes.size()); 

    // Let's get our "infinite" values in.
    for (std::vector<DijkstraInfo>::iterator iter = info.begin();
            iter != info.end();
            ++iter)
    {
        (*iter).cost = UINT_MAX;
    }
    
    // Mark start node as evaluated.
    info[start_node].cost = 0u;
    info[start_node].path.push_back(start_node + 1); // Actual node number.
    to_check.push(myMakeAdjInfo(start_node, 0u));

    // We are ready to begin.
    while (!to_check.empty())
    {
        AdjInfo current = to_check.top();
        to_check.pop();

        if (!evaluated[current.node])
        {
            // Mark x as evaluated.
            evaluated[current.node] = true;

            // For each neighbor of x...
            for (EdgeList::const_iterator iter = myNodes[current.node].GetEdgeList().begin();
                    iter != myNodes[current.node].GetEdgeList().end();
                    ++iter)
            {
                // Chillax.
                if (current.cost + (*iter).GetWeight() < info[(*iter).GetDestination()].cost)
                {
                    // If new cost to reach neighbor is lower...
                    info[(*iter).GetDestination()].cost = current.cost + (*iter).GetWeight();
                    // Update the path list.
                    info[(*iter).GetDestination()].path = info[current.node].path;
                    info[(*iter).GetDestination()].path.push_back((*iter).GetDestination() + 1);
                }
                    
                // Queue it up for checking.
                to_check.push(myMakeAdjInfo((*iter).GetDestination(), info[(*iter).GetDestination()].cost));
            }
        }
    }

    return(info);
}
コード例 #3
0
void DebuggerAsciiViewer::UpdateView(const wxString &expr, const wxString &value)
{
	m_textCtrlExpression->SetValue(expr);

	wxString evaluated (value);
	evaluated.Replace(wxT("\r\n"), wxT("\n"));
	evaluated.Replace(wxT("\n,"), wxT(",\n"));
	evaluated.Replace(wxT("\n\n"), wxT("\n"));

	m_textView->SetReadOnly(false);
	m_textView->ClearAll();
	m_textView->SetText(evaluated);
	m_textView->SetReadOnly(true);

}
コード例 #4
0
ファイル: lax.hpp プロジェクト: andrewmoylan/grworkbench
template <typename A> operator const A() const { return from_value<A>()(evaluated().value()); }