当前位置: 首页>>代码示例>>C++>>正文


C++ Guard函数代码示例

本文整理汇总了C++中Guard函数的典型用法代码示例。如果您正苦于以下问题:C++ Guard函数的具体用法?C++ Guard怎么用?C++ Guard使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Guard函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Guard

void SGameplayTagWidget::CreateNewGameplayTag()
{
	// Only support adding tags via ini file
	if (UGameplayTagsManager::ShouldImportTagsFromINI() == false)
	{
		return;
	}

	FString str = NewTagTextBox->GetText().ToString();
	if (str.IsEmpty())
	{
		return;
	}

	// set bIsAddingNewTag, this guards against the window closing when it loses focus due to source control checking out a file
	TGuardValue<bool>	Guard(bIsAddingNewTag, true);

	UGameplayTagsManager::AddNewGameplayTagToINI(str);

	NewTagTextBox->SetText(FText::GetEmpty());

	IGameplayTagsModule::Get().GetGameplayTagsManager().GetFilteredGameplayRootTags(RootFilterString, TagItems);
	TagTreeWidget->RequestTreeRefresh();

	auto node = IGameplayTagsModule::Get().GetGameplayTagsManager().FindTagNode(FName(*str));
	if (node.IsValid())
	{
		OnTagChecked(node);
	}

	// Filter on the new tag
	SearchTagBox->SetText(FText::FromString(str));
}
开发者ID:frobro98,项目名称:UnrealSource,代码行数:33,代码来源:SGameplayTagWidget.cpp

示例2: Guard

void CMainGui::ChangeWinSize (long width, long height) 
{
	CGuard Guard(m_CS);
	WINDOWPLACEMENT wndpl;
    RECT rc1, swrect;

	wndpl.length = sizeof(wndpl);
	GetWindowPlacement( m_hMainWindow, &wndpl);

	if ( (HWND)m_hStatusWnd != NULL ) 
    {
		GetClientRect( (HWND)m_hStatusWnd, &swrect );
	    SetRect( &rc1, 0, 0, width, height + swrect.bottom );
	} 
    else 
    {
	    SetRect( &rc1, 0, 0, width, height );
	}


    AdjustWindowRectEx( &rc1,GetWindowLong( m_hMainWindow, GWL_STYLE ),
		GetMenu( m_hMainWindow ) != NULL, GetWindowLong( m_hMainWindow, GWL_EXSTYLE ) ); 

    MoveWindow( m_hMainWindow, wndpl.rcNormalPosition.left, wndpl.rcNormalPosition.top, 
		rc1.right - rc1.left, rc1.bottom - rc1.top, TRUE );
}
开发者ID:BenjaminSiskoo,项目名称:project64,代码行数:26,代码来源:Gui+Class.cpp

示例3: Guard

UnicodeString TConfiguration::GetFileFileInfoString(const UnicodeString & AKey,
  const UnicodeString & AFileName, bool AllowEmpty) const
{
  TGuard Guard(FCriticalSection);

  UnicodeString Result;
  void * Info = GetFileApplicationInfo(AFileName);
  SCOPE_EXIT
  {
    if (!AFileName.IsEmpty() && Info)
    {
      FreeFileInfo(Info);
    }
  };
  if ((Info != nullptr) && (GetTranslationCount(Info) > 0))
  {
    TTranslation Translation = GetTranslation(Info, 0);
    try
    {
      Result = ::GetFileInfoString(Info, Translation, AKey, AllowEmpty);
    }
    catch (const std::exception & e)
    {
      (void)e;
      DEBUG_PRINTF("Error: %s", ::MB2W(e.what()).c_str());
      Result.Clear();
    }
  }
  else
  {
    assert(!AFileName.IsEmpty());
  }
  return Result;
}
开发者ID:kocicjelena,项目名称:Far-NetBox,代码行数:34,代码来源:Configuration.cpp

示例4: Guard

ULONG  CIniFileBase::GetString  ( LPCTSTR lpSectionName, LPCTSTR lpKeyName, LPCTSTR lpDefault, LPTSTR lpReturnedString, ULONG nSize )
{
	CGuard Guard(m_CS);

	std::string strSection;

	if (lpSectionName == NULL || _tcslen(lpSectionName) == 0)
	{
		strSection = "default";
	}
	else
	{
		strSection = lpSectionName;
	}

	if (m_File.IsOpen() && MoveToSectionNameData(strSection.c_str(),true)) 
	{
		KeyValueList::iterator iter = m_CurrentSectionData.find(lpKeyName);
		if (iter != m_CurrentSectionData.end())
		{
			_tcsncpy(lpReturnedString,iter->second.c_str(),nSize - 1);
			lpReturnedString[nSize - 1] = 0;
			return (ULONG)_tcslen(lpReturnedString);
		}
	}
	_tcsncpy(lpReturnedString,lpDefault,nSize - 1);
	lpReturnedString[nSize - 1] = 0;
	return (ULONG)_tcslen(lpReturnedString);
}
开发者ID:BenjaminSiskoo,项目名称:project64,代码行数:29,代码来源:Ini+File+Class.cpp

示例5: Guard

IDF_ERRORCODE iDFPluginMgr::run_all_plugins()
{
    idf::LockGuard<idf::MutexLock> Guard(this->lock);
    
    std::vector<iDFPluginWrapper*>::iterator begin=this->plugins.begin();
    std::vector<iDFPluginWrapper*>::iterator end = this->plugins.end();
    
    for(; begin!=end; begin++)
    {
        iDFPluginWrapper * plugin = *begin;
        if(!plugin->is_valid() || plugin->is_run())
        {
            printf("skip the plugin, %d", plugin->get_plugin_id());
            continue;
        }
        
        IDF_ERRORCODE error_code = plugin->init() || plugin->start();
        if(IDF_IS_ERROR(error_code))
        {
            printf("plugin failed to start it~, skip it~, error code is %lld", error_code);
            continue;
        }
    }
    
    return IDF_SUCCESS;
}
开发者ID:dongAxis,项目名称:iDefense,代码行数:26,代码来源:iDFPluginMgr.cpp

示例6: Guard

//---------------------------------------------------------------------------
UnicodeString TConfiguration::GetFileInfoString(const UnicodeString & Key,
  const UnicodeString & FileName) const
{
  TGuard Guard(FCriticalSection);

  UnicodeString Result;
  void * Info = GetFileApplicationInfo(FileName);
  SCOPE_EXIT
  {
    if (!FileName.IsEmpty() && Info)
    {
      FreeFileInfo(Info);
    }
  };
  {
    if ((Info != nullptr) && (GetTranslationCount(Info) > 0))
    {
      TTranslation Translation = GetTranslation(Info, 0);
      try
      {
        Result = ::GetFileInfoString(Info, Translation, Key);
      }
      catch (const std::exception & e)
      {
        (void)e;
        DEBUG_PRINTF(L"Error: %s", MB2W(e.what()).c_str());
        Result = L"";
      }
    }
  }
  return Result;
}
开发者ID:CyberShadow,项目名称:Far-NetBox,代码行数:33,代码来源:Configuration.cpp

示例7: NOW

RafLinkedList* AccountMgr::GetRAFAccounts(uint32 accid, bool referred)
{

    RafLinkedMap::iterator itr = mRAFLinkedMap.find(std::pair<uint32,bool>(accid, referred));
    if (itr == mRAFLinkedMap.end())
    {
        QueryResult* result;

        if (referred)
            result = LoginDatabase.PQuery("SELECT `friend_id` FROM `account_friends` WHERE `id` = %u AND `expire_date` > NOW() LIMIT %u", accid, sWorld.getConfig(CONFIG_UINT32_RAF_MAXREFERERS));
        else
            result = LoginDatabase.PQuery("SELECT `id` FROM `account_friends` WHERE `friend_id` = %u AND `expire_date` > NOW() LIMIT %u", accid, sWorld.getConfig(CONFIG_UINT32_RAF_MAXREFERALS));

        RafLinkedList acclist;

        if (result)
        {
            do
            {
                Field* fields = result->Fetch();
                uint32 refaccid = fields[0].GetUInt32();
                acclist.push_back(refaccid);
            }
            while (result->NextRow());
            delete result;
        }
        ReadGuard Guard(GetLock());
        mRAFLinkedMap.insert(RafLinkedMap::value_type(std::pair<uint32,bool>(accid, referred), acclist));
        itr = mRAFLinkedMap.find(std::pair<uint32,bool>(accid, referred));
    }

    return &itr->second;
}
开发者ID:AnthoDevMoP,项目名称:mangos4,代码行数:33,代码来源:AccountMgr.cpp

示例8: GetPlayerDataCache

void AccountMgr::ClearPlayerDataCache(ObjectGuid guid)
{
    if (!guid || !guid.IsPlayer())
        return;

    PlayerDataCache const* cache = GetPlayerDataCache(guid, false);

    if (cache)
    {
        uint32 accId = cache->account;

        WriteGuard Guard(GetLock());
        PlayerDataCacheMap::iterator itr = mPlayerDataCacheMap.find(guid);
        if (itr != mPlayerDataCacheMap.end())
            mPlayerDataCacheMap.erase(itr);

        RafLinkedMap::iterator itr1 = mRAFLinkedMap.find(std::pair<uint32,bool>(accId, true));
        if (itr1 != mRAFLinkedMap.end())
            mRAFLinkedMap.erase(itr1);
        itr1 = mRAFLinkedMap.find(std::pair<uint32,bool>(accId, false));
        if (itr1 != mRAFLinkedMap.end())
            mRAFLinkedMap.erase(itr1);
    }

}
开发者ID:AnthoDevMoP,项目名称:mangos4,代码行数:25,代码来源:AccountMgr.cpp

示例9: Guard

void CTraceLog::WriteTrace ( TraceType Type, LPCTSTR Message)
{
	CGuard Guard(m_CS);

	if (Type != TraceNone)
	{
		bool WriteToLog = false;
		for (int i = 0; i < (int)m_Modules.size(); i++ )
		{
			if ((m_Modules[i]->GetTraceLevel() & Type) != 0) 
			{
				WriteToLog = true;
				break;
			}
		}
		if (!WriteToLog) { return; }
	}

	if ((Type & TraceNoHeader) == 0)
	{
		TCHAR pBuffer[300];
		int nPos = 0;

		SYSTEMTIME sysTime;
		::GetLocalTime(&sysTime);

		nPos = _stprintf( pBuffer, _T("%04d/%02d/%02d %02d:%02d:%02d.%03d %05d: "), sysTime.wYear,
			sysTime.wMonth,sysTime.wDay,sysTime.wHour,sysTime.wMinute,sysTime.wSecond,sysTime.wMilliseconds,
			::GetCurrentThreadId()
		);

		// show the debug level
		if (Type == TraceNone) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("None   : ")); }
		else if ((Type & TraceError)     != 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Error  : ")); }
		else if ((Type & TraceSettings)  != 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Setting: ")); }
		else if ((Type & TraceGfxPlugin) != 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Gfx    : ")); }
		else if ((Type & TraceDebug)     != 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Debug  : ")); }
		else if ((Type & TraceRecompiler)!= 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Recomp : ")); }
		else if ((Type & TraceRSP       )!= 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("RSP    : ")); }
		else if ((Type & TraceTLB       )!= 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("TLB    : ")); }
		else if ((Type & TraceValidate  )!= 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Valid  : ")); }
		else if ((Type & TraceAudio     )!= 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Audio  : ")); }
		else { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Unknown: ")); }

		for (int i = 0; i < (int)m_Modules.size(); i++ )
		{
			if ((m_Modules[i]->GetTraceLevel() & Type) != 0) 
			{
				m_Modules[i]->Write(pBuffer, false);
			}
		}
	}
	for (int i = 0; i < (int)m_Modules.size(); i++ )
	{
		if ((m_Modules[i]->GetTraceLevel() & Type) != 0) 
		{
			m_Modules[i]->Write(Message, true);
		}
	}
}
开发者ID:BenjaminSiskoo,项目名称:project64,代码行数:60,代码来源:Trace.cpp

示例10: header

bool WorldSocket::SendPacket(const WorldPacket& pct)
{
    if (IsClosed())
        return false;

    // Dump outgoing packet.
    sLog.outWorldPacketDump(native_handle(), pct.GetOpcode(), pct.GetOpcodeName(), &pct, false);

    ServerPktHeader header(pct.size() + 2, pct.GetOpcode());
    crypt_.EncryptSend((uint8*) header.header, header.getHeaderLength());

    GuardType Guard(out_buffer_lock_);

    if (out_buffer_->space() >= pct.size() + header.getHeaderLength())
    {
        // Put the packet on the buffer.
        if (!out_buffer_->Write(header.header, header.getHeaderLength()))
            MANGOS_ASSERT(false);

        if (!pct.empty() && !out_buffer_->Write(pct.contents(), pct.size()))
            MANGOS_ASSERT(false);
    }
    else
    {
        // Enqueue the packet.
        throw std::exception("network write buffer is too small to accommodate packet");
    }

    StartAsyncSend();

    return true;
}
开发者ID:Havoc,项目名称:mangos-boost,代码行数:32,代码来源:WorldSocket.cpp

示例11: AppendExceptionStackTraceAndForget

//---------------------------------------------------------------------------
bool __fastcall AppendExceptionStackTraceAndForget(TStrings *& MoreMessages)
{
  bool Result = false;

  TGuard Guard(StackTraceCriticalSection.get());

  TStackTraceMap::iterator Iterator = StackTraceMap.find(GetCurrentThreadId());
  if (Iterator != StackTraceMap.end())
  {
    std::unique_ptr<TStrings> OwnedMoreMessages;
    if (MoreMessages == NULL)
    {
      OwnedMoreMessages.reset(new TStringList());
      MoreMessages = OwnedMoreMessages.get();
      Result = true;
    }
    if (!MoreMessages->Text.IsEmpty())
    {
      MoreMessages->Text = MoreMessages->Text + "\n";
    }
    MoreMessages->Text = MoreMessages->Text + LoadStr(STACK_TRACE) + "\n";
    MoreMessages->AddStrings(Iterator->second);

    delete Iterator->second;
    StackTraceMap.erase(Iterator);

    OwnedMoreMessages.release();
  }
  return Result;
}
开发者ID:mpmartin8080,项目名称:winscp,代码行数:31,代码来源:WinInterface.cpp

示例12: DEBUG_FILTER_LOG

// call this method only
void TerrainInfo::CleanUpGrids(uint32 const diff)
{
    for (int y = 0; y < MAX_NUMBER_OF_GRIDS; ++y)
    {
        for (int x = 0; x < MAX_NUMBER_OF_GRIDS; ++x)
        {
            // delete those GridMap objects which have refcount == 0
            if (m_GridMaps[x][y] && m_GridMaps[x][y].count() == 0)
            {
                DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING,"TerrainInfo::CleanUpGrids unload grid map:%u x:%d y:%d", GetMapId(), x, y);
                WriteGuard Guard(GetLock(), true);

                GridMapPtr tmpPtr = m_GridMaps[x][y];
                m_GridMaps[x][y] = GridMapPtr();

                // unload VMAPS...
                VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(m_mapId, x, y);

                // unload mmap...
                MMAP::MMapFactory::createOrGetMMapManager()->unloadMap(m_mapId, x, y);

                // tmpPtr be auto-erased after cycle end
            }
        }
    }
}
开发者ID:Jojo2323,项目名称:mangos3,代码行数:27,代码来源:GridMap.cpp

示例13: getEndPosition

bool PathFinder::calculate(float destX, float destY, float destZ, bool forceDest)
{
    Vector3 oldDest = getEndPosition();
    Vector3 dest(destX, destY, destZ);
    setEndPosition(dest);

    float x, y, z;
    m_sourceUnit->GetPosition(x, y, z);
    Vector3 start(x, y, z);
    setStartPosition(start);

    m_forceDestination = forceDest;

    DEBUG_FILTER_LOG(LOG_FILTER_PATHFINDING, "++ PathFinder::calculate() for %u \n", m_sourceUnit->GetGUIDLow());

    // make sure navMesh works - we can run on map w/o mmap
    // check if the start and end point have a .mmtile loaded (can we pass via not loaded tile on the way?)
    if (!m_navMesh || !m_navMeshQuery || m_sourceUnit->hasUnitState(UNIT_STAT_IGNORE_PATHFINDING) ||
        !HaveTile(start) || !HaveTile(dest) || (m_sourceUnit->GetTypeId() == TYPEID_UNIT && ((Creature*)m_sourceUnit)->IsLevitating()))
    {
        BuildShortcut();
        m_type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH);
        return true;
    }

    updateFilter();

    {
        ReadGuard Guard(MMAP::MMapFactory::createOrGetMMapManager()->GetLock(m_sourceUnit->GetMapId()));
        BuildPolyPath(start, dest);
    }
    return true;
}
开发者ID:BACKUPLIB,项目名称:Infinity_MaNGOS,代码行数:33,代码来源:PathFinder.cpp

示例14: DebugAssert

void TSessionLog::Add(TLogLineType Type, UnicodeString ALine)
{
  DebugAssert(FConfiguration);
  if (GetLogging())
  {
    try
    {
      if (FParent != nullptr)
      {
        DoAdd(Type, ALine, nb::bind(&TSessionLog::DoAddToParent, this));
      }
      else
      {
        TGuard Guard(FCriticalSection);

        DoAdd(Type, ALine, nb::bind(&TSessionLog::DoAddToSelf, this));
      }
    }
    catch (Exception &E)
    {
      // We failed logging, turn it off and notify user.
      FConfiguration->SetLogging(false);
      try
      {
        throw ExtException(&E, LoadStr(LOG_GEN_ERROR));
      }
      catch (Exception &E2)
      {
        AddException(&E2);
        FUI->HandleExtendedException(&E2);
      }
    }
  }
}
开发者ID:michaellukashov,项目名称:Far-NetBox,代码行数:34,代码来源:SessionInfo.cpp

示例15: ABILITY_LOG

void FAggregator::BroadcastOnDirty()
{
	// If we are batching on Dirty calls (and we actually have dependents registered with us) then early out.
	if (FScopedAggregatorOnDirtyBatch::GlobalBatchCount > 0 && (Dependents.Num() > 0 || OnDirty.IsBound()))
	{
		FScopedAggregatorOnDirtyBatch::DirtyAggregators.Add(this);
		return;
	}

	if (IsBroadcastingDirty)
	{
		// Apologies for the vague warning but its very hard from this spot to call out what data has caused this. If this frequently happens we should improve this.
		ABILITY_LOG(Warning, TEXT("FAggregator detected cyclic attribute dependencies. We are skipping a recursive dirty call. Its possible the resulting attribute values are not what you expect!"));
		return;
	}

	TGuardValue<bool>	Guard(IsBroadcastingDirty, true);
	
	OnDirty.Broadcast(this);


	TArray<FActiveGameplayEffectHandle>	ValidDependents;
	for (FActiveGameplayEffectHandle Handle : Dependents)
	{
		UAbilitySystemComponent* ASC = Handle.GetOwningAbilitySystemComponent();
		if (ASC)
		{
			ASC->OnMagnitudeDependencyChange(Handle, this);
			ValidDependents.Add(Handle);
		}
	}
	Dependents = ValidDependents;

}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:34,代码来源:GameplayEffectAggregator.cpp


注:本文中的Guard函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。