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


C++ CommandQueue类代码示例

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


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

示例1: LBASSERT

bool Dispatcher::dispatchCommand( ICommand& command )
{
    LBASSERT( command.isValid( ));

    LBVERB << "dispatch " << command << " on " << lunchbox::className( this )
           << std::endl;

    const uint32_t which = command.getCommand();
#ifndef NDEBUG
    if( which >= _impl->qTable.size( ))
    {
        LBABORT( "ICommand " << command
                 << " higher than number of registered command handlers ("
                 << _impl->qTable.size() << ") for object of type "
                 << lunchbox::className( this ) << std::endl );
        return false;
    }
#endif

    CommandQueue* queue = _impl->qTable[ which ];
    if( queue )
    {
        command.setDispatchFunction( _impl->fTable[ which ] );
        queue->push( command );
        return true;
    }
    // else

    LBCHECK( _impl->fTable[ which ]( command ));
    return true;
}
开发者ID:OlafRocket,项目名称:Collage,代码行数:31,代码来源:dispatcher.cpp

示例2: EQABORT

bool Dispatcher::dispatchCommand( Command& command )
{
    EQVERB << "dispatch " << command << " on " << base::className( this )
           << std::endl;

    const uint32_t which = command->command;
#ifndef NDEBUG
    if( which >= _qTable.size( ))
    {
        EQABORT( "Command " << command
                 << " higher than number of registered command handlers ("
                 << _qTable.size() << ") for object of type "
                 << base::className( this ) << std::endl );
        return false;
    }
#endif

    CommandQueue* queue = _qTable[which];
    if( queue )
    {
        command.setDispatchFunction( _fTable[which] );
        queue->push( command );
        return true;
    }
    // else

    EQCHECK( _fTable[which]( command ));
    return true;
}
开发者ID:MichaelVlad,项目名称:Equalizer,代码行数:29,代码来源:dispatcher.cpp

示例3: HandleEvent

void Player::HandleEvent(const sf::Event& event, CommandQueue& commands)
{

	if ( m_useJoystick )
	{
		Command_t c;
		c.category = Category::PlayerAircraft;
		if ( event.type == sf::Event::JoystickButtonPressed )
		{
			if ( event.joystickButton.button == 2)
			//if ( sf::Joystick::isButtonPressed( 0, 2 ) )
			{
				// yes: shoot!
				c.action = DerivedAction<Creature>( []( Creature& a, sf::Time ){ a.LaunchMissile(); } );
				commands.Push( c );
			}
		}
	}
	else
	{
		if ( event.type == sf::Event::KeyPressed )
		{
			// Check if pressed key appears in key binding, trigger command if so
			auto found = m_keyBinding.find( event.key.code );
			if ( found != m_keyBinding.end() && !IsRealtimeAction( found->second ) )
				commands.Push( m_actionBinding[found->second] );
		}
	}
	
}
开发者ID:Donald522,项目名称:pixels,代码行数:30,代码来源:Player.cpp

示例4: dequeueCommand

//protected
ICommand* AbstractManager::dequeueCommand()
{
    ICommand* command=0;
    if(mLock.tryLockForWrite(mReadMaxWait))
    {
        for(int severity=ICommand::HIGH;
            severity <= ICommand::LOW;
            severity++)
        {
            CommandQueue* queue = mHashCommandQueues.value(severity,0);
            if(queue)
            {
                if(!queue->isEmpty())
                {
                    command = queue->dequeue();
                    if(command)
                    {
                        break;
                    }
                }
            }
        }
        mLock.unlock();
    }
    return command;
}
开发者ID:MTechIIST2012,项目名称:SRpayloadRecovery,代码行数:27,代码来源:abstractmanager.cpp

示例5: Heap

Heap * Heap::Alloc(ID3D12Device * Device, int Type) {
    Heap * heap = 0;
    D3D12Render * render = D3D12Render::GetRender();
    CommandQueue * Queue = render->GetQueue(D3D12_COMMAND_LIST_TYPE_DIRECT);
    if (Free.Size()) {
        heap = Free.PopBack();
    }
    else {
        bool Found = 0;
        for (auto Iter = Retired.Begin(); Iter != Retired.End(); Iter++) {
            heap = *Iter;
            UINT64 FenceValue = heap->FenceValue;
            if (Queue->FenceComplete(FenceValue)) {
                Retired.Remove(Iter);
                Found = 1;
                break;
            }
        }
        if (!Found) {
            heap = 0;
        }
    }
    if (heap) {
        return heap;
    }
    else {
        // new context
        heap = new Heap();
        heap->Init(Device, MAX_CONSTANT_BUFFER_HEAP, Type);
    }
    return heap;
}
开发者ID:nickjfree,项目名称:renderer,代码行数:32,代码来源:Heap.cpp

示例6: checkProjectileLaunch

void Aircraft::checkProjectileLaunch(sf::Time dt, CommandQueue& commands)
{
	// Enemies try to fire all the time
	if (!isAllied())
		fire();

	// Check for automatic gunfire, allow only in intervals
	if (mIsFiring && mFireCountdown <= sf::Time::Zero)
	{
		// Interval expired: We can fire a new bullet
		commands.push(mFireCommand);
		mFireCountdown += Table[mType].fireInterval / (mFireRateLevel + 1.f);
		mIsFiring = false;
	}
	else if (mFireCountdown > sf::Time::Zero)
	{
		// Interval not expired: Decrease it further
		mFireCountdown -= dt;
		mIsFiring = false;
	}

	// Check for missile launch
	if (mIsLaunchingMissile)
	{
		commands.push(mMissileCommand);
		mIsLaunchingMissile = false;
	}
}
开发者ID:gabrieljt,项目名称:learn-sfml,代码行数:28,代码来源:Aircraft.cpp

示例7: LB_TS_THREAD

MessagePump* Pipe::getMessagePump()
{
    LB_TS_THREAD( _pipeThread );
    if( !_impl->thread )
        return 0;

    CommandQueue* queue = _impl->thread->getWorkerQueue();
    return queue->getMessagePump();
}
开发者ID:niujunpenghn,项目名称:Equalizer,代码行数:9,代码来源:pipe.cpp

示例8: _exitCommandQueue

void Pipe::_exitCommandQueue()
{
    // Non-threaded pipes have no pipe thread message pump
    if( !_impl->thread )
        return;

    CommandQueue* queue = _impl->thread->getWorkerQueue();
    LBASSERT( queue );

    MessagePump* pump = queue->getMessagePump();
    queue->setMessagePump( 0 );
    delete pump;
}
开发者ID:niujunpenghn,项目名称:Equalizer,代码行数:13,代码来源:pipe.cpp

示例9: pthread_mutex_lock

bool Event::removeWaitEvent(Event *event)
{
    bool empty;

    pthread_mutex_lock(&p_state_mutex);
    p_wait_events.remove(event);
    empty = p_wait_events.empty();
    pthread_mutex_unlock(&p_state_mutex);

    CommandQueue *q = (CommandQueue *) event->parent();
    if (q != NULL) q->releaseEvent(event);
    return empty;
}
开发者ID:rcn-ee,项目名称:ti-opencl,代码行数:13,代码来源:commandqueue.cpp

示例10: main

int main(int argc, char ** argv) {
    // Load image
    SIPL::Image<float> * image = new SIPL::Image<float>("images/sunset.jpg");

    // Create OpenCL context
    Context context = createCLContextFromArguments(argc, argv);

    // Compile OpenCL code
    Program program = buildProgramFromSource(context, "gaussian_blur.cl");

    // Select device and create a command queue for it
    VECTOR_CLASS<Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
    CommandQueue queue = CommandQueue(context, devices[0]);

    // Create an OpenCL Image / texture and transfer data to the device
    Image2D clImage = Image2D(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, ImageFormat(CL_R, CL_FLOAT), image->getWidth(), image->getHeight(), 0, (void*)image->getData());

    // Create a buffer for the result
    Buffer clResult = Buffer(context, CL_MEM_WRITE_ONLY, sizeof(float)*image->getWidth()*image->getHeight());

    // Create Gaussian mask
    int maskSize;
    float * mask = createBlurMask(10.0f, &maskSize);

    // Create buffer for mask and transfer it to the device
    Buffer clMask = Buffer(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, sizeof(float)*(maskSize*2+1)*(maskSize*2+1), mask);

    // Run Gaussian kernel
    Kernel gaussianBlur = Kernel(program, "gaussian_blur");
    gaussianBlur.setArg(0, clImage);
    gaussianBlur.setArg(1, clMask);
    gaussianBlur.setArg(2, clResult);
    gaussianBlur.setArg(3, maskSize);

    queue.enqueueNDRangeKernel(
        gaussianBlur,
        NullRange,
        NDRange(image->getWidth(), image->getHeight()),
        NullRange
    );

    // Transfer image back to host
    float* data = new float[image->getWidth()*image->getHeight()];
    queue.enqueueReadBuffer(clResult, CL_TRUE, 0, sizeof(float)*image->getWidth()*image->getHeight(), data);
    image->setData(data);

    // Save image to disk
    image->save("images/result.jpg", "jpeg");
    image->display();
}
开发者ID:smistad,项目名称:OpenCL-Gaussian-Blur,代码行数:50,代码来源:main.cpp

示例11: checkPickupDrop

void Aircraft::checkPickupDrop(CommandQueue& commands)
{
	if (!isAllied() && randomInt(3) == 0 && !mSpawnedPickup)
		commands.push(mDropPickupCommand);

	mSpawnedPickup = true;
}
开发者ID:Nyssther,项目名称:SFML-Game-Development-Book,代码行数:7,代码来源:Aircraft.cpp

示例12: updateInput

void Player::updateInput(CommandQueue &command_queue)
{
	if (keyboard_works == true)
	for (auto &itr : key_to_action)
	{
		//If the key is pressed add to the set. If not then delete from the set.
		//If it's a new key then refresh the last_key_pressed and current_action
		if (sf::Keyboard::isKeyPressed(itr.first)) 
		{
			auto key = keys_pressed.find(itr.first);
			if (key == keys_pressed.end())
			{
				current_action = key_to_action[itr.first];
				last_key_pressed = itr.first;
			}
			keys_pressed.insert(itr.first);
		}
		else
		{
			auto key = keys_pressed.find(itr.first);
			if (key != keys_pressed.end()) keys_pressed.erase(itr.first);
		}
	}


	if(last_key_pressed != 0 && keyboard_works == true)
		command_queue.push(action_to_command[current_action]);
	//command_queue.push(action_to_command[key_to_action[last_key_pressed]]);
}
开发者ID:CarlosPerezPuertas,项目名称:Pacman,代码行数:29,代码来源:Player.cpp

示例13: handleEvent

void Player::handleEvent(const sf::Event& event, CommandQueue& commands)
{
    // event souris
    if (event.type == sf::Event::KeyPressed)
    {
         auto found = m_keyBinding.find(event.key.code);
            if (found != m_keyBinding.end() && !isRealtimeAction(found->second))
                commands.push(m_actionBinding[found->second]);
    }
    else if(event.type == sf::Event::MouseButtonPressed)
    {
        auto found = m_mouseBinding.find(event.mouseButton.button);
            if (found != m_mouseBinding.end() && !isRealtimeAction(found->second))
                commands.push(m_actionBinding[found->second]);
    }
}
开发者ID:tristanklempka,项目名称:Purple-Xylophone,代码行数:16,代码来源:Player.cpp

示例14: updateCurrent

void Tile::updateCurrent(sf::Time dt, CommandQueue& commands)
{
	// Entity has been destroyed: Possibly drop pickup, mark for removal
	if (isDestroyed())
	{
		checkPickupDrop(commands);
		mExplosion.update(dt);
		// Play explosion sound only once
		if (!mExplosionBegan)
		{
			// Play sound effect
			SoundEffect::ID soundEffect = (randomInt(2) == 0) ? SoundEffect::Explosion1 : SoundEffect::Explosion2;
			playLocalSound(commands, soundEffect);

			// Emit network game action for explosions
			if (isBlock())
			{
				sf::Vector2f position = getWorldPosition();

				Command command;
				command.category = Category::Network;
				command.action = derivedAction<NetworkNode>([position] (NetworkNode& node, sf::Time)
															{
																node.notifyGameAction(GameActions::EnemyExplode, position);
															});

				commands.push(command);
				mExplosionBegan = true;
			}
		}
		return;
	}

	Entity::updateCurrent(dt, commands);
}
开发者ID:ffrujeri,项目名称:SFML-bomberman-clone,代码行数:35,代码来源:Tile.cpp

示例15: handleRealtimeInput

void Player::handleRealtimeInput(CommandQueue& commands) {
	// Checks every key for a press
	for (auto pair : mKeyBinding) {
		// if something is pressed make sure to trigger command
		if (sf::Keyboard::isKeyPressed(pair.first) && isRealtimeAction(pair.second))
			commands.push(mActionBinding[pair.second]);
	}
}
开发者ID:x00112310,项目名称:Space-Shooter-Game,代码行数:8,代码来源:Player.cpp


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