本文整理汇总了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 );
}
示例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);
}
示例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;
}
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
}
示例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);
}
}
示例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();
}
}
示例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++;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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 );
}