StratifiedSampler() : Sampler(Properties()) { }
void Server::_initialize() { Log::info("Initialazing the server", "Server", "_initialize"); // Sets the current path of the application to the path of the executable QDir::setCurrent(QCoreApplication::applicationDirPath()); // Seeds the random number generator LightBird::srand(); // Then the configuration is loaded Log::info("Loading the server configuration", "Server", "_initialize"); if (!*(this->configurations = new Configurations(this->arguments.getConfiguration(), this))) return Log::fatal("Failed to load the server configuration", "Server", "_initialize"); Log::instance()->setState(Log::CONFIGURATION); // Tells Qt where are its plugins QCoreApplication::addLibraryPath(Configurations::c().QtPluginsPath); // The threads manager must be initialized just after the configuration Log::info("Loading the thread manager", "Server", "_initialize"); this->threads = new Threads(this); // Loads the thread pool Log::info("Loading the thread pool", "Server", "_initialize"); this->threadPool = new ThreadPool(this); // Loads the translator Log::info("Loading the translation", "Server", "_initialize"); if (!this->_loadTranslation(Configurations::c().languagesPath + "/", ":languages/")) Log::error("Unable to load the translation of the server", "Server", "_initialize"); // Creates the file path if it does not exist QString filesPath = Configurations::c().filesPath; if (!QFileInfo(filesPath).isDir() && !QDir().mkpath(filesPath)) return Log::fatal("Failed to create the files path", Properties("filesPath", filesPath), "Server", "_initialize"); // Creates the temporary directory if (!this->_temporaryDirectory()) return Log::fatal("Failed to manage the temporary directory", "Server", "_initialize"); // Loads the database Log::info("Loading the database", "Server", "_initialize"); if (!*(this->database = new Database(this))) return Log::fatal("Failed to load the database", "Server", "_initialize"); // Loads the events system this->events = new Events(this); // Loads the plugins manager and some APIs Log::info("Loading the plugins manager", "Server", "_initialize"); this->plugins = new Plugins(); this->apiGuis = new ApiGuis(this); this->apiPlugins = new ApiPlugins(this); this->apiSessions = new ApiSessions(this); this->extensions = new Extensions(this); // Loads the library Log::info("Loading the LightBird library", "Server", "_initialize"); LightBird::Library::initialize(); // Loads the network Log::info("Loading the network", "Server", "_initialize"); if (!*(this->network = new Network(this))) return Log::fatal("Failed to load the network", "Server", "_initialize"); this->_loadNetwork(); // Loads the plugins Log::info("Loading the plugins", "Server", "_initialize"); this->_loadPlugins(); // The logs are now fully initialized Log::info("Loading the logs", "Server", "_initialize"); Log::instance()->setState(Log::PLUGIN); Log::info("Server initialized", "Server", "_initialize"); Events::instance()->send("server_started"); this->isInitialized(); }
HammersleySampler() : Sampler(Properties()) { }
bool preprocess(const Scene *scene, RenderQueue *queue, const RenderJob *job, int sceneResID, int sensorResID, int samplerResID) { SamplingIntegrator::preprocess(scene, queue, job, sceneResID, sensorResID, samplerResID); /* Create a deterministic sampler for the photon gathering step */ ref<Scheduler> sched = Scheduler::getInstance(); ref<Sampler> sampler = static_cast<Sampler *> (PluginManager::getInstance()-> createObject(MTS_CLASS(Sampler), Properties("halton"))); /* Create a sampler instance for every core */ std::vector<SerializableObject *> samplers(sched->getCoreCount()); for (size_t i=0; i<sched->getCoreCount(); ++i) { ref<Sampler> clonedSampler = sampler->clone(); clonedSampler->incRef(); samplers[i] = clonedSampler.get(); } int qmcSamplerID = sched->registerMultiResource(samplers); for (size_t i=0; i<samplers.size(); ++i) samplers[i]->decRef(); const ref_vector<Medium> &media = scene->getMedia(); for (ref_vector<Medium>::const_iterator it = media.begin(); it != media.end(); ++it) { if (!(*it)->isHomogeneous()) Log(EError, "Inhomogeneous media are currently not supported by the photon mapper!"); } if (m_globalPhotonMap.get() == NULL && m_globalPhotons > 0) { /* Generate the global photon map */ ref<GatherPhotonProcess> proc = new GatherPhotonProcess( GatherPhotonProcess::ESurfacePhotons, m_globalPhotons, m_granularity, m_maxDepth-1, m_rrDepth, m_gatherLocally, m_autoCancelGathering, job); proc->bindResource("scene", sceneResID); proc->bindResource("sensor", sensorResID); proc->bindResource("sampler", qmcSamplerID); m_proc = proc; sched->schedule(proc); sched->wait(proc); m_proc = NULL; if (proc->getReturnStatus() != ParallelProcess::ESuccess) return false; ref<PhotonMap> globalPhotonMap = proc->getPhotonMap(); if (globalPhotonMap->isFull()) { Log(EDebug, "Global photon map full. Shot " SIZE_T_FMT " particles, excess photons due to parallelism: " SIZE_T_FMT, proc->getShotParticles(), proc->getExcessPhotons()); m_globalPhotonMap = globalPhotonMap; m_globalPhotonMap->setScaleFactor(1 / (Float) proc->getShotParticles()); m_globalPhotonMap->build(); m_globalPhotonMapID = sched->registerResource(m_globalPhotonMap); } } if (m_causticPhotonMap.get() == NULL && m_causticPhotons > 0) { /* Generate the caustic photon map */ ref<GatherPhotonProcess> proc = new GatherPhotonProcess( GatherPhotonProcess::ECausticPhotons, m_causticPhotons, m_granularity, m_maxDepth-1, m_rrDepth, m_gatherLocally, m_autoCancelGathering, job); proc->bindResource("scene", sceneResID); proc->bindResource("sensor", sensorResID); proc->bindResource("sampler", qmcSamplerID); m_proc = proc; sched->schedule(proc); sched->wait(proc); m_proc = NULL; if (proc->getReturnStatus() != ParallelProcess::ESuccess) return false; ref<PhotonMap> causticPhotonMap = proc->getPhotonMap(); if (causticPhotonMap->isFull()) { Log(EDebug, "Caustic photon map full. Shot " SIZE_T_FMT " particles, excess photons due to parallelism: " SIZE_T_FMT, proc->getShotParticles(), proc->getExcessPhotons()); m_causticPhotonMap = causticPhotonMap; m_causticPhotonMap->setScaleFactor(1 / (Float) proc->getShotParticles()); m_causticPhotonMap->build(); m_causticPhotonMapID = sched->registerResource(m_causticPhotonMap); } } size_t volumePhotons = scene->getMedia().size() == 0 ? 0 : m_volumePhotons; if (m_volumePhotonMap.get() == NULL && volumePhotons > 0) { /* Generate the volume photon map */ ref<GatherPhotonProcess> proc = new GatherPhotonProcess( GatherPhotonProcess::EVolumePhotons, volumePhotons, m_granularity, m_maxDepth-1, m_rrDepth, m_gatherLocally, m_autoCancelGathering, job); proc->bindResource("scene", sceneResID); proc->bindResource("sensor", sensorResID); proc->bindResource("sampler", qmcSamplerID); m_proc = proc; sched->schedule(proc); sched->wait(proc); m_proc = NULL; if (proc->getReturnStatus() != ParallelProcess::ESuccess) return false; ref<PhotonMap> volumePhotonMap = proc->getPhotonMap(); if (volumePhotonMap->isFull()) { Log(EDebug, "Volume photon map full. Shot " SIZE_T_FMT " particles, excess photons due to parallelism: " SIZE_T_FMT, proc->getShotParticles(), proc->getExcessPhotons()); volumePhotonMap->setScaleFactor(1 / (Float) proc->getShotParticles()); volumePhotonMap->build(); m_bre = new BeamRadianceEstimator(volumePhotonMap, m_volumeLookupSize); m_breID = sched->registerResource(m_bre); } } /* Adapt to scene extents */ m_globalLookupRadius = m_globalLookupRadiusRel * scene->getBSphere().radius; m_causticLookupRadius = m_causticLookupRadiusRel * scene->getBSphere().radius; sched->unregisterResource(qmcSamplerID); return true; }
SocketTcpWindows::SocketTcpWindows(const QHostAddress &peerAddress, quint16 peerPort) : SocketTcp(peerAddress, peerPort, 0, INVALID_SOCKET) , _events(&_noEvents) , _disableWriteBuffer(true) { _socket = INVALID_SOCKET; _connected = false; // Resolves the peer address and port QByteArray address(_peerAddress.toString().toLatin1()); QByteArray port = QByteArray::number(_peerPort); int addrinfoResult; struct addrinfo *addrInfo = NULL, hints; ZeroMemory(&hints, sizeof (hints)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; if ((addrinfoResult = getaddrinfo(address, port.data(), &hints, &addrInfo))) { LOG_ERROR("Unable to connect to the client: getaddrinfo failed", Properties("error", addrinfoResult).add("peerPort", port).add("peerAddress", address), "SocketTcpWindows", "SocketTcpWindows"); return ; } // Creates the socket _socket = _descriptor = socket(addrInfo->ai_family, addrInfo->ai_socktype, addrInfo->ai_protocol); if (_socket == INVALID_SOCKET) { LOG_ERROR("Unable to connect to the client: socket() failed", Properties("error", WSAGetLastError()).add("peerPort", port).add("peerAddress", address), "SocketTcpWindows", "SocketTcpWindows"); freeaddrinfo(addrInfo); return ; } // Disables the write buffer int sndbuff = 0; if (_disableWriteBuffer && setsockopt(_socket, SOL_SOCKET, SO_SNDBUF, (char *)&sndbuff, sizeof(sndbuff)) == SOCKET_ERROR) { LOG_ERROR("Client setsockopt SO_SNDBUF failed", Properties("error", WSAGetLastError()), "SocketTcpWindows", "SocketTcpWindows"); return ; } // Non blocking mode u_long nonBlockingMode = 1; if ((ioctlsocket(_socket, FIONBIO, &nonBlockingMode)) == SOCKET_ERROR) { LOG_DEBUG("Failed to set the socket in non blocking mode", Properties("error", WSAGetLastError()).add("peerPort", port).add("peerAddress", address).add("socket", _socket), "SocketTcpWindows", "SocketTcpWindows"); freeaddrinfo(addrInfo); _close(); return ; } // Starts the connection to the server ::connect(_socket, addrInfo->ai_addr, (int)addrInfo->ai_addrlen); _connecting = true; freeaddrinfo(addrInfo); // Gets the local port of the socket sockaddr_in6 addr; int addrlen = sizeof(addr); if (getsockname(_socket, (struct sockaddr *)&addr, &addrlen) != SOCKET_ERROR) { if (addrlen == sizeof(addr) && addr.sin6_family == AF_INET6) _localPort = ntohs(addr.sin6_port); else if (addrlen == sizeof(sockaddr_in) && ((sockaddr_in*)&addr)->sin_family == AF_INET) _localPort = ntohs(((sockaddr_in*)&addr)->sin_port); } if (_localPort == 0) LOG_ERROR("Unable to get the local port of the socket: getsockname() failed", Properties("error", WSAGetLastError()).add("peerPort", port).add("peerAddress", address), "SocketTcpWindows", "SocketTcpWindows"); }
CoreSolver::CoreSolver() : mProperties(Properties()) { }
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "buttons.h" #include <QtGui> static const Properties buttonTextProperties = Properties() << Property("text", "Example Text"); const PreviewWidget buttonWidgets[] = { { "QPushButton", WidgetCreator<QPushButton>::createWidget, &buttonTextProperties }, { "QToolButton", WidgetCreator<QToolButton>::createWidget, &buttonTextProperties }, { "QRadioButton", WidgetCreator<QRadioButton>::createWidget, &buttonTextProperties }, { "QCheckBox", WidgetCreator<QCheckBox>::createWidget, &buttonTextProperties }, { "QCommandLinkButton", WidgetCreator<QCommandLinkButton>::createWidget, &buttonTextProperties }, { 0, 0, 0 } };
void Body::SetLabel(const std::string &label) { m_label = label; Properties().Set("label", label); }
/** * @brief PoissonDiscSampler */ PoissonDiscSampler() : Sampler(Properties()) {}
void cairo::JSSurface::addClassProperties(JSContext * cx, JSObject * theClassProto) { JSA_AddFunctions(cx, theClassProto, Functions()); JSA_AddProperties(cx, theClassProto, Properties()); createClassModuleDocumentation("Cairo", ClassName(), Properties(), Functions(), 0, 0, 0); }
SobolSampler() : Sampler(Properties()) { }
void Missile::Disarm() { m_armed = false; Properties().Set("isArmed", false); }
void Missile::Arm() { m_armed = true; Properties().Set("isArmed", true); }
QPCSCReader::QPCSCReader( const QString &reader, QPCSC *parent ) : QObject( parent ) , d( new QPCSCReaderPrivate( parent->d ) ) { d->reader = reader.toUtf8(); d->state.szReader = d->reader.constData(); if( !d->updateState() ) return; /* Use DIRECT mode only if there is no card in the reader */ if( !isPresent() ) { #ifndef Q_OS_WIN /* Apple 10.5.7 and pcsc-lite previous to v1.5.5 do not support 0 as protocol identifier */ DWORD proto = SCARD_PROTOCOL_T0|SCARD_PROTOCOL_T1; #else DWORD proto = 0; #endif LONG rv = SCardConnect( d->d->context, d->state.szReader, SCARD_SHARE_DIRECT, proto, &d->card, &d->proto ); // Assume that there is a card in the reader in shared mode if direct communcation failed if( rv == LONG(SCARD_E_SHARING_VIOLATION) && !connect() ) return; } else if( !connect() ) return; d->friendlyName = d->attrib( SCARD_ATTR_DEVICE_FRIENDLY_NAME_A ); #if 0 qDebug() << "SCARD_ATTR_DEVICE_FRIENDLY_NAME:" << d->attrib( SCARD_ATTR_DEVICE_FRIENDLY_NAME_A ); qDebug() << "SCARD_ATTR_DEVICE_SYSTEM_NAME:" << d->attrib( SCARD_ATTR_DEVICE_SYSTEM_NAME_A ); qDebug() << "SCARD_ATTR_DEVICE_UNIT:" << d->attrib( SCARD_ATTR_DEVICE_UNIT ); qDebug() << "SCARD_ATTR_VENDOR_IFD_SERIAL_NO:" << d->attrib( SCARD_ATTR_VENDOR_IFD_SERIAL_NO ); qDebug() << "SCARD_ATTR_VENDOR_IFD_TYPE:" << d->attrib( SCARD_ATTR_VENDOR_IFD_TYPE ); qDebug() << "SCARD_ATTR_VENDOR_IFD_VERSION:" << d->attrib( SCARD_ATTR_VENDOR_IFD_VERSION ); qDebug() << "SCARD_ATTR_VENDOR_NAME:" << d->attrib( SCARD_ATTR_VENDOR_NAME ); #endif DWORD size = 0; BYTE feature[256]; LONG rv = SCardControl( d->card, CM_IOCTL_GET_FEATURE_REQUEST, 0, 0, feature, sizeof(feature), &size ); if( rv == SCARD_S_SUCCESS && (size % sizeof(PCSC_TLV_STRUCTURE)) == 0 ) { size /= sizeof(PCSC_TLV_STRUCTURE); PCSC_TLV_STRUCTURE *pcsc_tlv = (PCSC_TLV_STRUCTURE *)feature; for( DWORD i = 0; i < size; i++ ) d->ioctl[DRIVER_FEATURES(pcsc_tlv[i].tag)] = ntohl( pcsc_tlv[i].value ); } if( DWORD ioctl = d->ioctl.value(FEATURE_GET_TLV_PROPERTIES) ) { DWORD size = 0; BYTE recv[256]; rv = SCardControl( d->card, ioctl, 0, 0, recv, sizeof(recv), &size ); unsigned char *p = recv; while( DWORD(p-recv) < size ) { int tag = *p++, len = *p++, value = -1; switch( len ) { case 1: value = *p; break; case 2: value = *p + (*(p+1)<<8); break; case 4: value = *p + (*(p+1)<<8) + (*(p+2)<<16) + (*(p+3)<<24); break; default: break; } p += len; d->properties[Properties(tag)] = value; } } if( DWORD ioctl = d->ioctl.value(FEATURE_IFD_PIN_PROPERTIES) ) { DWORD size = 0; BYTE recv[256]; DWORD rv = SCardControl( d->card, ioctl, 0, 0, recv, sizeof(recv), &size ); if( rv == SCARD_S_SUCCESS ) { PIN_PROPERTIES_STRUCTURE *caps = (PIN_PROPERTIES_STRUCTURE *)recv; d->display = caps->wLcdLayout > 0; } } disconnect(); }
//============================================================================== PlanarJoint::Properties PlanarJoint::getPlanarJointProperties() const { return Properties(getMultiDofJointProperties(), getPlanarJointAddon()->getProperties()); }
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "input.h" #include <QtGui> extern const char lotsOfText[]; static const Properties editableProperties = Properties() << Property("editable", true); static const Properties passwordEcho = Properties() << Property("echoMode", QLineEdit::PasswordEchoOnEdit); static const Properties plainTextProperties = Properties() << Property("plainText", QLatin1String(lotsOfText)); static const Properties valueProperties = Properties() << Property("value", 42); static const Properties doubleProperties = Properties() << Property("value", 42.42); static const Properties sliderProperties = Properties()
//============================================================================== RevoluteJoint::Properties RevoluteJoint::getRevoluteJointProperties() const { return Properties(getGenericJointProperties(), mAspectProperties); }
bool render(Scene *scene, RenderQueue *queue, const RenderJob *job, int sceneResID, int cameraResID, int samplerResID) { ref<Scheduler> sched = Scheduler::getInstance(); ref<Camera> camera = scene->getCamera(); ref<Film> film = camera->getFilm(); size_t nCores = sched->getCoreCount(); Sampler *cameraSampler = (Sampler *) sched->getResource(samplerResID, 0); size_t sampleCount = cameraSampler->getSampleCount(); Log(EInfo, "Starting render job (%ix%i, " SIZE_T_FMT " %s, " SIZE_T_FMT " %s, " SSE_STR ") ..", film->getCropSize().x, film->getCropSize().y, sampleCount, sampleCount == 1 ? "sample" : "samples", nCores, nCores == 1 ? "core" : "cores"); Vector2i cropSize = film->getCropSize(); Point2i cropOffset = film->getCropOffset(); m_gatherPoints.clear(); m_running = true; for (size_t i=0; i<m_blocks.size(); ++i) m_blocks[i]->decRef(); m_blocks.clear(); m_totalEmitted = 0; bool needsLensSample = camera->needsLensSample(); bool needsTimeSample = camera->needsTimeSample(); Log(EInfo, "Creating approximately %i gather points", cropSize.x*cropSize.y*sampleCount); Point2 lensSample, sample; RayDifferential eyeRay; Float timeSample = 0; m_filter = camera->getFilm()->getTabulatedFilter(); Vector2 filterSize = m_filter->getFilterSize(); int borderSize = (int) std::ceil(std::max(filterSize.x, filterSize.y)); ref<Sampler> independentSampler = static_cast<Sampler *> (PluginManager::getInstance()-> createObject(MTS_CLASS(Sampler), Properties("independent"))); /* Create a sampler instance for every core */ std::vector<SerializableObject *> samplers(sched->getCoreCount()); for (size_t i=0; i<sched->getCoreCount(); ++i) { ref<Sampler> clonedSampler = independentSampler->clone(); clonedSampler->incRef(); samplers[i] = clonedSampler.get(); } int independentSamplerResID = sched->registerManifoldResource(samplers); for (size_t i=0; i<sched->getCoreCount(); ++i) samplers[i]->decRef(); #ifdef MTS_DEBUG_FP enableFPExceptions(); #endif /* Create gather points in blocks so that gathering can be parallelized later on */ for (int yofs=0; yofs<cropSize.y; yofs += m_blockSize) { for (int xofs=0; xofs<cropSize.x; xofs += m_blockSize) { ImageBlock *block = new ImageBlock(Vector2i(m_blockSize, m_blockSize), borderSize, true, true, false, false); block->setSize(Vector2i(m_blockSize, m_blockSize)); block->setOffset(Point2i(cropOffset.x + xofs, cropOffset.y + yofs)); block->incRef(); std::vector<GatherPoint> gatherPoints; gatherPoints.reserve(m_blockSize*m_blockSize*sampleCount); for (int yofsInt = 0; yofsInt < m_blockSize; ++yofsInt) { if (yofsInt + yofs >= cropSize.y) continue; for (int xofsInt = 0; xofsInt < m_blockSize; ++xofsInt) { if (xofsInt + xofs >= cropSize.x) continue; int y = cropOffset.y + yofs + yofsInt; int x = cropOffset.x + xofs + xofsInt; cameraSampler->generate(); for (size_t j = 0; j<sampleCount; j++) { if (needsLensSample) lensSample = cameraSampler->next2D(); if (needsTimeSample) timeSample = cameraSampler->next1D(); sample = cameraSampler->next2D(); sample.x += x; sample.y += y; camera->generateRayDifferential(sample, lensSample, timeSample, eyeRay); size_t offset = gatherPoints.size(); Float count = (Float) createGatherPoints(scene, eyeRay, sample, cameraSampler, Spectrum(1.0f), gatherPoints, 1); if (count > 1) { // necessary because of filter weight computation for (int i = 0; i<count; ++i) gatherPoints[offset+i].weight *= count; } cameraSampler->advance(); } } } m_blocks.push_back(block); m_gatherPoints.push_back(gatherPoints); } } int it=0; while (m_running) photonMapPass(++it, queue, job, film, sceneResID, cameraResID, independentSamplerResID); #ifdef MTS_DEBUG_FP disableFPExceptions(); #endif sched->unregisterResource(independentSamplerResID); return true; }