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


C++ CSmartPtr类代码示例

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


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

示例1: processPeerExitUnreach

void COfConnectMgr::processPeerExitUnreach(CSmartPtr<CSwitch>& sw, INT4 reason)
{
    if (sw.isNotNull() && (sw->getState() == SW_STATE_UNREACHABLE))
    {
        //交换机状态恢复为STABLE
        sw->setState(SW_STATE_STABLE);

        //上报交换机事件EXIT_UNREACH
        CSwitchEventReportor::getInstance()->report(sw, EVENT_TYPE_SWITCH_EXIT_UNREACH, reason);

        //停止掉电检�?
        stopPowerOffCheck(sw);
    }
}
开发者ID:China863SDN,项目名称:DCFabric,代码行数:14,代码来源:COfConnectMgr.cpp

示例2: RefusedLogin

void CWebAuth::RefusedLogin(const CString& sReason) {
	if (m_pWebSock) {
		CSmartPtr<CWebSession> spSession = m_pWebSock->GetSession();

		spSession->AddError("Invalid login!");
		spSession->SetUser(NULL);

		m_pWebSock->SetLoggedIn(false);
		m_pWebSock->UnPauseRead();
		m_pWebSock->Redirect("/?cookie_check=true");

		DEBUG("UNSUCCESSFUL login attempt ==> REASON [" + sReason + "] ==> SESSION [" + spSession->GetId() + "]");
	}
}
开发者ID:DrRenX,项目名称:znc,代码行数:14,代码来源:WebModules.cpp

示例3: MuzzleFlash_Chopper

//-----------------------------------------------------------------------------
// Chopper muzzle flashes
//-----------------------------------------------------------------------------
void MuzzleFlash_Chopper( ClientEntityHandle_t hEntity, int attachmentIndex )
{
	VPROF_BUDGET( "MuzzleFlash_Chopper", VPROF_BUDGETGROUP_PARTICLE_RENDERING );

	matrix3x4_t	matAttachment;
	// If the client hasn't seen this entity yet, bail.
	if ( !FX_GetAttachmentTransform( hEntity, attachmentIndex, matAttachment ) )
		return;
	
	CSmartPtr<CLocalSpaceEmitter> pSimple = CLocalSpaceEmitter::Create( "MuzzleFlash", hEntity, attachmentIndex );

	SimpleParticle *pParticle;
	Vector			forward(1,0,0), offset; //NOTENOTE: All coords are in local space

	float flScale = random->RandomFloat( 2.5f, 4.5f );

	// Flash
	for ( int i = 1; i < 7; i++ )
	{
		offset = (forward * (i*2.0f*flScale));

		pParticle = (SimpleParticle *) pSimple->AddParticle( sizeof( SimpleParticle ), pSimple->GetPMaterial( VarArgs( "effects/combinemuzzle%d", random->RandomInt(1,2) ) ), offset );
			
		if ( pParticle == NULL )
			return;

		pParticle->m_flLifetime		= 0.0f;
		pParticle->m_flDieTime		= random->RandomFloat( 0.05f, 0.1f );

		pParticle->m_vecVelocity.Init();

		pParticle->m_uchColor[0]	= 255;
		pParticle->m_uchColor[1]	= 255;
		pParticle->m_uchColor[2]	= 255;

		pParticle->m_uchStartAlpha	= 255;
		pParticle->m_uchEndAlpha	= 128;

		pParticle->m_uchStartSize	= ( (random->RandomFloat( 6.0f, 8.0f ) * (10-(i))/7) * flScale );
		pParticle->m_uchEndSize		= pParticle->m_uchStartSize;
		pParticle->m_flRoll			= random->RandomInt( 0, 360 );
		pParticle->m_flRollDelta	= 0.0f;
	}
	
	// Grab the origin out of the transform for the attachment
	Vector		origin;
	MatrixGetColumn( matAttachment, 3, &origin );	
	CreateMuzzleflashELight( origin, 6, 128, 256, hEntity );
}
开发者ID:Yosam02,项目名称:game,代码行数:52,代码来源:fx_hl2_tracers.cpp

示例4: processPeerPowerOff

void COfConnectMgr::processPeerPowerOff(CSmartPtr<CSwitch>& sw)
{
    if (sw.isNotNull() && (sw->getState() < SW_STATE_POWER_OFF))
    {
        sw->setState(SW_STATE_POWER_OFF);
        
        //上报交换机事件POWER_OFF
        CSwitchEventReportor::getInstance()->report(sw, EVENT_TYPE_SWITCH_POWER_OFF, EVENT_REASON_SWITCH_POWER_OFF);
        
        //停止掉电检�?
        stopPowerOffCheck(sw);

        processPeerQuit(sw, EVENT_REASON_SWITCH_POWER_OFF);
    }
}
开发者ID:China863SDN,项目名称:DCFabric,代码行数:15,代码来源:COfConnectMgr.cpp

示例5: deleteCmsg

static void deleteCmsg(CMsgCommon* msg)
{
    if (NULL != msg)
    {
        CMsg* ofmsg = (CMsg*)msg;
        INT4 sockfd = ofmsg->getSockfd();

        ofmsg->~CMsg();

        CSmartPtr<COfRecvWorker> worker = CServer::getInstance()->mapOfRecvWorker(sockfd);
        if (worker.isNotNull())
            worker->getMemPool().release(ofmsg);
        else
            LOG_WARN_FMT("memory[%p] not released for none COfRecvWorker by sockfd[%d] !", ofmsg, sockfd);
    }
}
开发者ID:China863SDN,项目名称:DCFabric,代码行数:16,代码来源:COfRecvWorker.cpp

示例6: OnLoginAttempt

	virtual EModRet OnLoginAttempt(CSmartPtr<CAuthBase> Auth) {
		// e.g. webadmin ends up here
		const CString& sRemoteIP = Auth->GetRemoteIP();

		if (sRemoteIP.empty())
			return CONTINUE;

		unsigned int *pCount = m_Cache.GetItem(sRemoteIP);
		if (pCount && *pCount >= m_uiAllowedFailed) {
			// OnFailedLogin() will refresh their ban
			Auth->RefuseLogin("Please try again later - reconnecting too fast");
			return HALT;
		}

		return CONTINUE;
	}
开发者ID:bpcampbe,项目名称:znc,代码行数:16,代码来源:fail2ban.cpp

示例7: sizeof

INT4 COfRecvWorker::procRecvBuffer(INT4 sockfd, INT1* buffer, UINT4 len, CSmartPtr<CLoopBuffer>& recvBuffer)
{
    struct ofp_header* header = NULL;
    const UINT4 headerLen = sizeof(struct ofp_header);
    UINT2 lenTotal = 0;
    INT1* pdata = NULL, *pmsg = NULL;
    CMsg* ofmsg = NULL;
    CMsgTree& msgTree = CControl::getInstance()->getMsgTree();
    
    while (len >= headerLen)
    {
        header = (struct ofp_header*)buffer;
        lenTotal = ntohs(header->length);
        if (lenTotal < headerLen)
        {
            LOG_WARN_FMT("%s drop packet when invalid ofp_header.length %u !!!", toString(), lenTotal);
            return BNC_ERR;
        }
        if (len < lenTotal)
            break;

        procStats();

        pdata = (INT1*)m_memPool.alloc(lenTotal);
        if (NULL == pdata)
        {
            LOG_ERROR_FMT("alloc %u bytes failed!", lenTotal);
            return BNC_ERR;
        }
        memcpy(pdata, buffer, lenTotal);

        pmsg = (INT1*)m_memPool.alloc(sizeof(CMsg));
        if (NULL == pmsg)
        {
            LOG_ERROR_FMT("alloc CMsg failed !");
            m_memPool.release(pdata);
            return BNC_ERR;
        }
        ofmsg = new(pmsg) CMsg(sockfd, header->version, header->type, pdata, lenTotal);

        ofmsg->setPath();
        ofmsg->setKey();

        CSmartPtr<CMsgCommon> msg(ofmsg, deleteCmsg);
        if (msgTree.pushMsg(msg) != BNC_OK)
        {
            LOG_INFO_FMT("push msg[%s]key[%s] from sockfd[%d] into tree failed", 
                ofmsg->getPath().c_str(), ofmsg->getKey().c_str(), sockfd);
        }

        buffer += lenTotal;
        len -= lenTotal;
    }
    
    if (len > 0)
        recvBuffer->write(buffer, len);

    return BNC_OK;
}
开发者ID:China863SDN,项目名称:DCFabric,代码行数:59,代码来源:COfRecvWorker.cpp

示例8: processPeerEnterStable

void COfConnectMgr::processPeerEnterStable(CSmartPtr<CSwitch>& sw)
{
    if (sw.isNotNull())
    {
        //上报交换机事件ENTER_STABLE
        CSwitchEventReportor::getInstance()->report(sw, EVENT_TYPE_SWITCH_ENTER_STABLE, EVENT_REASON_NONE);
    }
}
开发者ID:China863SDN,项目名称:DCFabric,代码行数:8,代码来源:COfConnectMgr.cpp

示例9: needPowerOffCheck

BOOL COfConnectMgr::needPowerOffCheck(CSmartPtr<CSwitch>& sw)
{
    if (sw.isNull() || (sw->getState() >= SW_STATE_POWER_OFF))
        return FALSE;

    CPortMap& ports = sw->getPorts();
    STL_FOR_LOOP(ports, it)
    {
        gn_port_t& port = it->second;
        if (PORT_STATE_UP == port.state)
        {
            //if (PORT_TYPE_EXTERNAL == port.type)
            //    return TRUE;
            if (PORT_TYPE_SWITCH == port.type)
                return TRUE;
        }
    }
开发者ID:China863SDN,项目名称:DCFabric,代码行数:17,代码来源:COfConnectMgr.cpp

示例10: checkMsg

BOOL COfMsgTreeNode::checkMsg(CSmartPtr<CMsg>& msgPtr)
{
    if (msgPtr.isNull())
    {
        return FALSE;
    }

    //of消息类型检查
    UINT1* ofMsg = msgPtr->getData();
    struct ofp_header* header = (struct ofp_header*)ofMsg;
    if (header->type != getMsgType())
    {
        return FALSE;
    }

    return TRUE;
}
开发者ID:zhaozhongguo,项目名称:camel,代码行数:17,代码来源:COfMsgTreeNode.cpp

示例11: WheelDustCallback

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : &data - 
//-----------------------------------------------------------------------------
void WheelDustCallback( const CEffectData &data )
{
	CSmartPtr<CSimpleEmitter> pSimple = CSimpleEmitter::Create( "dust" );
	pSimple->SetSortOrigin( data.m_vOrigin );
	pSimple->SetNearClip( 32, 64 );

	SimpleParticle	*pParticle;

	Vector	offset;

	//FIXME: Better sampling area
	offset = data.m_vOrigin + ( data.m_vNormal * data.m_flScale );
	
	//Find area ambient light color and use it to tint smoke
	Vector	worldLight = WorldGetLightForPoint( offset, true );

	//Throw puffs
	offset.Random( -(data.m_flScale*16.0f), data.m_flScale*16.0f );
	offset.z = 0.0f;
	offset += data.m_vOrigin + ( data.m_vNormal * data.m_flScale );

	pParticle = (SimpleParticle *) pSimple->AddParticle( sizeof(SimpleParticle), g_Mat_DustPuff[0], offset );

	if ( pParticle != NULL )
	{			
		pParticle->m_flLifetime		= 0.0f;
		pParticle->m_flDieTime		= random->RandomFloat( 0.25f, 0.5f );
		
		pParticle->m_vecVelocity = RandomVector( -1.0f, 1.0f );
		VectorNormalize( pParticle->m_vecVelocity );
		pParticle->m_vecVelocity[2] += random->RandomFloat( 16.0f, 32.0f ) * (data.m_flScale*2.0f);

		int	color = random->RandomInt( 100, 150 );

		pParticle->m_uchColor[0] = 16 + ( worldLight[0] * (float) color );
		pParticle->m_uchColor[1] = 8 + ( worldLight[1] * (float) color );
		pParticle->m_uchColor[2] = ( worldLight[2] * (float) color );

		pParticle->m_uchStartAlpha	= random->RandomInt( 64.0f*data.m_flScale, 128.0f*data.m_flScale );
		pParticle->m_uchEndAlpha	= 0;
		pParticle->m_uchStartSize	= random->RandomInt( 16, 24 ) * data.m_flScale;
		pParticle->m_uchEndSize		= random->RandomInt( 32, 48 ) * data.m_flScale;
		pParticle->m_flRoll			= random->RandomInt( 0, 360 );
		pParticle->m_flRollDelta	= random->RandomFloat( -2.0f, 2.0f );
	}
}
开发者ID:BerntA,项目名称:tfo-code,代码行数:50,代码来源:c_vehicle_jeep.cpp

示例12: LOG_INFO_FMT

INT4 CMsgQueues::pushMsg(CSmartPtr<CMsgCommon>& msg)
{
    LOG_INFO_FMT("push oper[%d]msg[%s]key[%s] into queue of %s ...", 
        msg->getOperation(), msg->getPath().c_str(), msg->getKey().c_str(), 
        (NULL!=m_operator)?m_operator->toString():"producer");

#if defined(USING_LK_HASH_MAP)
    UINT4 index = m_queues.bucketIndex(msg->getKey());
    m_queues.bucketLock(index);
#endif

    CSmartPtr<CMsgQueue> queue = getQueue(msg->getKey());
    if (queue.isNull())
    {
        queue = createQueue(msg->getKey());
        if (queue.isNull())
        {
            LOG_WARN_FMT("%s[%p] createQueue for path[%s]key[%s] failed !", 
                (NULL!=m_operator)?m_operator->toString():"producer", m_operator, m_path.c_str(), msg->getKey().c_str());
#if defined(USING_LK_HASH_MAP)
            m_queues.bucketUnlock(index);
#endif
            return BNC_ERR;
        }
    }

    LOG_INFO_FMT("%s[%p] before push, path[%s]key[%s] has msg count[%lu] ...", 
        (NULL!=m_operator)?m_operator->toString():"producer", m_operator, m_path.c_str(), msg->getKey().c_str(), queue->size());
    push(queue, msg);
    LOG_INFO_FMT("%s[%p] after pushed and rearranged, path[%s]key[%s] has msg count[%lu] ...", 
        (NULL!=m_operator)?m_operator->toString():"producer", m_operator, m_path.c_str(), msg->getKey().c_str(), queue->size());

#if defined(USING_LK_HASH_MAP)
    m_queues.bucketUnlock(index);
#endif

#if 0
    if ((NULL==m_operator)||
        !strcmp(m_operator->toString(),"CSwitchEventTester")||
        !strcmp(m_operator->toString(),"CLinkEventTester")||
        !strcmp(m_operator->toString(),"CPortEventTester"))
    {
        LOG_WARN_FMT("######%s[%p] after pushed and rearranged, path[%s]key[%s] has msg count[%lu] ...", 
            (NULL!=m_operator)?m_operator->toString():"producer", m_operator, m_path.c_str(), msg->getKey().c_str(), queue->size());
        LOG_WARN_FMT("######%s[%p] after pushed msg, path[%s] has queues count[%lu] ...", 
            (NULL!=m_operator)?m_operator->toString():"producer", m_operator, m_path.c_str(), m_queues.size());
    }
#endif

    return BNC_OK;
}
开发者ID:China863SDN,项目名称:DCFabric,代码行数:51,代码来源:CMsgQueue.cpp

示例13: main

int main()
{
    //mq_unlink("/sensor");
    //mq_unlink("/actuator");

    CLogger().setStream(std::cout);

    Sensor      sen("/sensor", 0u, 0u);
    Actuator    act("/actuator", sizeof(int), 10u);

    sen.join();
    act.join();

    CSmartPtr<FOO> a;
    {
        CSmartPtr<FOO> b;
        {
            CSmartPtr<FOO> c(new FOO);
            a = c;
            b = a;
            c->foo();
            a->foo();
            b->foo();
        }
        a->foo();
        b->foo();
    }
    a->foo();

    return 0;
}
开发者ID:andriy-bilynskyy,项目名称:OSAL,代码行数:31,代码来源:main.cpp

示例14: ClientThink

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_ObjectEMPGenerator::ClientThink( void )
{
	// Add particles at the target.
	float flCur = gpGlobals->frametime;
	while ( m_ParticleEvent.NextEvent( flCur ) )
	{
		Vector vPos = WorldSpaceCenter( );
		Vector vOffset = RandomVector( -1, 1 );
		VectorNormalize( vOffset );
		vPos += vOffset * RandomFloat( 0, 50 );
		
		SimpleParticle *pParticle = m_pEmitter->AddSimpleParticle( m_hParticleMaterial, vPos );
		if ( pParticle )
		{
			// Move the points along the path.
			pParticle->m_vecVelocity.Init();
			pParticle->m_flRoll = 0;
			pParticle->m_flRollDelta = 0;
			pParticle->m_flDieTime = 0.4f;
			pParticle->m_flLifetime = 0;
			pParticle->m_uchColor[0] = 255; 
			pParticle->m_uchColor[1] = 255;
			pParticle->m_uchColor[2] = 255;
			pParticle->m_uchStartAlpha = 32;
			pParticle->m_uchEndAlpha = 0;
			pParticle->m_uchStartSize = 6;
			pParticle->m_uchEndSize = 4;
			pParticle->m_iFlags = 0;
		}
	}
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:34,代码来源:c_obj_empgenerator.cpp

示例15: ClientThink

//------------------------------------------------------------------------------
// Purpose :
// Input   :
// Output  :
//------------------------------------------------------------------------------
void C_PlasmaBeamNode::ClientThink(void)
{
	if (!m_bSprayOn)
	{
		return;
	}
	
	trace_t trace;
	Vector vEndTrace = GetAbsOrigin() + (0.3*GetAbsVelocity());
	UTIL_TraceLine( GetAbsOrigin(), vEndTrace, MASK_SHOT, NULL, COLLISION_GROUP_NONE, &trace );
	if ( trace.fraction != 1.0f || trace.startsolid)
	{
		m_bSprayOn = false;
		return;
	}

	PMaterialHandle handle = m_pFirePlasmaSpray->GetPMaterial( "sprites/plasmaember" );
	for (int i=0;i<SPRAYS_PER_THINK;i++)
	{
		SimpleParticle	*sParticle;

		//Make a new particle
		if ( random->RandomInt( 0, 2 ) == 0 )
		{
			float ranx = random->RandomFloat( -28.0f, 28.0f );
			float rany = random->RandomFloat( -28.0f, 28.0f );
			float ranz = random->RandomFloat( -28.0f, 28.0f );

			Vector vNewPos	=  GetAbsOrigin();
			Vector vAdd		=  Vector(GetAbsAngles().x,GetAbsAngles().y,GetAbsAngles().z)*random->RandomFloat(-60,120);
			vNewPos			+= vAdd;

			sParticle = (SimpleParticle *) m_pFirePlasmaSpray->AddParticle( sizeof(SimpleParticle), handle, vNewPos );
			
			sParticle->m_flLifetime		= 0.0f;
			sParticle->m_flDieTime		= PLASMASPARK_LIFETIME;

			sParticle->m_vecVelocity	= GetAbsVelocity();
			sParticle->m_vecVelocity.x	+= ranx;
			sParticle->m_vecVelocity.y	+= rany;
			sParticle->m_vecVelocity.z	+= ranz;
			m_pFirePlasmaSpray->m_pOwner	=  this;
		}
	}

	SetNextClientThink(gpGlobals->curtime + 0.05);
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:52,代码来源:c_plasma_beam_node.cpp


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