void CCTCPSocketHub::update(float delta) { for(CCTCPSocketList::iterator iter = m_lstSocket.begin(); iter != m_lstSocket.end(); ++ iter) { CCTCPSocket* pSocket = *iter; int tag = pSocket->getTag(); if (!pSocket->hasAvailable()) { if(pSocket->isConnected()) { pSocket->setConnected(false); CCTCPSocketListener* l = getListener(tag); if(l) l->onTCPSocketDisconnected(tag); } CC_SAFE_RELEASE(*iter); m_lstSocket.erase(iter); break; } else if(!pSocket->isConnected()) { pSocket->setConnected(true); CCTCPSocketListener* l = getListener(tag); if(l) l->onTCPSocketConnected(tag); } while (true) { int read = pSocket->receiveData(m_buffer, kCCSocketMaxPacketSize); if (read <= 0) break; CCByteBuffer packet; packet.write((uint8*)m_buffer, read); CCTCPSocketListener* l = getListener(tag); if(l) { l->onTCPSocketData(tag, packet); } } } }
void QblEvpDigest::finish(){ unsigned char hash[EVP_MAX_MD_SIZE]; unsigned int length; EVP_DigestFinal_ex(&mdctx, hash, &length); EVP_MD_CTX_cleanup(&mdctx); std::vector<char> vect(hash, hash + length); getListener()->onData(vect); getListener()->onFinish(); }
STDMETHODIMP EventSourceChangedEventWrap::COMGETTER(Listener)(IEventListener **aListener) { LogRelFlow(("{%p} %s: enter aListener=%p\n", this, "EventSourceChangedEvent::getListener", aListener)); VirtualBoxBase::clearError(); HRESULT hrc; try { CheckComArgOutPointerValidThrow(aListener); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) throw autoCaller.rc(); hrc = getListener(ComTypeOutConverter<IEventListener>(aListener).ptr()); } catch (HRESULT hrc2) { hrc = hrc2; } catch (...) { hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS); } LogRelFlow(("{%p} %s: leave *aListener=%p hrc=%Rhrc\n", this, "EventSourceChangedEvent::getListener", *aListener, hrc)); return hrc; }
int Widget::countListeners(Event::Type type) { const EventListener *listener = getListener(type); if (listener) return listener->size(); return 0; }
// // 函数:close() // // 目的: 关闭一个窗口实例 // // 注释: // 通过YCUILayer中onMessage触发快捷键关闭 // 此时的调用为close(true) // 内部执行是检查是否有绑定的lua OnClose脚本 // 有则执行脚本,否则调用finalClose(false) // void YCIContainer::close() { ////////////////////////////////////////////// //窗口退出动画 ////////////////////////////////////////////// const char* onClose = getListener(UITAG_CLOSE_EVENT); if (onClose != NULL) { YCLua* lua = (YCLua*)YCRegistry::get("lua"); if (lua == NULL) { LOG_ERROR("YCIContainer::initialize查询YCLua环境失败,请确认注册YCLua!"); throw YCException(2002, "YCIContainer::initialize查询YCLua环境失败,请确认注册YCLua!"); } // 构建Lua上下文 YCLuaContext context; context.addContext("container", this); context.addContext("this", this); lua->execute(&context, onClose, myWindowName); } else { finalClose(); } }
namespace odfaeg { Listener& InputSystem::listener = getListener(); Listener& InputSystem::getListener() { if (&listener == nullptr) { Listener* lsn = new Listener(); return *lsn; } return listener; } }
void PianoGrid::addNote (PianoGridNote* note) { PianoGridListener* listener = getListener(); if (listener && listener->noteAdded (note->getNote(), note->getBeat (), note->getLength ())) { addAndMakeVisible (note); notes.add (note); selectedNotes.selectOnly (note); } }
void AutomationGrid::removeNote (AutomationEvent* note, const bool alsoFreeObject) { AutomationGridListener* listener = getListener(); if (listener && listener->eventRemoved (note->getController(), note->getValue(), note->getBeat ())) { selectedNotes.deselect (note); notes.removeObject (note, alsoFreeObject); repaint(); } }
void QblEvpStream::encrypt(const char *plain, const int length) { int outlength; unsigned char buffer[length + EVP_MAX_BLOCK_LENGTH]; EVP_EncryptUpdate(&this->encryptContext, buffer, &outlength, (unsigned char *)plain, length); if(outlength != 0) { std::vector<char> vect(buffer, buffer + length); getListener()->onData(vect); } }
void AutomationGrid::addNote (AutomationEvent* note) { AutomationGridListener* listener = getListener(); if (listener && listener->eventAdded (note->getController(), note->getValue(), note->getBeat ())) { addAndMakeVisible (note); notes.add (note); selectedNotes.selectOnly (note); } }
void QblEvpStream::finish() { int length; unsigned char buffer[EVP_MAX_BLOCK_LENGTH]; if(this->getMode() == QBL_CRYPTO_STREAM_ENCRYPT) { EVP_EncryptFinal_ex(&this->encryptContext, buffer, &length); if(length != 0) { std::vector<char> vect(buffer, buffer + length); getListener()->onData(vect); } } else { EVP_DecryptFinal_ex(&this->decryptContext, buffer, &length); if(length != 0) { std::vector<char> vect(buffer, buffer + length); getListener()->onData(vect); } } getListener()->onFinish(); }
CCUDPSocket* CCUDPSocketHub::createSocket(const string& hostname, int port, int tag, int blockSec) { CCUDPSocket* s = CCUDPSocket::create(hostname, port, tag, blockSec); if (s && addSocket(s)) { CCUDPSocketListener* l = getListener(tag); if(l) { l->onUDPSocketBound(tag); } } return s; }
CCTCPSocket* CCTCPSocketHub::createSocket(const string& hostname, int port, int tag, int blockSec, bool keepAlive) { CCTCPSocket* s = CCTCPSocket::create(hostname, port, tag, blockSec, keepAlive); if (s && addSocket(s) && s->isConnected()) { CCTCPSocketListener* l = getListener(tag); if(l) { l->onTCPSocketConnected(tag); } } return s; }
void AutomationGrid::moveEvent (AutomationEvent* note, const double beatNumber, const double newValue) { const double oldNote = note->getValue (); const double oldBeat = note->getBeat (); AutomationGridListener* listener = getListener(); if (listener && listener->eventMoved (note->getController(), oldNote, oldBeat, newValue, beatNumber)) { note->setValue (newValue); note->setBeat (beatNumber); } }
void CCUDPSocketHub::disconnect(int tag) { for(CCUDPSocketList::iterator iter = m_lstSocket.begin(); iter != m_lstSocket.end(); ++ iter) { if((*iter)->getTag() == tag) { (*iter)->destroy(); CCUDPSocketListener* l = getListener(tag); if(l) { l->onUDPSocketClosed(tag); } break; } } }
void PianoGrid::removeNote (PianoGridNote* note, const bool alsoFreeObject) { PianoGridListener* listener = getListener(); if (listener && listener->noteRemoved (note->getNote(), note->getBeat (), note->getLength ())) { selectedNotes.deselect (note); notes.removeObject (note, alsoFreeObject); } }
void PianoGrid::removeAllNotes (const bool notifyListeners) { selectedNotes.deselectAll (); notes.clear (true); if (notifyListeners) { PianoGridListener* listener = getListener(); if (listener) listener->allNotesRemoved (); } }
CCUDPSocketHub::~CCUDPSocketHub() { CCScheduler* s = CCDirector::sharedDirector()->getScheduler(); s->unscheduleUpdateForTarget(this); for (CCUDPSocketList::iterator iter = m_lstSocket.begin(); iter != m_lstSocket.end(); ++iter) { int tag = (*iter)->getTag(); CC_SAFE_RELEASE(*iter); CCUDPSocketListener* l = getListener(tag); if(l) { l->onUDPSocketClosed(tag); } } }
void ListenerSocketConnection::threadClientFunction( void *p_arg ) { // startup sockets SocketProtocol::initSocketLib(); // read messages readMessages(); SocketListener *listener = getListener(); listener -> removeListenerConnection( this ); // cleanup sockets SocketProtocol::exitSocketLib(); }
void AutomationGrid::removeAllEvents (const bool notifyListeners) { selectedNotes.deselectAll (); notes.clear (true); if (notifyListeners) { AutomationGridListener* listener = getListener(); if (listener) listener->allEventsRemoved (); } repaint(); }
void PianoGrid::resizeNote (PianoGridNote* note, const float beatNumber, const float newLength) { PianoGridListener* listener = getListener(); if (listener && listener->noteResized (note->getNote(), note->getBeat(), note->getLength())) { float minLength = 0.0001f; float maxLength = (numBars * divDenominator) - beatNumber; if (snapQuantize > 0) minLength = defaultNoteLength; note->setLength (jmin (jmax (newLength, minLength), maxLength)); } }
void GoogleStoreFront::makePayment(const char * productID, int quantity, const char * usernameHash) { android_app* app = __state; JNIEnv* env = app->activity->env; JavaVM* vm = app->activity->vm; vm->AttachCurrentThread(&env, NULL); jstring paramString = env->NewStringUTF(productID); while (quantity-- > 0) env->CallVoidMethod(app->activity->clazz, __midPurchaseItem, paramString); vm->DetachCurrentThread(); getListener()->paymentTransactionInProcessEvent(productID, quantity); }
void Widget::dispatchEvent(Event &evt) { if (!isEventTypeTracked(evt.getType())) return; propagateEvent(evt); if (evt.isConsumed()) return; const EventListener *listener = getListener(evt.getType()); if (listener == NULL) return; EventListener::const_iterator it; for (it = listener->begin(); it != listener->end(); it++) (**it)(evt); }
void PianoGrid::moveNote (PianoGridNote* note, const int newNote, const float newBeat) { const int oldNote = note->getNote (); const float oldBeat = note->getBeat (); PianoGridListener* listener = getListener(); if (listener && listener->noteMoved (oldNote, oldBeat, newNote, newBeat, note->getLength())) { note->setNote (newNote); float maxBeat = (numBars * divDenominator) - note->getLength(); note->setBeat (jmin (jmax (newBeat, 0.0f), maxBeat)); } }
void OpenALRenderableListener::updateImpl(int flags) throw(Exception) { if (flags & UPDATE_LOCATION) { const Vector3 pos(getListener()->getPosition()); // no option but to cast it down to float :( const Vector3 vel(getListener()->getVelocity()); const Vector3 at (getListener()->getAtDirection()); const Vector3 up (getListener()->getUpDirection()); ALfloat ori[] = { at.x, at.y, at.z, up.x, up.y, up.z }; alListener3f(AL_POSITION, pos.x, pos.y, pos.z); alListener3f(AL_VELOCITY, vel.x, vel.y, vel.z); alListenerfv(AL_ORIENTATION, ori); } if (flags & UPDATE_ATTRIBUTES) { alListenerf (AL_GAIN, getListener()->getGain()); } }
/** * @author JoSch * @date 03-16-2005 */ void ListenerObject::_update() { ActorControlledObject::_update(); ListenerMovable *listener = getListener(); Actor *actor = getActor(); if (!listener || !actor) // Einer ist Null { return; } listener->setPosition(actor->getPosition()); Vector3 *temp1 = new Vector3(); Vector3 *temp2 = new Vector3(actor->getPosition()); Real length = temp2->normalise(); actor->getOrientation().ToAxes(temp1); *temp1 += *temp2; *temp1 *= length; listener->setOrientation(*temp1, *temp1); // TODO Orientation korrigieren }
void CCUDPSocketHub::update(float delta) { for(CCUDPSocketList::iterator iter = m_lstSocket.begin(); iter != m_lstSocket.end(); ++ iter) { CCUDPSocket* pSocket = *iter; int tag = pSocket->getTag(); while (true) { int read = pSocket->receiveData(m_buffer, kCCSocketMaxPacketSize); if (read <= 0) break; CCByteBuffer packet; packet.write((uint8*)m_buffer, read); CCUDPSocketListener* l = getListener(tag); if(l) { l->onUDPSocketData(tag, packet); } } } }
/** * @author JoSch * @date 03-16-2005 */ void ListenerObject::_update() { ActorControlledObject::_update(); ListenerMovable *listener = getListener(); Actor *actor = getActor(); if (!listener || !actor) // Einer ist Null { LOG_DEBUG(Logger::CORE, "Pos Listener: NULL!"); return; } listener->setPosition(actor->getWorldPosition()); listener->setOrientation(actor->getWorldOrientation()); listener->setVelocity(actor->getVelocity()); LOG_DEBUG(Logger::CORE, "Pos Listener: " + StringConverter::toString(actor->getWorldPosition().x) + " " + StringConverter::toString(actor->getWorldPosition().y) + " " + StringConverter::toString(actor->getWorldPosition().z) + ", " + "Orient Listener: " + StringConverter::toString(actor->getWorldOrientation().w) + " " + StringConverter::toString(actor->getWorldOrientation().x) + " " + StringConverter::toString(actor->getWorldOrientation().y) + ", " + StringConverter::toString(actor->getWorldOrientation().z)); }
OITRenderComponent::OITRenderComponent (RenderWindow& window, int layer, std::string expression) : HeavyComponent(window, math::Vec3f(window.getView().getPosition().x, window.getView().getPosition().y, layer), math::Vec3f(window.getView().getSize().x, window.getView().getSize().y, 0), math::Vec3f(window.getView().getSize().x + window.getView().getSize().x * 0.5f, window.getView().getPosition().y + window.getView().getSize().y * 0.5f, layer)), view(window.getView()), expression(expression) { update = false; sf::Vector3i resolution ((int) window.getSize().x, (int) window.getSize().y, window.getView().getSize().z); depthBuffer = std::make_unique<RenderTexture>(); frameBuffer = std::make_unique<RenderTexture>(); specularTexture = std::make_unique<RenderTexture>(); bumpTexture = std::make_unique<RenderTexture>(); refractionTexture = std::make_unique<RenderTexture>(); depthBuffer->create(resolution.x, resolution.y,window.getSettings()); frameBuffer->create(resolution.x, resolution.y,window.getSettings()); specularTexture->create(resolution.x, resolution.y,window.getSettings()); bumpTexture->create(resolution.x, resolution.y,window.getSettings()); refractionTexture->create(resolution.x, resolution.y,window.getSettings()); frameBuffer->setView(window.getView()); depthBuffer->setView(window.getView()); specularTexture->setView(window.getView()); bumpTexture->setView(window.getView()); refractionTexture->setView(window.getView()); frameBuffer->clear(sf::Color::Transparent); depthBuffer->clear(sf::Color::Transparent); specularTexture->clear(sf::Color::Transparent); bumpTexture->clear(sf::Color::Transparent); frameBufferTile = std::make_unique<Tile>(&frameBuffer->getTexture(), math::Vec3f(0, 0, 0), math::Vec3f(window.getView().getSize().x, window.getView().getSize().y, 0), IntRect(0, 0, window.getView().getSize().x, window.getView().getSize().y)); depthBufferTile = std::make_unique<Tile>(&depthBuffer->getTexture(), math::Vec3f(0, 0, 0), math::Vec3f(window.getView().getSize().x, window.getView().getSize().y, 0), IntRect(0, 0, window.getView().getSize().x, window.getView().getSize().y)); if (Shader::isAvailable()) { frameBufferGenerator = std::make_unique<Shader>(); depthBufferGenerator = std::make_unique<Shader>(); specularTextureGenerator = std::make_unique<Shader>(); bumpTextureGenerator = std::make_unique<Shader>(); refractionTextureGenerator = std::make_unique<Shader>(); simpleShader = std::make_unique<Shader>(); const std::string vertexShader = "#version 130 \n" "out mat4 projMat;" "void main () {" "gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;" "gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;" "gl_FrontColor = gl_Color;" "projMat = gl_ProjectionMatrix;" "}"; const std::string specularGenFragShader = "#version 130 \n" "uniform sampler2D specularTexture;" "uniform sampler2D texture;" "uniform vec3 resolution;" "uniform float maxM;" "uniform float maxP;" "uniform float m;" "uniform float p;" "uniform float haveTexture;" "in mat4 projMat;" "void main() {" "vec2 position = ( gl_FragCoord.xy / resolution.xy );" "vec4 color = texture2D(specularTexture, position);" "vec4 pixel = (haveTexture==1) ? gl_Color * texture2D(texture, gl_TexCoord[0].xy) : gl_Color;" "float z = (gl_FragCoord.w != 1.f) ? (inverse(projMat) * vec4(0, 0, 0, gl_FragCoord.w)).w : gl_FragCoord.z;" "if(z >= color.z && pixel.a >= color.a) {" "float intensity = (maxM != 0.f) ? m / maxM : 0.f;" "float power = (maxP != 0.f) ? p / maxP : 0.f;" "gl_FragColor = vec4(intensity, power, z, pixel.a);" "} else {" "gl_FragColor = color;" "}" "}"; const std::string depthGenFragShader = "#version 130 \n" "uniform sampler2D depthBuffer;" "uniform sampler2D texture;" "uniform vec3 resolution;" "uniform float haveTexture;" "in mat4 projMat;" "void main () {" "vec2 position = ( gl_FragCoord.xy / resolution.xy );" "vec4 previous_depth_alpha = texture2D(depthBuffer, position);" "vec4 texel = texture2D(texture, gl_TexCoord[0].xy);" "vec4 colors[2];" "colors[1] = texel * gl_Color;" "colors[0] = gl_Color;" "bool b = (haveTexture == 1);" "float current_alpha = colors[int(b)].a;" "float current_depth = (gl_FragCoord.w != 1.f) ? (inverse(projMat) * vec4(0, 0, 0, gl_FragCoord.w)).w : gl_FragCoord.z;" "colors[1] = vec4(current_depth, current_alpha, current_depth, current_alpha);" "colors[0] = vec4(current_depth, current_alpha, previous_depth_alpha.z, previous_depth_alpha.a);" "b = (current_depth >= previous_depth_alpha.z && current_alpha != 0);" "gl_FragColor = colors[int(b)];" "}"; const std::string frameBufferGenFragShader = "#version 130 \n" "uniform sampler2D depthBuffer;" "uniform sampler2D frameBuffer;" "uniform sampler2D texture;" "uniform vec3 resolution;" "uniform float haveTexture;" "in mat4 projMat;" "void main () {" "vec2 position = ( gl_FragCoord.xy / resolution.xy );" "vec4 previous_depth_alpha = texture2D(depthBuffer, position);" "vec4 previous_color = texture2D(frameBuffer, position);" "vec4 texel = texture2D(texture, gl_TexCoord[0].xy);" "vec4 colors[2];" "colors[1] = texel * gl_Color;" "colors[0] = gl_Color;" "bool b = (haveTexture == 1);" "vec4 current_color = colors[int(b)];" "float current_depth = (gl_FragCoord.w != 1.f) ? (inverse(projMat) * vec4(0, 0, 0, gl_FragCoord.w)).w : gl_FragCoord.z;" "colors[1] = current_color * current_color.a + previous_color * (1 - current_color.a);" "colors[1].a = current_color.a + previous_color.a * (1 - current_color.a);" "colors[0] = previous_color * previous_depth_alpha.a + current_color * (1 - previous_depth_alpha.a);" "colors[0].a = previous_color.a + current_color.a * (1 - previous_color.a);" "b = (current_depth >= previous_depth_alpha.z);" "gl_FragColor = colors[int(b)];" "}"; const std::string bumpGenFragShader = "#version 130 \n" "uniform sampler2D bumpTexture;" "uniform sampler2D texture;" "uniform vec3 resolution;" "uniform float haveTexture;" "in mat4 projMat;" "void main() {" "vec2 position = ( gl_FragCoord.xy / resolution.xy );" "vec4 bump1 = texture2D(bumpTexture, position);" "vec4 bump2 = (haveTexture==1) ? texture2D(texture, gl_TexCoord[0].xy) : vec4(0, 0, 0, 0);" "float z = (gl_FragCoord.w != 1.f) ? (inverse(projMat) * vec4(0, 0, 0, gl_FragCoord.w)).w : gl_FragCoord.z;" "if (z >= bump1.a) {" "gl_FragColor = vec4(bump2.xyz, z);" "} else {" "gl_FragColor = bump1;" "}" "}"; const std::string refractionGenFragShader = "#version 130 \n" "uniform sampler2D refractionTexture;" "uniform vec3 resolution;" "uniform float refractionFactor;" "in mat4 projMat;" "void main() {" "vec2 position = ( gl_FragCoord.xy / resolution.xy );" "vec4 refraction = texture2D(refractionTexture, position);" "float z = (gl_FragCoord.w != 1.f) ? (inverse(projMat) * vec4(0, 0, 0, gl_FragCoord.w)).w : gl_FragCoord.z;" "if (z >= refraction.a) {" "gl_FragColor = vec4(refractionFactor, 0, z, 0);" "} else {" "gl_FragColor = refraction;" "}" "}"; if (!depthBufferGenerator->loadFromMemory(vertexShader, depthGenFragShader)) throw core::Erreur(50, "Failed to load depth buffer generator shader", 0); if (!frameBufferGenerator->loadFromMemory(vertexShader, frameBufferGenFragShader)) throw core::Erreur(51, "Failed to load frame buffer generator shader", 0); if (!specularTextureGenerator->loadFromMemory(vertexShader, specularGenFragShader)) throw core::Erreur(52, "Failed to load specular texture generator shader", 0); if (!bumpTextureGenerator->loadFromMemory(vertexShader, bumpGenFragShader)) throw core::Erreur(53, "Failed to load bump texture generator shader", 0); if (!refractionTextureGenerator->loadFromMemory(vertexShader, refractionGenFragShader)) throw core::Erreur(54, "Failed to load refraction texture generator shader", 0); frameBufferGenerator->setParameter("resolution",resolution.x, resolution.y, resolution.z); frameBufferGenerator->setParameter("depthBuffer", depthBuffer->getTexture()); frameBufferGenerator->setParameter("frameBuffer", frameBuffer->getTexture()); frameBufferGenerator->setParameter("texture", Shader::CurrentTexture); depthBufferGenerator->setParameter("resolution",resolution.x, resolution.y, resolution.z); depthBufferGenerator->setParameter("depthBuffer", depthBuffer->getTexture()); depthBufferGenerator->setParameter("texture", Shader::CurrentTexture); specularTextureGenerator->setParameter("resolution",resolution.x, resolution.y, resolution.z); specularTextureGenerator->setParameter("specularTexture",specularTexture->getTexture()); specularTextureGenerator->setParameter("texture",Shader::CurrentTexture); specularTextureGenerator->setParameter("maxM", Material::getMaxSpecularIntensity()); specularTextureGenerator->setParameter("maxP", Material::getMaxSpecularPower()); bumpTextureGenerator->setParameter("resolution",resolution.x, resolution.y, resolution.z); bumpTextureGenerator->setParameter("bumpTexture",bumpTexture->getTexture()); bumpTextureGenerator->setParameter("texture",Shader::CurrentTexture); refractionTextureGenerator->setParameter("resolution",resolution.x, resolution.y, resolution.z); refractionTextureGenerator->setParameter("bumpTexture",bumpTexture->getTexture()); core::FastDelegate<bool> signal (&OITRenderComponent::needToUpdate, this); core::FastDelegate<void> slot (&OITRenderComponent::drawNextFrame, this); core::Command cmd(signal, slot); getListener().connect("UPDATE", cmd); backgroundColor = sf::Color::Transparent; } else { throw core::Erreur(55, "Shader not supported!", 0); } }
void OITRenderComponent::pushEvent(sf::Event event) { getListener().pushEvent(event); }