void FScriptExecutionNode::GetLinearExecutionPath(TArray<FLinearExecPath>& LinearExecutionNodes, const FTracePath& TracePath, const bool bIncludeChildren)
{
	LinearExecutionNodes.Add(FLinearExecPath(AsShared(), TracePath));
	if (bIncludeChildren)
	{
		for (auto Child : ChildNodes)
		{
			FTracePath ChildTracePath(TracePath);
			Child->GetLinearExecutionPath(LinearExecutionNodes, ChildTracePath, bIncludeChildren);
		}
	}
	if (bIncludeChildren || GetNumLinkedNodes() == 1)
	{
		for (auto NodeIter : LinkedNodes)
		{
			if (HasFlags(EScriptExecutionNodeFlags::PureStats))
			{
				continue;
			}
			else
			{
				FTracePath NewTracePath(TracePath);
				if (NodeIter.Value->HasFlags(EScriptExecutionNodeFlags::EventPin))
				{
					NewTracePath.ResetPath();
				}
				if (NodeIter.Key != INDEX_NONE && !HasFlags(EScriptExecutionNodeFlags::InvalidTrace))
				{
					NewTracePath.AddExitPin(NodeIter.Key);
				}
				NodeIter.Value->GetLinearExecutionPath(LinearExecutionNodes, NewTracePath, bIncludeChildren);
			}
		}
	}
}
示例#2
0
/** \fn DVBSignalMonitor::EmitStatus(void)
 *  \brief Emits signals for lock, signal strength, etc.
 */
void DVBSignalMonitor::EmitStatus(void)
{
    // Emit signals..
    DTVSignalMonitor::EmitStatus();
    if (HasFlags(kDVBSigMon_WaitForSNR))
        SendMessage(kStatusSignalToNoise,     signalToNoise);
    if (HasFlags(kDVBSigMon_WaitForBER))
        SendMessage(kStatusBitErrorRate,      bitErrorRate);
    if (HasFlags(kDVBSigMon_WaitForUB))
        SendMessage(kStatusUncorrectedBlocks, uncorrectedBlocks);
    if (HasFlags(kDVBSigMon_WaitForPos))
        SendMessage(kStatusRotorPosition,     rotorPosition);
}
示例#3
0
void FEPlayer::Serialize(TiXmlDocument* _poXmlDoc, TiXmlElement* _poParent)
{
	TiXmlElement* poPlayerElement = new TiXmlElement("Player");
	_poParent->LinkEndChild(poPlayerElement);

	poPlayerElement->SetAttribute("is_movable",	HasFlags(EFEFlag_Movable));
	poPlayerElement->SetAttribute("is_deletable", HasFlags(EFEFlag_Deletable));

	TiXmlElement* poPosElement = new TiXmlElement("Position");
	poPlayerElement->LinkEndChild(poPosElement);
	poPosElement->SetDoubleAttribute("x", m_vPos.x);
	poPosElement->SetDoubleAttribute("y", m_vPos.y);
}
void FScriptExecutionNode::UpdateHeatDisplayStats(FScriptExecutionHottestPathParams& HotPathParams)
{
	// Grab local perf data by tracepath.
	FTracePath& TracePath = HotPathParams.GetTracePath();
	TSharedPtr<FScriptPerfData> LocalPerfData = GetOrAddPerfDataByInstanceAndTracePath(HotPathParams.GetInstanceName(), TracePath);
	// Calculate hottest path value
	const float PathHeatLevel = HotPathParams.CalculateHeatLevel();
	LocalPerfData->SetHottestPathHeatLevel(PathHeatLevel);
	// Update the heat thresholds
	LocalPerfData->SetHeatLevels(HotPathParams.GetHeatThresholds());
	NodePerfData.SetHeatLevels(HotPathParams.GetHeatThresholds());
	// Update the time taken so far
	if (!IsEvent() && !HasFlags(EScriptExecutionNodeFlags::ExecPin))
	{
		HotPathParams.AddPathTiming(LocalPerfData->GetAverageTiming(), LocalPerfData->GetSampleCount());
	}
	// Update children and linked nodes
	if (!IsPureNode())
	{
		for (auto ChildIter : ChildNodes)
		{
			ChildIter->UpdateHeatDisplayStats(HotPathParams);
		}
		if (HasFlags(EScriptExecutionNodeFlags::ConditionalBranch))
		{
			for (auto LinkIter : LinkedNodes)
			{
				FScriptExecutionHottestPathParams LinkedHotPathParams(HotPathParams);
				if (!LinkIter.Value->HasFlags(EScriptExecutionNodeFlags::InvalidTrace))
				{
					LinkedHotPathParams.GetTracePath().AddExitPin(LinkIter.Key);
				}
				LinkIter.Value->UpdateHeatDisplayStats(LinkedHotPathParams);
			}
		}
		else
		{
			FTracePath RootTracePath(TracePath);
			for (auto LinkIter : LinkedNodes)
			{
				TracePath = RootTracePath;
				if (!LinkIter.Value->HasFlags(EScriptExecutionNodeFlags::InvalidTrace))
				{
					TracePath.AddExitPin(LinkIter.Key);
				}
				LinkIter.Value->UpdateHeatDisplayStats(HotPathParams);
			}
		}
	}
}
示例#5
0
QStringList DVBSignalMonitor::GetStatusList(bool kick)
{
    QStringList list = DTVSignalMonitor::GetStatusList(kick);
    statusLock.lock();
    if (HasFlags(kDVBSigMon_WaitForSNR))
        list<<signalToNoise.GetName()<<signalToNoise.GetStatus();
    if (HasFlags(kDVBSigMon_WaitForBER))
        list<<bitErrorRate.GetName()<<bitErrorRate.GetStatus();
    if (HasFlags(kDVBSigMon_WaitForUB))
        list<<uncorrectedBlocks.GetName()<<uncorrectedBlocks.GetStatus();
    if (HasFlags(kDVBSigMon_WaitForPos))
        list<<rotorPosition.GetName()<<rotorPosition.GetStatus();
    statusLock.unlock();
    return list;
}
void FScriptExecutionPureChainNode::RefreshStats(const FTracePath& TracePath)
{
	// Process stat update
	TArray<TSharedPtr<FScriptPerfData>> BlueprintPooledStats;
	// Refresh all pure nodes and accumulate for blueprint stat.
	if (HasFlags(EScriptExecutionNodeFlags::PureChain))
	{
		// Update linked pure nodes and find instances
		TSet<FName> ValidInstances;
		FTracePath PureTracePath(TracePath);
		TMap<int32, TSharedPtr<FScriptExecutionNode>> AllPureNodes;
		GetAllPureNodes(AllPureNodes);
		for (auto PureIter : AllPureNodes)
		{
			GetValidInstanceNames(ValidInstances);
			PureTracePath.AddExitPin(PureIter.Key);
			PureIter.Value->RefreshStats(PureTracePath);
		}
	}
	// Grab all instance stats to accumulate into the blueprint stat.
	GetInstancePerfDataByTracePath(TracePath, BlueprintPooledStats);
	// Update the owning blueprint stats
	if (BlueprintPooledStats.Num() > 0)
	{
		TSharedPtr<FScriptPerfData> BlueprintData = GetBlueprintPerfDataByTracePath(TracePath);
		BlueprintData->CreateBlueprintStats(BlueprintPooledStats);
	}
	// Update the node stats
	UpdatePerfDataForNode();
}
示例#7
0
void SignalMonitor::EmitStatus(void)
{
    SendMessage(kStatusChannelTuned, scriptStatus);
    SendMessage(kStatusSignalLock, signalLock);
    if (HasFlags(kSigMon_WaitForSig))
        SendMessage(kStatusSignalStrength,    signalStrength);
}
示例#8
0
void FERealPlayer::Draw()
{
	D_Color bodyColor = m_Color;
	if(HasFlags(EFEFlag_Selected))
		bodyColor = bodyColor / 1.5f;

	Vec2 playerPos(m_vPos.x - m_fPlayerRadius, m_vPos.y + m_fPlayerRadius);
	Vec2 playerScreenPos = CoordinateInfo::WorldToScreen(playerPos);
	g_poSROU->DrawFillRectangle(
		(f32)playerScreenPos.x,
		(f32)playerScreenPos.y,
		2 * m_fPlayerRadius * CoordinateInfo::GetPixelPerMeter(), 
		2 * m_fPlayerRadius * CoordinateInfo::GetPixelPerMeter(),
		bodyColor, D_Color(255, 255, 255));

	Vec2 indicatorPos(m_vPos.x - m_fPlayerRadius, m_vPos.y + m_fPlayerRadius);
	Vec2 indicatorScreenPos = CoordinateInfo::WorldToScreen(indicatorPos);
	Char indicator[4];
	if(m_bIsGK)
		strcpy(indicator, "G");
	else
		_itoa(m_Team == kHOME_TEAM ? (m_id) : (m_id - FESimulatedPlayer::sHomePlayerCount), indicator, 10);

	g_poSROU->DrawStringEx(
		indicatorScreenPos.x, 
		indicatorScreenPos.y,
		2 * m_fPlayerRadius * CoordinateInfo::GetPixelPerMeter(), 
		2 * m_fPlayerRadius * CoordinateInfo::GetPixelPerMeter(),
		kPLAYER_NUMSIZE * CoordinateInfo::GetPixelPerMeter(),
		indicator, NULL, D_Color(0,0,0));
}
示例#9
0
void FEPlayer::Move(const Vec2& pos)
{
	if(!HasFlags(EFEFlag_Movable))
		return;
	m_vPos = Vec3::FromVec2(ClampToPitch(pos));
	if(CoordinateInfo::sAwayView)
		m_vPos = -m_vPos;
}
示例#10
0
void FEPlayer::Draw()
{
	D_Color bodyColor = m_Color;
	if(HasFlags(EFEFlag_Selected))
		bodyColor = bodyColor / 1.5f;

	DrawWithColor(bodyColor);
}
示例#11
0
/** \brief Returns QStringList containing all signals and their current
 *         values.
 *
 *   This serializes the signal monitoring values so that they can
 *   be passed from a backend to a frontend.
 *
 *   SignalMonitorValue::Parse(const QStringList&) will convert this
 *   to a vector of SignalMonitorValue instances.
 */
QStringList SignalMonitor::GetStatusList(void) const
{
    QStringList list;
    statusLock.lock();
    list<<scriptStatus.GetName()<<scriptStatus.GetStatus();
    list<<signalLock.GetName()<<signalLock.GetStatus();
    if (HasFlags(kSigMon_WaitForSig))
        list<<signalStrength.GetName()<<signalStrength.GetStatus();
    statusLock.unlock();

    return list;
}
EScriptStatContainerType::Type FScriptExecutionNode::GetStatisticContainerType() const
{
	EScriptStatContainerType::Type Result = EScriptStatContainerType::Standard;
	if (IsPureNode())
	{
		Result = EScriptStatContainerType::PureNode;
	}
	else if (HasFlags(EScriptExecutionNodeFlags::ExecPin))
	{
		Result = EScriptStatContainerType::NewExecutionPath;
	}
	else if (HasFlags(EScriptExecutionNodeFlags::Container))
	{
		Result = EScriptStatContainerType::Container;
	}
	else if (HasFlags(EScriptExecutionNodeFlags::SequentialBranch))
	{
		Result = EScriptStatContainerType::SequentialBranch;
	}
	return Result;
}
示例#13
0
SNORTRULEHDR void CPcreOption::Precompile(CByteArray &pcResult) const
{
	int options = 0;
	if (HasFlags(PF_s))
	{
		options |= PCRE_DOTALL;
	}
	if (HasFlags(PF_m))
	{
		options |= PCRE_MULTILINE;
	}
	if (HasFlags(PF_i))
	{
		options |= PCRE_CASELESS;
	}
	if (HasFlags(PF_x))
	{
		options |= PCRE_EXTENDED;
	}

	const char *error;
	int erroffset;
	pcre *re = pcre_compile(m_strPcre.Data(), options, &error, &erroffset, null);
	if (re == null)
	{
		TTHROW(TI_INVALIDDATA);
	}

	pcResult.Clear();
	unsigned int size;
	unsigned short name_table_offset;
	size = *((unsigned int*)re + 1);
	name_table_offset = *((unsigned short*)re + 12);
	for (ulong i = 0; i < size - name_table_offset; ++i)
	{
		pcResult.PushBack((byte)*((byte*)re + name_table_offset + i));
	}
}
示例#14
0
bool SignalMonitor::IsChannelTuned(void)
{
    if (is_tuned)
        return true;

    ChannelBase::Status status = channel->GetStatus();
    QMutexLocker locker(&statusLock);

    switch (status) {
      case ChannelBase::changePending:
        if (HasFlags(SignalMonitor::kDVBSigMon_WaitForPos))
        {
            // Still waiting on rotor
            m_channelTimer.start();
            channelTuned.SetValue(1);
        }
        else if (m_channelTimer.elapsed() > m_channelTimeout)
        {
            // channel change is taking too long
            VERBOSE(VB_IMPORTANT, "SignalMonitor: channel change timed-out");
            error = QObject::tr("Error: channel change failed");
            channelTuned.SetValue(2);
        }
        else
            channelTuned.SetValue(1);
        break;
      case ChannelBase::changeFailed:
        VERBOSE(VB_IMPORTANT, "SignalMonitor: channel change failed");
        channelTuned.SetValue(2);
        error = QObject::tr("Error: channel change failed");
        break;
      case ChannelBase::changeSuccess:
        channelTuned.SetValue(3);
        break;
    }

    EmitStatus();

    if (status == ChannelBase::changeSuccess)
    {
        if (tablemon)
            pParent->SetupDTVSignalMonitor(eit_scan);

        is_tuned = true;
        return true;
    }

    return false;
}
示例#15
0
void FirewireSignalMonitor::HandlePMT(uint pnum, const ProgramMapTable *pmt)
{
    LOG(VB_CHANNEL, LOG_INFO, LOC + "HandlePMT()");

    AddFlags(kDTVSigMon_PMTSeen);

    if (!HasFlags(kDTVSigMon_PATMatch))
    {
        GetStreamData()->SetVersionPMT(pnum, -1,0);
        LOG(VB_CHANNEL, LOG_INFO, LOC + "HandlePMT() ignoring PMT");
        return;
    }

    DTVSignalMonitor::HandlePMT(pnum, pmt);
}
示例#16
0
/** \fn SignalMonitor::GetStatusList(bool)
 *  \brief Returns QStringList containing all signals and their current
 *         values.
 *
 *   This serializes the signal monitoring values so that they can
 *   be passed from a backend to a frontend.
 *
 *   SignalMonitorValue::Parse(const QStringList&) will convert this
 *   to a vector of SignalMonitorValue instances.
 *
 *  \param kick if true Kick() will be employed so that this
 *         call will not have to wait for the next signal
 *         monitoring event.
 */
QStringList SignalMonitor::GetStatusList(bool kick)
{
    if (kick && running)
        Kick();
    else if (!running)
        UpdateValues();

    QStringList list;
    statusLock.lock();
    list<<channelTuned.GetName()<<channelTuned.GetStatus();
    list<<signalLock.GetName()<<signalLock.GetStatus();
    if (HasFlags(kSigMon_WaitForSig))
        list<<signalStrength.GetName()<<signalStrength.GetStatus();
    statusLock.unlock();

    return list;
}
示例#17
0
void FERealBall::Draw()
{
	D_Color bodyColor = m_Color;
	if(HasFlags(EFEFlag_Selected))
		bodyColor = bodyColor / 1.5f;

	Vec2 screenPos = CoordinateInfo::WorldToScreen(Vec2::FromVec3(m_vPos));
	g_poSROU->DrawFillCircle((f32)screenPos.x, (f32)screenPos.y, m_fBallRadius * CoordinateInfo::GetPixelPerMeter(), bodyColor, D_Color(0, 0, 0));

	Vec2 indicatorPos(m_vPos.x - m_fBallRadius, m_vPos.y + m_fBallRadius);
	Vec2 indicatorScreenPos = CoordinateInfo::WorldToScreen(indicatorPos);
	Char indicator[] = "B";
	g_poSROU->DrawStringEx(
		indicatorScreenPos.x, 
		indicatorScreenPos.y,
		2 * m_fBallRadius * CoordinateInfo::GetPixelPerMeter(), 
		2 * m_fBallRadius * CoordinateInfo::GetPixelPerMeter(),
		kPLAYER_NUMSIZE * CoordinateInfo::GetPixelPerMeter(),
		indicator, NULL, D_Color(0,0,0));
}
void FScriptExecutionNode::MapTunnelLinearExecution(FTracePath& Trace) const
{
	if (HasFlags(EScriptExecutionNodeFlags::TunnelInstance))
	{
		for (auto ChildIter : ChildNodes)
		{
			ChildIter->MapTunnelLinearExecution(Trace);
		}
	}
	else if (GetNumLinkedNodes() == 1)
	{
		for (auto NodeIter : LinkedNodes)
		{
			if (!NodeIter.Value->HasFlags(EScriptExecutionNodeFlags::InvalidTrace))
			{
				Trace.AddExitPin(NodeIter.Key);
			}
			NodeIter.Value->MapTunnelLinearExecution(Trace);
		}
	}
}
示例#19
0
/** \fn DVBSignalMonitor::UpdateValues()
 *  \brief Fills in frontend stats and emits status Qt signals.
 *
 *   This is automatically called by MonitorLoop(), after Start()
 *   has been used to start the signal monitoring thread.
 */
void DVBSignalMonitor::UpdateValues(void)
{
    if (!running || exit)
        return;

    if (streamHandlerStarted)
    {
        if (!streamHandler->IsRunning())
        {
            error = QObject::tr("Error: stream handler died");
            update_done = true;
            return;
        }

        EmitStatus();
        if (IsAllGood())
            SendMessageAllGood();

        // TODO dtv signals...

        update_done = true;
        return;
    }

    AddFlags(kSigMon_WaitForSig);

    DVBChannel *dvbchannel = GetDVBChannel();
    if (!dvbchannel)
        return;

    // Handle retuning after rotor has turned
    if (HasFlags(SignalMonitor::kDVBSigMon_WaitForPos))
    {
        if (dvbchannel->GetRotor())
        {
            if (!streamHandler->IsRetuneAllowed())
                streamHandler->SetRetuneAllowed(true, this, dvbchannel);
            streamHandler->RetuneMonitor();
        }
        else
            RemoveFlags(SignalMonitor::kDVBSigMon_WaitForPos);
    }

    bool wasLocked = false, isLocked = false;
    uint sig = 0, snr = 0, ber = 0, ublocks = 0;

    // Get info from card
    bool has_lock = dvbchannel->HasLock();
    if (HasFlags(kSigMon_WaitForSig))
        sig = (uint) (dvbchannel->GetSignalStrength() * 65535);
    if (HasFlags(kDVBSigMon_WaitForSNR))
        snr = (uint) (dvbchannel->GetSNR() * 65535);
    if (HasFlags(kDVBSigMon_WaitForBER))
        ber = (uint) dvbchannel->GetBitErrorRate();
    if (HasFlags(kDVBSigMon_WaitForUB))
        ublocks = (uint) dvbchannel->GetUncorrectedBlockCount();

    has_lock |= streamHandler->IsRunning();

    // Set SignalMonitorValues from info from card.
    {
        QMutexLocker locker(&statusLock);

        // BER and UB are actually uint32 values, but we
        // clamp them at 64K. This is because these values
        // are acutally cumulative, but we don't try to
        // normalize these to a time period.

        wasLocked = signalLock.IsGood();
        signalLock.SetValue((has_lock) ? 1 : 0);
        isLocked = signalLock.IsGood();

        if (HasFlags(kSigMon_WaitForSig))
            signalStrength.SetValue(sig);
        if (HasFlags(kDVBSigMon_WaitForSNR))
            signalToNoise.SetValue(snr);
        if (HasFlags(kDVBSigMon_WaitForBER))
            bitErrorRate.SetValue(ber);
        if (HasFlags(kDVBSigMon_WaitForUB))
            uncorrectedBlocks.SetValue(ublocks);
    }

    // Debug output
    if (wasLocked != isLocked)
    {
        VERBOSE(VB_CHANNEL, LOC + "UpdateValues -- Signal "
                <<(isLocked ? "Locked" : "Lost"));
    }

    EmitStatus();
    if (IsAllGood())
        SendMessageAllGood();

    // Start table monitoring if we are waiting on any table
    // and we have a lock.
    if (isLocked && GetStreamData() &&
        (!HasFlags(kDVBSigMon_WaitForPos) || rotorPosition.IsGood()) &&
        HasAnyFlag(kDTVSigMon_WaitForPAT | kDTVSigMon_WaitForPMT |
                   kDTVSigMon_WaitForMGT | kDTVSigMon_WaitForVCT |
                   kDTVSigMon_WaitForNIT | kDTVSigMon_WaitForSDT))
    {
        GetStreamData()->AddListeningPID(MPEG_PAT_PID);
        streamHandler->AddListener(GetStreamData(), true, false);
        streamHandlerStarted = true;
    }

    update_done = true;
}
示例#20
0
文件: kwm.cpp 项目: koekeishiya/kwm
internal CGEventRef
CGEventCallback(CGEventTapProxy Proxy, CGEventType Type, CGEventRef Event, void *Refcon)
{
    switch(Type)
    {
        case kCGEventTapDisabledByTimeout:
        case kCGEventTapDisabledByUserInput:
        {
            DEBUG("Notice: Restarting Event Tap");
            CGEventTapEnable(KWMMach.EventTap, true);
        } break;
        case kCGEventMouseMoved:
        {
            if(KWMSettings.Focus == FocusModeAutoraise)
                AXLibConstructEvent(AXEvent_MouseMoved, NULL, false);
        } break;
        case kCGEventLeftMouseDown:
        {
            if(HasFlags(&KWMSettings, Settings_MouseDrag))
            {
                if(MouseDragKeyMatchesCGEvent(Event))
                {
                    AXLibConstructEvent(AXEvent_LeftMouseDown, NULL, false);
                    return NULL;
                }
            }
        } break;
        case kCGEventLeftMouseUp:
        {
            if(HasFlags(&KWMSettings, Settings_MouseDrag))
                AXLibConstructEvent(AXEvent_LeftMouseUp, NULL, false);
        } break;
        case kCGEventLeftMouseDragged:
        {
            if(HasFlags(&KWMSettings, Settings_MouseDrag))
            {
                CGPoint *Cursor = (CGPoint *) malloc(sizeof(CGPoint));
                *Cursor = CGEventGetLocation(Event);
                AXLibConstructEvent(AXEvent_LeftMouseDragged, Cursor, false);
            }
        } break;
        case kCGEventRightMouseDown:
        {
            if(HasFlags(&KWMSettings, Settings_MouseDrag))
            {
                if(MouseDragKeyMatchesCGEvent(Event))
                {
                    AXLibConstructEvent(AXEvent_RightMouseDown, NULL, false);
                    return NULL;
                }
            }
        } break;
        case kCGEventRightMouseUp:
        {
            if(HasFlags(&KWMSettings, Settings_MouseDrag))
                AXLibConstructEvent(AXEvent_RightMouseUp, NULL, false);
        } break;
        case kCGEventRightMouseDragged:
        {
            if(HasFlags(&KWMSettings, Settings_MouseDrag))
            {
                CGPoint *Cursor = (CGPoint *) malloc(sizeof(CGPoint));
                *Cursor = CGEventGetLocation(Event);
                AXLibConstructEvent(AXEvent_RightMouseDragged, Cursor, false);
            }
        } break;

        default: {} break;
    }

    return Event;
}
示例#21
0
SNORTRULEHDR void CPcreOption::FromPattern(const CDllString &strPat)
{
	CDllString strTemp = strPat;
	FormatPattern(strTemp);

	if (HasFlags(CRuleOption::HASNOT))
	{
		return;
	}

	STRING str = strTemp.Data();

	STRING_ITER iBeg = str.begin(), iEnd = str.end();
	STRING strSuffix;
	if (*iBeg == '/')
	{
		++iBeg;
		for(--iEnd; *iEnd != '/' && iEnd != str.begin(); --iEnd);
		if (iBeg >= iEnd)
		{
			TTHROW(TI_INVALIDDATA);
		}
		strSuffix = STRING(iEnd + 1, str.end());
	}

	m_strPcre.Assign(STRING(iBeg, iEnd).c_str());
	
	for(STRING_ITER j = strSuffix.begin(); j != strSuffix.end(); ++j)
	{
		switch (*j)
		{
		case 'A':
			AddFlags(PF_A);
			if (m_strPcre[0] != '^')
			{
				m_strPcre.Insert(0, '^');
			}
			continue;
		case 'R':
			AddFlags(PF_R);
			continue;
		case 'i':
			AddFlags(PF_i);
			continue;
		case 's':
			AddFlags(PF_s);
			continue;
		case 'm':
			AddFlags(PF_m);
			continue;
		case 'x':
			AddFlags(PF_x);
			continue;
		case 'E':
			AddFlags(PF_E);
			continue;
		case 'G':
			AddFlags(PF_G);
			continue;
		case 'U':
			AddFlags(PF_U);
			continue;
		case 'B':
			AddFlags(PF_B);
			continue;
		case 'P':
			AddFlags(PF_P);
			continue;
		case 'H':
			AddFlags(PF_H);
			continue;
		case 'M':
			AddFlags(PF_M);
			continue;
		case 'C':
			AddFlags(PF_C);
			continue;
		case 'O':
			AddFlags(PF_O);
			continue;
		case 'I':
			AddFlags(PF_I);
			continue;
		case 'D':
			AddFlags(PF_D);
			continue;
		case 'K':
			AddFlags(PF_K);
			continue;
		case 'S':
			AddFlags(PF_S);
			continue;
		case 'Y':
			AddFlags(PF_Y);
			continue;			
		default:
			TTHROW(TI_INVALIDDATA);
		}
	}
	if (m_strPcre[0] == '^')
	{
		AddFlags(PF_A);
	}
}
示例#22
0
文件: node.cpp 项目: koekeishiya/kwm
void CreateLeafNodePair(ax_display *Display, tree_node *Parent, uint32_t FirstWindowID, uint32_t SecondWindowID, split_type SplitMode)
{
    Parent->WindowID = 0;
    Parent->SplitMode = SplitMode;
    Parent->SplitRatio = KWMSettings.SplitRatio;

    node_type ParentType = Parent->Type;
    link_node *ParentList = Parent->List;
    Parent->Type = NodeTypeTree;
    Parent->List = NULL;

    uint32_t LeftWindowID;
    uint32_t RightWindowID;

    if(HasFlags(&KWMSettings, Settings_SpawnAsLeftChild))
    {
        LeftWindowID = SecondWindowID;
        RightWindowID = FirstWindowID;
    }
    else
    {
        LeftWindowID = FirstWindowID;
        RightWindowID = SecondWindowID;
    }

    if(SplitMode == SPLIT_VERTICAL)
    {
        Parent->LeftChild = CreateLeafNode(Display, Parent, LeftWindowID, CONTAINER_LEFT);
        Parent->RightChild = CreateLeafNode(Display, Parent, RightWindowID, CONTAINER_RIGHT);

        tree_node *Node;
        if(HasFlags(&KWMSettings, Settings_SpawnAsLeftChild))
            Node = Parent->RightChild;
        else
            Node = Parent->LeftChild;

        Node->Type = ParentType;
        Node->List = ParentList;
        ResizeLinkNodeContainers(Node);
    }
    else if(SplitMode == SPLIT_HORIZONTAL)
    {
        Parent->LeftChild = CreateLeafNode(Display, Parent, LeftWindowID, CONTAINER_UPPER);
        Parent->RightChild = CreateLeafNode(Display, Parent, RightWindowID, CONTAINER_LOWER);

        tree_node *Node;
        if(HasFlags(&KWMSettings, Settings_SpawnAsLeftChild))
            Node = Parent->RightChild;
        else
            Node = Parent->LeftChild;

        Node->Type = ParentType;
        Node->List = ParentList;
        ResizeLinkNodeContainers(Node);
    }
    else
    {
        Parent->Parent = NULL;
        Parent->LeftChild = NULL;
        Parent->RightChild = NULL;
        Parent = NULL;
    }
}
示例#23
0
/** \fn FirewireSignalMonitor::UpdateValues(void)
 *  \brief Fills in frontend stats and emits status Qt signals.
 *
 *   This function uses five ioctl's FE_READ_SNR, FE_READ_SIGNAL_STRENGTH
 *   FE_READ_BER, FE_READ_UNCORRECTED_BLOCKS, and FE_READ_STATUS to obtain
 *   statistics from the frontend.
 *
 *   This is automatically called by MonitorLoop(), after Start()
 *   has been used to start the signal monitoring thread.
 */
void FirewireSignalMonitor::UpdateValues(void)
{
    if (!running || exit)
        return;

    if (dtvMonitorRunning)
    {
        EmitStatus();
        if (IsAllGood())
            SendMessageAllGood();
        // TODO dtv signals...

        update_done = true;
        return;
    }

    if (stb_needs_to_wait_for_power &&
        (stb_wait_for_power_timer.elapsed() < (int)kPowerTimeout))
    {
        return;
    }
    stb_needs_to_wait_for_power = false;

    FirewireChannel *fwchan = dynamic_cast<FirewireChannel*>(channel);
    if (!fwchan)
        return;

    if (HasFlags(kFWSigMon_WaitForPower) && !HasFlags(kFWSigMon_PowerMatch))
    {
        bool retried = false;
        while (true)
        {
            FirewireDevice::PowerState power = fwchan->GetPowerState();
            if (FirewireDevice::kAVCPowerOn == power)
            {
                AddFlags(kFWSigMon_PowerSeen | kFWSigMon_PowerMatch);
            }
            else if (FirewireDevice::kAVCPowerOff == power)
            {
                AddFlags(kFWSigMon_PowerSeen);
                fwchan->SetPowerState(true);
                stb_wait_for_power_timer.start();
                stb_needs_to_wait_for_power = true;
            }
            else
            {
                bool qfailed = (FirewireDevice::kAVCPowerQueryFailed == power);
                if (qfailed && !retried)
                {
                    retried = true;
                    continue;
                }

                LOG(VB_RECORD, LOG_WARNING,
                    "Can't determine if STB is power on, assuming it is...");
                AddFlags(kFWSigMon_PowerSeen | kFWSigMon_PowerMatch);
            }
            break;
        }
    }

    bool isLocked = !HasFlags(kFWSigMon_WaitForPower) ||
        HasFlags(kFWSigMon_WaitForPower | kFWSigMon_PowerMatch);

    if (isLocked && stb_needs_retune)
    {
        fwchan->Retune();
        isLocked = stb_needs_retune = false;
    }

    SignalMonitor::UpdateValues();

    {
        QMutexLocker locker(&statusLock);
        if (!scriptStatus.IsGood())
            return;
    }

    // Set SignalMonitorValues from info from card.
    {
        QMutexLocker locker(&statusLock);
        signalStrength.SetValue(isLocked ? 100 : 0);
        signalLock.SetValue(isLocked ? 1 : 0);
    }

    EmitStatus();
    if (IsAllGood())
        SendMessageAllGood();

    // Start table monitoring if we are waiting on any table
    // and we have a lock.
    if (isLocked && GetStreamData() &&
        HasAnyFlag(kDTVSigMon_WaitForPAT | kDTVSigMon_WaitForPMT |
                   kDTVSigMon_WaitForMGT | kDTVSigMon_WaitForVCT |
                   kDTVSigMon_WaitForNIT | kDTVSigMon_WaitForSDT))
    {
        tableMonitorThread = new FirewireTableMonitorThread(this);

        LOG(VB_CHANNEL, LOG_INFO, LOC + "UpdateValues() -- "
                "Waiting for table monitor to start");

        while (!dtvMonitorRunning)
            usleep(5000);

        LOG(VB_CHANNEL, LOG_INFO, LOC + "UpdateValues() -- "
                "Table monitor started");
    }

    update_done = true;
}
// If you change DataDocumentContentPolicy, make sure to check that
// CHECK_PRINCIPAL_AND_DATA in nsContentPolicyUtils is still valid.
// nsContentPolicyUtils may not pass all the parameters to ShouldLoad.
NS_IMETHODIMP
nsDataDocumentContentPolicy::ShouldLoad(uint32_t aContentType,
                                        nsIURI *aContentLocation,
                                        nsIURI *aRequestingLocation,
                                        nsISupports *aRequestingContext,
                                        const nsACString &aMimeGuess,
                                        nsISupports *aExtra,
                                        nsIPrincipal *aRequestPrincipal,
                                        int16_t *aDecision)
{
  MOZ_ASSERT(aContentType == nsContentUtils::InternalContentPolicyTypeToExternal(aContentType),
             "We should only see external content policy types here.");

  *aDecision = nsIContentPolicy::ACCEPT;
  // Look for the document.  In most cases, aRequestingContext is a node.
  nsCOMPtr<nsIDocument> doc;
  nsCOMPtr<nsINode> node = do_QueryInterface(aRequestingContext);
  if (node) {
    doc = node->OwnerDoc();
  } else {
    nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aRequestingContext);
    if (window) {
      doc = window->GetDoc();
    }
  }

  // DTDs are always OK to load
  if (!doc || aContentType == nsIContentPolicy::TYPE_DTD) {
    return NS_OK;
  }

  // Nothing else is OK to load for data documents
  if (doc->IsLoadedAsData()) {
    // ...but let static (print/print preview) documents to load fonts.
    if (!doc->IsStaticDocument() || aContentType != nsIContentPolicy::TYPE_FONT) {
      *aDecision = nsIContentPolicy::REJECT_TYPE;
      return NS_OK;
    }
  }

  if (doc->IsBeingUsedAsImage()) {
    // We only allow SVG images to load content from URIs that are local and
    // also satisfy one of the following conditions:
    //  - URI inherits security context, e.g. data URIs
    //   OR
    //  - URI loadable by subsumers, e.g. blob URIs
    // Any URI that doesn't meet these requirements will be rejected below.
    if (!(HasFlags(aContentLocation,
                   nsIProtocolHandler::URI_IS_LOCAL_RESOURCE) &&
          (HasFlags(aContentLocation,
                    nsIProtocolHandler::URI_INHERITS_SECURITY_CONTEXT) ||
           HasFlags(aContentLocation,
                    nsIProtocolHandler::URI_LOADABLE_BY_SUBSUMERS)))) {
      *aDecision = nsIContentPolicy::REJECT_TYPE;

      // Report error, if we can.
      if (node) {
        nsIPrincipal* requestingPrincipal = node->NodePrincipal();
        nsRefPtr<nsIURI> principalURI;
        nsresult rv =
          requestingPrincipal->GetURI(getter_AddRefs(principalURI));
        if (NS_SUCCEEDED(rv) && principalURI) {
          nsScriptSecurityManager::ReportError(
            nullptr, NS_LITERAL_STRING("ExternalDataError"), principalURI,
            aContentLocation);
        }
      }
    } else if ((aContentType == nsIContentPolicy::TYPE_IMAGE ||
                aContentType == nsIContentPolicy::TYPE_IMAGESET) &&
               doc->GetDocumentURI()) {
      // Check for (& disallow) recursive image-loads
      bool isRecursiveLoad;
      nsresult rv = aContentLocation->EqualsExceptRef(doc->GetDocumentURI(),
                                                      &isRecursiveLoad);
      if (NS_FAILED(rv) || isRecursiveLoad) {
        NS_WARNING("Refusing to recursively load image");
        *aDecision = nsIContentPolicy::REJECT_TYPE;
      }
    }
    return NS_OK;
  }

  // Allow all loads for non-resource documents
  if (!doc->IsResourceDoc()) {
    return NS_OK;
  }

  // For resource documents, blacklist some load types
  if (aContentType == nsIContentPolicy::TYPE_OBJECT ||
      aContentType == nsIContentPolicy::TYPE_DOCUMENT ||
      aContentType == nsIContentPolicy::TYPE_SUBDOCUMENT ||
      aContentType == nsIContentPolicy::TYPE_SCRIPT ||
      aContentType == nsIContentPolicy::TYPE_XSLT ||
      aContentType == nsIContentPolicy::TYPE_FETCH ||
      aContentType == nsIContentPolicy::TYPE_WEB_MANIFEST) {
    *aDecision = nsIContentPolicy::REJECT_TYPE;
  }

  // If you add more restrictions here, make sure to check that
  // CHECK_PRINCIPAL_AND_DATA in nsContentPolicyUtils is still valid.
  // nsContentPolicyUtils may not pass all the parameters to ShouldLoad

  return NS_OK;
}
示例#25
0
void FESimulatedBall::Move(const Vec2& pos)
{
	if(!HasFlags(EFEFlag_Movable))
		return;
	m_RfPosition = ClampToPitch(pos);
}