Point* LineString::getPointN(size_t n) const { assert(getFactory()); assert(points.get()); return getFactory()->createPoint(points->getAt(n)); }
void DownloadFileTransferAPI::start() { FBLOG_DEBUG("DownloadFileTransferAPI::start", "this=" << this); mFileStr = getFactory()->getFileManager()->uriToFile(mTargetUri); if(mFileStr.empty()) { FBLOG_DEBUG("DownloadFileTransferAPI::start", "Invalid target path"); onError("Invalid target path"); return; } FBLOG_DEBUG("DownloadFileTransferAPI::start", "targetFile=" << mFileStr); mFilePath = boost::filesystem::path(mFileStr); if(boost::filesystem::exists(mFilePath)) { FBLOG_DEBUG("DownloadFileTransferAPI::start", "The path target \"" << mFileStr << "\" already exists"); onError("The target path already exist"); return; } // Create the request FB::BrowserStreamRequest req(mSourceUri, "GET"); req.setCallback(boost::bind(&DownloadFileTransferAPI::callbackFct, this, _1, _2, _3, _4)); // Start transfer FB::BrowserHostPtr host = getFactory()->getPlugin()->getHost(); try { mHelper = FileStreamHelper::AsyncRequest(host, req); } catch(std::runtime_error&) { FBLOG_DEBUG("DownloadFileTransferAPI::start", "Internal error"); onError("Internal error"); } }
Geometry* MultiPolygon::getBoundary() const { if (isEmpty()) { return getFactory()->createMultiLineString(); } vector<Geometry *>* allRings=new vector<Geometry *>(); for (size_t i = 0; i < geometries->size(); i++) { Polygon *pg=dynamic_cast<Polygon *>((*geometries)[i]); assert(pg); Geometry *g=pg->getBoundary(); if ( LineString *ls=dynamic_cast<LineString *>(g) ) { allRings->push_back(ls); } else { GeometryCollection* rings=dynamic_cast<GeometryCollection*>(g); for (size_t j=0, jn=rings->getNumGeometries(); j<jn; ++j) { //allRings->push_back(new LineString(*(LineString*)rings->getGeometryN(j))); allRings->push_back(rings->getGeometryN(j)->clone()); } delete g; } } Geometry *ret=getFactory()->createMultiLineString(allRings); //for (int i=0; i<allRings->size(); i++) delete (*allRings)[i]; //delete allRings; return ret; }
CoordinateSequence* Polygon::getCoordinates() const { if (isEmpty()) { return getFactory()->getCoordinateSequenceFactory()->create(); } vector<Coordinate> *cl = new vector<Coordinate>; // reserve space in the vector for all the polygon points cl->reserve(getNumPoints()); // Add shell points const CoordinateSequence* shellCoords=shell->getCoordinatesRO(); shellCoords->toVector(*cl); // Add holes points size_t nholes=holes->size(); for (size_t i=0; i<nholes; ++i) { const LinearRing* lr = dynamic_cast<const LinearRing *>((*holes)[i]); const CoordinateSequence* childCoords = lr->getCoordinatesRO(); childCoords->toVector(*cl); } return getFactory()->getCoordinateSequenceFactory()->create(cl); }
void Application::onRelease() { ScriptUnregisterFunction( TWindowManager::GetInstance()->GetScript(), "addGame" ); ScriptUnregisterFunction( TWindowManager::GetInstance()->GetScript(), "addLevel" ); ScriptUnregisterFunction( TWindowManager::GetInstance()->GetScript(), "addActor" ); releaseLuaFunction( 0 ); releaseLuaFunction( 1 ); getFactory()->release(); Factory* factory( getFactory() ); setFactory( 0 ); delete factory; Game* game = begin(); while(game) { if ( game->isInited() ) { game->release(); } game=getNextEntity(); } removeAllEntity(); }
/*public*/ Geometry* Polygon::getBoundary() const { /* * We will make sure that what we * return is composed of LineString, * not LinearRings */ const GeometryFactory* gf = getFactory(); if (isEmpty()) { return gf->createMultiLineString(); } if ( ! holes->size() ) { return gf->createLineString(*shell).release(); } vector<Geometry *> *rings = new vector<Geometry *>(holes->size()+1); (*rings)[0] = gf->createLineString(*shell).release(); for(size_t i=0, n=holes->size(); i<n; ++i) { const LinearRing* hole = dynamic_cast<const LinearRing *>((*holes)[i]); assert( hole ); LineString* ls = gf->createLineString( *hole ).release(); (*rings)[i + 1] = ls; } MultiLineString *ret = getFactory()->createMultiLineString(rings); return ret; }
Geometry* MultiPolygon::getBoundary() const { if (isEmpty()) { return getFactory()->createGeometryCollection(NULL); } vector<Geometry *>* allRings=new vector<Geometry *>(); for (unsigned int i = 0; i < geometries->size(); i++) { Polygon *pg=(Polygon *) (*geometries)[i]; Geometry *g=pg->getBoundary(); LineString *ls=dynamic_cast<LineString *>(g); if ( ls ) { allRings->push_back(ls); } else { GeometryCollection* rings=(GeometryCollection*)g; for (int j = 0; j < rings->getNumGeometries(); j++) { allRings->push_back(new LineString(*(LineString*)rings->getGeometryN(j))); } delete g; } } Geometry *ret=getFactory()->createMultiLineString(allRings); //for (int i=0; i<allRings->size(); i++) delete (*allRings)[i]; //delete allRings; return ret; }
CoordinateSequence* Polygon::getCoordinates() const { if (isEmpty()) { return getFactory()->getCoordinateSequenceFactory()->create(NULL); } size_t i, j, npts; size_t nholes=holes->size(); vector<Coordinate> *cl = new vector<Coordinate>; // Add shell points const CoordinateSequence* shellCoords=shell->getCoordinatesRO(); npts=shellCoords->getSize(); /* * reserve space in the vector as if all holes have the same * amount of points. Holes usually have less, so this should * be a good compromise */ cl->reserve((nholes+1)*npts); for (j=0; j<npts; ++j) cl->push_back(shellCoords->getAt(j)); for (i=0; i<nholes; ++i) { // Add hole points const CoordinateSequence* childCoords=((LinearRing *)(*holes)[i])->getCoordinatesRO(); npts=childCoords->getSize(); for (j=0; j<npts; ++j) cl->push_back(childCoords->getAt(j)); } return getFactory()->getCoordinateSequenceFactory()->create(cl); }
Label* LeaderboardDialog::createLeaderboardLabel( const std::string& text, agui::Widget* parent, bool header, bool odd ) { Label* label = getFactory()->createLabel(); if(Platf::isRetina()) label->setFont(getFactory()->getFontManager()->getFont(2.0f)); if(header) { label->setFont(getFactory()->getFontManager()->getFont(label->getFont(),1.4f)); label->setFontColor(agui::Color( label->getFontColor().getR() - 0.1f, label->getFontColor().getG() - 0.1f, label->getFontColor().getB() - 0.1f )); } if(odd) { label->setFontColor(agui::Color( label->getFontColor().getR() + 0.15f, label->getFontColor().getG() + 0.15f, label->getFontColor().getB() + 0.15f )); } label->setText(text); label->addMouseListener(this); parent->add(label); return label; }
Geometry* LinearRing::reverse() const { assert(points.get()); CoordinateSequence* seq = points->clone(); CoordinateSequence::reverse(seq); assert(getFactory()); return getFactory()->createLinearRing(seq); }
Geometry* MultiLineString::getBoundary() const { if (isEmpty()) { return getFactory()->createGeometryCollection(NULL); } //Geometry *in = toInternalGeometry(this); GeometryGraph gg(0, this); CoordinateSequence *pts=gg.getBoundaryPoints(); Geometry *ret = getFactory()->createMultiPoint(*pts); return ret; }
Geometry* LineString::getBoundary() const { if (isEmpty()) { return getFactory()->createEmptyGeometry(); } if (isClosed()) { return getFactory()->createMultiPoint(); } vector<Geometry*> *pts=new vector<Geometry*>(); pts->push_back(getStartPoint()); pts->push_back(getEndPoint()); MultiPoint *mp = getFactory()->createMultiPoint(pts); return mp; }
static inline ALeffectStateFactory *getFactoryByType(ALenum type) { ALeffectStateFactory* (*getFactory)(void) = LookupUIntMapKey(&EffectStateFactoryMap, type); if(getFactory != NULL) return getFactory(); return NULL; }
bool ComponentNode::resetComponent( const std::string& componentId ) { bool wasEnabled = isEnabled(); if ( wasEnabled ) { disable(); } // remove old component clearAttributes(); delete _component; _component = 0; _componentId = componentId; // set new component if ( !_componentId.empty() ) { _component = getFactory().createComponent( _componentId ); if ( !_component || !_component->init( *this ) ) { if ( _component ) { COCA_ERROR( "Could not initialize component with id '" << _componentId << "'" ); delete _component; _component = 0; } _componentId = ""; } } if ( wasEnabled ) { enable(); } getEventManager().sendEvent( E_NODE_COMPONENT_CHANGED_EVENT, *this ); return ( _componentId == componentId ); }
jobject CBarcode1::getObject(JNIEnv* env) { jhstring jhId = rho_cast<jstring>(env, m_id); jhobject jhFactory = getFactory(env); jobject res = env->CallObjectMethod(jhFactory.get(), s_midGetApiObject, jhId.get()); return res; }
/*protected*/ Polygon::Polygon(LinearRing *newShell, vector<Geometry *> *newHoles, const GeometryFactory *newFactory): Geometry(newFactory) { if (newShell==nullptr) { shell=getFactory()->createLinearRing(nullptr); } else { if (newHoles != nullptr && newShell->isEmpty() && hasNonEmptyElements(newHoles)) { throw util::IllegalArgumentException("shell is empty but holes are not"); } shell=newShell; } if (newHoles==nullptr) { holes=new vector<Geometry *>(); } else { if (hasNullElements(newHoles)) { throw util::IllegalArgumentException("holes must not contain null elements"); } for (size_t i=0; i<newHoles->size(); i++) if ( (*newHoles)[i]->getGeometryTypeId() != GEOS_LINEARRING) throw util::IllegalArgumentException("holes must be LinearRings"); holes=newHoles; } }
/*!\func TGraph::TGraph * --, * \param * - parent - * \return */ GraphBody::GraphBody(EnterInputs *parent) : QGraphicsView(parent), m_ui(new Ui::GraphBody) { LOG(LOG_DEBUG, QString(__FUNCTION__) + " <" + QString::number(__LINE__) + ">"); factory = 0; setState(new State()); m_ui->setupUi(this); this->parent = parent; line = new QGraphicsLineItem; scene.setItemIndexMethod(QGraphicsScene::NoIndex); setScene(&scene); setRenderHint(QPainter::Antialiasing); setTransformationAnchor(AnchorUnderMouse); setResizeAnchor(AnchorViewCenter); scaleView(1); //scene.setSceneRect(200*factor, 100*factor, width(), height()); setMinimumSize(400, 400); currentIndex = -1; scene.addItem(line); rootNode = getFactory()->newRoot(); node = rootNode; max_id = 0; foreach(INode* n, node->nodes()) n->show(); setLevelsPath(); change(false); }
PresenceModelAPIPtr FriendAPI::getPresenceModel() const { CORE_MUTEX FBLOG_DEBUG("FriendAPI::getPresenceModel", "this=" << this); const LinphonePresenceModel *model = linphone_friend_get_presence_model(mFriend); return getFactory()->getPresenceModel(model); }
FileTransferAPIPtr FileManagerAPI::copy(std::string const &sourceUrl, std::string const &targetUrl, FB::JSObjectPtr const &callback) { FBLOG_DEBUG("FileManagerAPI::copy", "this=" << this << "\t" << "sourceUrl=" << sourceUrl << "\t" << "targetUrl=" << targetUrl << "\t" << "callback=" << callback); FB::URI sourceUri(sourceUrl); FB::URI targetUri(targetUrl); if(FileManagerAPI::isHttp(sourceUri) && FileManagerAPI::isHttp(targetUri)) { FBLOG_DEBUG("FileManagerAPI::copy", "Can't copy two Remote resources"); callback->InvokeAsync("", FB::variant_list_of(false)("Can't copy two Remote resources")); return FileTransferAPIPtr(); } if(FileManagerAPI::isInternal(targetUri)) { FBLOG_DEBUG("FileManagerAPI::copy", "Can't copy file into Internal resources"); callback->InvokeAsync("", FB::variant_list_of(false)("Can't copy file into Internal resources")); return FileTransferAPIPtr(); } if(FileManagerAPI::isHttp(sourceUri) && !isSameHost(sourceUri)) { FBLOG_DEBUG("FileManagerAPI::copy", "Can't use different host with remote resource (XSS)"); callback->InvokeAsync("", FB::variant_list_of(false)("Can't use different host with remote resource (XSS)")); return FileTransferAPIPtr(); } if(FileManagerAPI::isHttp(targetUri) && !isSameHost(targetUri)) { FBLOG_DEBUG("FileManagerAPI::copy", "Can't use different host with remote resource (XSS)"); callback->InvokeAsync("", FB::variant_list_of(false)("Can't use different host with remote resource (XSS)")); return FileTransferAPIPtr(); } FileTransferAPIPtr fileTransfer = getFactory()->getFileTransfer(sourceUri, targetUri, callback); return fileTransfer; }
void Application::addGame( TLuaTable* gameTable ) { assert( 0 != gameTable ); Game* game = getFactory()->createGame( gameTable->GetString( "type_" ).c_str() ); assert( 0 != game ); game->init( gameTable ); }
bool FileManagerAPI::isSameHost(FB::URI const &uri) { FB::PluginCorePtr plugin = getFactory()->getPlugin(); FB::URI hostUri = plugin->getHost()->getDOMWindow()->getLocation(); bool ret = boost::iequals(hostUri.protocol, uri.protocol) && boost::iequals(hostUri.domain, uri.domain); if(ret) { int port = uri.port; int hostPort = hostUri.port; if(port == 0) { if(boost::iequals(hostUri.protocol, Protocol::https)) { port = 443; } else if(boost::iequals(uri.protocol, Protocol::http)) { port = 80; } } if(hostPort == 0) { if(boost::iequals(hostUri.protocol, Protocol::https)) { hostPort = 443; } else if(boost::iequals(hostUri.protocol, Protocol::http)) { hostPort = 80; } } ret = (port == hostPort); } return ret; }
void LeaderboardDialog::addCell( const std::string& rank, const std::string& name, const std::string& rating, bool header, bool odd ) { LeaderboardCell cell; cell.container = getFactory()->createEmptyWidget(); cell.container->addMouseListener(this); cell.container->setMargins(1,1,1,5); cell.rank = createLeaderboardLabel(rank,cell.container,header,odd); cell.name = createLeaderboardLabel(name,cell.container,header,odd); cell.rating = createLeaderboardLabel(rating,cell.container,header,odd); int nameOffset = 0; if(header) nameOffset = cell.rank->getWidth(); else if(m_cells.size() > 0) nameOffset = m_cells[0].rank->getWidth(); else nameOffset = 80; nameOffset += 20; int headerExtra = header ? 5 : 0; cell.container->setSize(0,cell.rank->getHeight() + headerExtra + 5); m_container->add(cell.container); cell.container->add(cell.rank); cell.container->add(cell.name); cell.container->add(cell.rating); int yPos = 0; cell.rank->setLocation(0,yPos); cell.name->setLocation(nameOffset,yPos); cell.rating->setLocation(cell.container->getInnerWidth() - cell.rating->getWidth(),yPos); m_cells.push_back(cell); }
void TreasureArme::open(Personnage &p) { Random *r = Random::getInstance(); ItemFactory *f = getFactory(r->getRand()); Arme *a; switch (r->getRand()%3) { case 1: a = f->GetEpee(); break; case 2: a = f->GetDague(); break; default: a = f->GetHache(); } for (int i = 0; i < m_lvl; ++i) { switch (r->getRand()%6) { case 0: a = new DArmeD(a); break; case 1: a = new DArmeC(a); break; case 2: a = new DArmeF(a); break; case 3: a = new DArmeV(a); break; } } delete f; p.trouverArme(a); }
void Script::initializeScript() { auto scriptNameValue = scriptName.getValue(); scriptInterpreter = getFactory()->getScene()->getScriptInterpreter(); scriptInterpreter->loadScript(scriptNameValue); std::string constructorName = scriptNameValue.substr(0, scriptNameValue.size() - 4); // Construct the script object. scriptObject = invokeFunction<LuaObject>(constructorName); scriptObject["scriptWrapper"] = this; // Add dependencies defined in the script. for (luabind::iterator it(scriptObject["dependencies"]), end; it != end; ++it) { LuaObject dependency = *it; auto casted = luabind::object_cast_nothrow<ComponentDependencyBase*>(dependency); if (casted) { addDependency(*casted); } } // Add attributes defined in the script. for (luabind::iterator it(scriptObject["attributes"]), end; it != end; ++it) { LuaObject attribute = *it; auto casted = luabind::object_cast_nothrow<ComponentAttributeBase*>(attribute); if (casted) { addAttribute(*casted); } } }
void KeyListPresenter::deleteKey() { BOOST_LOG_NAMED_SCOPE("KeyListPresenter::deleteKey"); if(checkSelection()) { KeyManager& myKeyMan(getFactory().getKeyManager()); getYubikoOtpKeyPresenter().deleteKey(myKeyMan.getKey(itsSelectedKey)); } }
AddressAPIPtr FriendAPI::getAddress() const { CORE_MUTEX FBLOG_DEBUG("FriendAPI::getAddress", "this=" << this); const LinphoneAddress *address = linphone_friend_get_address(mFriend); return getFactory()->getAddress(address); }
YubikoOtpKeyPresenter& KeyListPresenter::getYubikoOtpKeyPresenter() { if (itsYubikoOtpKeyPresenter == 0) { itsYubikoOtpKeyPresenter = new YubikoOtpKeyPresenter(getFactory()); itsYubikoOtpKeyPresenter->saved.connect([=] {reloadKeyList();}); } return *itsYubikoOtpKeyPresenter; }
//---------- void NodeBrowser::notifyNewNode() { auto currentSelection = this->currentSelection.lock(); if (currentSelection) { auto newNode = currentSelection->getFactory()->make(); this->onNewNode(newNode); } }
/************************************************************************* returns a pointer to the requested WindowFactory object *************************************************************************/ WindowFactory* WindowFactoryManager::getFactory(const String& type) const { // first, dereference aliased types, as needed. String targetType(getDereferencedAliasType(type)); // try for a 'real' type WindowFactoryRegistry::const_iterator pos = d_factoryRegistry.find(targetType); // found an actual factory for this type if (pos != d_factoryRegistry.end()) { return pos->second; } // no concrete type, try for a falagard mapped type else { FalagardMapRegistry::const_iterator falagard = d_falagardRegistry.find(targetType); // found falagard mapping for this type if (falagard != d_falagardRegistry.end()) { // recursively call getFactory on the target base type return getFactory(falagard->second.d_baseType); } // type not found anywhere, give up with an exception. else { throw UnknownObjectException("WindowFactoryManager::getFactory - A WindowFactory object, an alias, or mapping for '" + type + "' Window objects is not registered with the system."); } } }
AbstractUMLLink * AbstractUMLLink::create( int id, Port * begin, Port * end ) { std::map< int, std::function< AbstractUMLLink * ( Port *, Port * ) > >::const_iterator it = getFactory().find( id ); if( it == getFactory().end() ) { return NULL; } return it->second( begin, end ); }