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


C++ Listener类代码示例

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


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

示例1: listener_spawn

/*
 * listener_spawn is responsible for creating a Listener class
 * and launching the listener. It is provided as a means for
 * the C thread subsystem to launch the listener C++ object.
 */
void listener_spawn( thread_Settings *thread ) {
    Listener *theListener = NULL;

    // start up a listener
    theListener = new Listener( thread );
#ifndef WIN32
    // handling of daemon mode in non-win32 builds
    if ( isDaemon( thread ) ) {
        theListener->runAsDaemon("iperf",LOG_DAEMON);
    }
#endif

    // Start listening
    theListener->Run();
    DELETE_PTR( theListener );
}
开发者ID:CalSPEED,项目名称:iPerf,代码行数:21,代码来源:Launch.cpp

示例2: updateView

void Entity::updateView(View &view , Listener &listener , RenderWindow &window)
{
	Vector2u sizeWindow = window.getSize();
	//sizeWindow.x /= 1.f;//SCALE_VIEW
	//sizeWindow.y /= 1.f;// TODO : increase zoom for camera, reason: small image
	view.setSize(Vector2f(sizeWindow));

	float tempX = getXPos();
	float tempY = getYPos();

	listener.setPosition(tempX, tempY, 0);

	float x = getXPos();
	float y = getYPos();

	int leftBorder = sizeWindow.x / 2;
	int rightBorder = SIZE_BLOCK * (WIDTH_MAP - BORDER1) - sizeWindow.x / 2;
	int topBorder = sizeWindow.y / 2;
	int lowBorder = SIZE_BLOCK * LONG_MAP - sizeWindow.y / 2;

	if (int(x) < leftBorder) tempX = float(leftBorder);
	else if (int(x) > rightBorder) tempX = float(rightBorder);
	if (int(y) < topBorder) tempY = float(topBorder);
	else if (int(y) > lowBorder) tempY = float(lowBorder);

	view.setCenter(tempX, tempY);
}
开发者ID:7kia,项目名称:Theory-programming,代码行数:27,代码来源:MainPerson.cpp

示例3: DS_SFX_Listenerv

/**
 * @param prop  SFXLP_ORIENTATION  (yaw, pitch) in degrees.
 */
void DS_SFX_Listenerv(int prop, float* values)
{
    switch(prop)
    {
    case SFXLP_POSITION:
        listener.position.set(values);
        //DSFMOD_TRACE("Pos:" << values[0] << "," << values[1] << "," << values[2]);
        break;

    case SFXLP_ORIENTATION:
        // Convert the angles to front and up vectors.
        listener.setOrientation(float(values[0]/180*M_PI), float(values[1]/180*M_PI));
        break;

    case SFXLP_VELOCITY:
        listener.velocity.set(values);
        break;

    case SFXLP_REVERB:
        updateListenerEnvironmentSettings(values);
        break;

    case SFXLP_PRIMARY_FORMAT:
        DSFMOD_TRACE("SFX_Listenerv: Ignoring SFXLP_PRIMARY_FORMAT.");
        return;

    default:
        return;
    }
}
开发者ID:cmbruns,项目名称:Doomsday-Engine,代码行数:33,代码来源:fmod_sfx.cpp

示例4: bool

RowType* ForexConnectWrapper::getTableRow(O2GTable table, std::string key, bool (*finderFunc)(RowType *, std::string), ReaderType* (*readerCreateFunc)(IO2GResponseReaderFactory* , IO2GResponse *)) {

    IO2GResponse *response;

    if( !loginRules->isTableLoadedByDefault(table) ) {
        IO2GRequest *request = mRequestFactory->createRefreshTableRequestByAccount(Trades, sAccountID.c_str());

        Listener *ll = new Listener(session);
        response = ll->sendRequest(request);
        request->release();
        ll->release();
        if (!response) {
            log("No response to manual table refresh request");
            throw "No response to manual table refresh request";
        }
    } else {
        response = loginRules->getTableRefreshResponse(table);
        if (!response) {
            log("No response to automatic table refresh request");
            throw "No response to automatic table refresh request";
        }
    }

    ReaderType *reader = readerCreateFunc(mResponseReaderFactory, response);
    response->release();

    RowType *row = NULL;

    for ( int i = 0; i < reader->size(); ++i ) {
        row = reader->getRow(i);
        if ( finderFunc(row, key) ) {
                break;
        }
        row->release();
        row = NULL;
    }
    reader->release();

    if (row == NULL) {
        std::stringstream ss;
        ss << "Could not find row for key " << key;
        log(ss.str());
        throw ss.str().c_str();
    }

    return row;
}
开发者ID:joaocosta,项目名称:Finance-FXCM-Simple,代码行数:47,代码来源:ForexConnectWrapper.cpp

示例5: main

int main()
{
	model = new Wrapper(new SimpleModel());
	Simulator<External*>* sim = new Simulator<External*>(model);
	Listener* l = new Listener();
	sim->addEventListener(l);
	// First input/output series. Internal event test.
	l->setExpected(1.0,FAST,1);
	Event<External*> e;
	e.model = model;
	e.value = new External(FAST,1);
	Bag<Event<External*> > x;
	x.insert(e);
	sim->computeNextState(x,0.0);
	assert(sim->nextEventTime() == 1.0);
	sim->execNextEvent();
	assert(output_happened);
	output_happened = false;
	// Second input/output series. External event test.
	l->setExpected(3.5,SLOW,1);
	x.clear();
	e.value = new External(SLOW,1);
	x.insert(e);
	sim->computeNextState(x,1.5);
	assert(!output_happened);
	assert(sim->nextEventTime() == 3.5);
	sim->execNextEvent();
	assert(output_happened);
	output_happened = false;
	// Third input/output series. Confluent event test
	l->setExpected(5.5,SLOW,2);
	x.clear();
	e.value = new External(STOP,1);
	x.insert(e);
	assert(sim->nextEventTime() == 5.5);
	sim->computeNextState(x,sim->nextEventTime());
	assert(output_happened);
	assert(sim->nextEventTime() == DBL_MAX);
	// Done. Try to clean up.
	assert(External::num_existing == 3);
	delete model;
	delete l;
	delete sim;
	assert(Internal::num_existing == 0);
	return 0;
}
开发者ID:Network-Dynamics,项目名称:adevs,代码行数:46,代码来源:test.cpp

示例6: log

void ForexConnectWrapper::openMarket(const std::string symbol, const std::string direction, int amount) {
    if (direction != O2G2::Sell && direction != O2G2::Buy) {
        log("Direction must be 'B' or 'S'");
        throw "Direction must be 'B' or 'S'";
    }

    std::string sOfferID = getOfferID(symbol);

    IO2GValueMap *valuemap = mRequestFactory->createValueMap();
    valuemap->setString(Command, O2G2::Commands::CreateOrder);
    valuemap->setString(OrderType, O2G2::Orders::TrueMarketOpen);
    valuemap->setString(AccountID, sAccountID.c_str());
    valuemap->setString(OfferID, sOfferID.c_str());
    valuemap->setString(BuySell, direction.c_str());
    valuemap->setInt(Amount, amount);
    valuemap->setString(TimeInForce, O2G2::TIF::IOC);

    IO2GRequest *orderRequest = mRequestFactory->createOrderRequest(valuemap);
    valuemap->release();

    TableListener *tableListener = new TableListener();
    tableListener->setRequestID(orderRequest->getRequestID());

    IO2GTableManager *tableManager = getLoadedTableManager();
    subscribeTableListener(tableManager, tableListener);

    Listener *ll = new Listener(session);
    IO2GResponse *response = ll->sendRequest(orderRequest);
    orderRequest->release();
    ll->release();

    if (!response) {
        std::stringstream ss;
        ss << "Failed to send openMarket request " << symbol << " " << direction << " " << amount;
        log(ss.str());
        throw ss.str().c_str();
    }

    tableListener->waitForTableUpdate();

    response->release();
    unsubscribeTableListener(tableManager, tableListener);
    tableListener->release();
    tableManager->release();
}
开发者ID:joaocosta,项目名称:Finance-FXCM-Simple,代码行数:45,代码来源:ForexConnectWrapper.cpp

示例7: Parse

void XmlSceneParser::Parse (const ParseNode& decl, Listener& node, Node& parent, SceneContext& context)
{
  try
  {
      //настройка узла
      
    node.SetGain (get<float> (decl, "gain", node.Gain ()));
    
      //разбор родительских параметров
    
    Parse (decl, static_cast<Entity&> (node), parent, context);    
  }
  catch (xtl::exception& e)
  {
    e.touch ("scene_graph::XmlSceneParser::Parse(const ParseNode&,Listener&,Node&,SceneContext&)");
    throw;
  }
}
开发者ID:untgames,项目名称:funner,代码行数:18,代码来源:sg_xml_scene_parser.cpp

示例8: assert

void Entity::publish() {
    assert(!isPublished);
    isPublished = true;
    
    // Try find which listeners (systems) correspond with this entity's set of components
    for(std::vector<System*>::iterator sysIter = world->systems.begin(); sysIter != world->systems.end(); ++ sysIter) {
        System* sys = *sysIter;
        
        // Iterate over that system's requirements, check that each one is fulfilled
        bool haveAllRequirements = true;
        const std::vector<ComponentID>& requirements = sys->getRequiredComponents();
        for(std::vector<ComponentID>::const_iterator reqIter = requirements.begin(); reqIter != requirements.end(); ++ reqIter) {
            const ComponentID& reqId = *reqIter;
            
            // Check if we fulfill this requirements
            bool haveRequirement = false;
            for(std::vector<Component*>::iterator compIter = components.begin(); compIter != components.end(); ++ compIter) {
                Component* myComponent = *compIter;
                
                if(myComponent->getID() == reqId) {
                    haveRequirement = true;
                    break;
                }
            }
            
            // If we are missing a single requirement, then we do not have all of them
            if(!haveRequirement) {
                haveAllRequirements = false;
                break;
            }
        }
        
        // Entity has all requirements, therefore add it to our listener list
        if(haveAllRequirements) {
            listeners.push_back(sys);
        }
    }
    
    // Tell every listener that we exist
    for(std::vector<Listener*>::iterator listIter = listeners.begin(); listIter != listeners.end(); ++ listIter) {
        Listener* listener = *listIter;
        listener->onEntityExists(this);
    }
}
开发者ID:Naftoreiclag,项目名称:VS8C,代码行数:44,代码来源:nresEntity.cpp

示例9: getLoadedTableManager

void ForexConnectWrapper::setSubscriptionStatus(std::string instrument, std::string status) {
    IO2GTableManager *tableManager = getLoadedTableManager();
    IO2GOffersTable *offersTable = (IO2GOffersTable *)tableManager->getTable(::Offers);
    tableManager->release();

    IO2GOfferTableRow *offerRow = NULL;
    IO2GTableIterator tableIterator;
    bool instrumentFound = false;

    while (offersTable->getNextRow(tableIterator, offerRow)) {
        if ( instrument == offerRow->getInstrument() ) {
            instrumentFound = true;
            IO2GRequestFactory *factory = session->getRequestFactory();

            IO2GValueMap *valueMap = factory->createValueMap();
            valueMap->setString(::Command, O2G2::Commands::SetSubscriptionStatus);
            valueMap->setString(::SubscriptionStatus, status.c_str());
            valueMap->setString(::OfferID, offerRow->getOfferID());

            IO2GRequest *request = factory->createOrderRequest(valueMap);
            valueMap->release();

            Listener *ll = new Listener(session);
            IO2GResponse *response = ll->sendRequest(request);
            response->release();
            request->release();
            ll->release();
            factory->release();

            break;
        }
    }
    offerRow->release();
    offersTable->release();

    if (!instrumentFound) {
        std::stringstream ss;
        ss << "Could not find offer row for instrument " << instrument;
        log(ss.str());
        throw ss.str().c_str();
    }
}
开发者ID:joaocosta,项目名称:Finance-FXCM-Simple,代码行数:42,代码来源:ForexConnectWrapper.cpp

示例10: GetListener

void Transport::Send(Serializer& _ser, const Peer& _peer, netU32 _type)
{
	Listener *listener = GetListener(_type);

	if(listener)
	{
		_ser.ResetCursor();
		SerializerLess serless(_ser);
		listener->Push(serless, _peer);
	}
	else
	{
		// unavailable transport
		assert(false);
	}

	// update stats
	struct Activity* activity = GetActivity(_peer);
	activity->m_lastSend = Time::GetMsTime();
	activity->m_nbSend++;
}
开发者ID:ricklesauceur,项目名称:netduke,代码行数:21,代码来源:transport.cpp

示例11: FindEventHandler

const TypedEventHandler*
EventListenerManager::GetTypedEventHandler(nsIAtom* aEventName,
                                           const nsAString& aTypeString)
{
  uint32_t eventType = nsContentUtils::GetEventId(aEventName);
  Listener* listener = FindEventHandler(eventType, aEventName, aTypeString);

  if (!listener) {
    return nullptr;
  }

  JSEventHandler* jsEventHandler = listener->GetJSEventHandler();

  if (listener->mHandlerIsString) {
    CompileEventHandlerInternal(listener, nullptr, nullptr);
  }

  const TypedEventHandler& typedHandler =
    jsEventHandler->GetTypedEventHandler();
  return typedHandler.HasEventHandler() ? &typedHandler : nullptr;
}
开发者ID:Balakrishnan-Vivek,项目名称:gecko-dev,代码行数:21,代码来源:EventListenerManager.cpp

示例12: Pull

netBool Transport::Pull(SerializerLess &_ser, Peer& _peer)
{
	netBool isFound = false;

	for(listeners_t::iterator it=m_listeners.begin(); it != m_listeners.end(); ++it)
	{
		Listener *listener = (*it);
		if(listener->Pull(_ser, _peer))
		{
			isFound = true;

			// update stats
			struct Activity* activity = GetActivity(_peer);
			activity->m_lastRecv = Time::GetMsTime();
			activity->m_nbRecv++;

			break;
		}
	}

	return isFound;
}
开发者ID:ricklesauceur,项目名称:netduke,代码行数:22,代码来源:transport.cpp

示例13: chainEvents

bool chainEvents(Listener& someListener, const LLSD& event)
{
	// Make this call so we can watch for side effects for test purposes.
	someListener.call(event);
	// This function represents a recursive event chain -- or some other
	// scenario in which an event handler raises additional events.
	int value = event.asInteger();
	if (value)
	{
		LLEventPumps::instance().obtain("login").post(value - 1);
	}
	return false;
}
开发者ID:OS-Development,项目名称:VW.Dolphin_v3,代码行数:13,代码来源:llevents_tut.cpp

示例14: main

//
// Run motion detection on a saved file, provide debug images in matrix mode over HTTP
//
int main( int argc, const char *argv[] )
{
    debugInitialise( "example6", "", 5 );

    Info( "Starting" );

    avInit();

    Application app;

    NetworkAVInput input( "input", "/tmp/movie.mp4" );
    app.addThread( &input );

    MotionDetector motionDetector( "modect" );
    motionDetector.registerProvider( input );
    //EventRecorder eventRecorder( "/transfer/ozx" );
    app.addThread( &motionDetector );

    MatrixVideo matrixVideo( "matrix", PIX_FMT_YUV420P, 640, 480, FrameRate( 1, 10 ), 2, 2 );
    matrixVideo.registerProvider( *motionDetector.refImageSlave() );
    matrixVideo.registerProvider( *motionDetector.compImageSlave() );
    matrixVideo.registerProvider( *motionDetector.deltaImageSlave() );
    matrixVideo.registerProvider( *motionDetector.varImageSlave() );
    app.addThread( &matrixVideo );

    Listener listener;
    app.addThread( &listener );

    HttpController httpController( "p8080", 8080 );
    listener.addController( &httpController );

    httpController.addStream( "file", input );
    httpController.addStream( "debug", SlaveVideo::cClass() );
    httpController.addStream( "debug", matrixVideo );
    httpController.addStream( "debug", motionDetector );

    app.run();
}
开发者ID:jianhongwei,项目名称:ozonebase,代码行数:41,代码来源:example6.cpp

示例15: update

void ParticleL::update(const Listener& list, const ci::Vec2f pos){

	mAge++;
	if (mAge > mLifespan)
		mIsDead = true;
	float ageMap = 1.0f - (mAge / (float)mLifespan);

	mRadius = constrain(list.getVolume() * 2.f, .5f, 2.f );
	
	Vec2f expander = mAnchorPosition;
	expander.rotate(mAge/20.f);
	expander *= mRadius;
	addPosition( expander );
}
开发者ID:brucelane,项目名称:f2_Orbs,代码行数:14,代码来源:ParticleL.cpp


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