예제 #1
0
LightEntity::LightEntity(OgreSystem *scene, const std::tr1::shared_ptr<ProxyLightObject> &plo, const std::string &id)
    : Entity(scene,
             plo,
             id.length()?id:ogreLightName(plo->getObjectReference()),
             scene->getSceneManager()->createLight(id.length()?id:ogreLightName(plo->getObjectReference()))) {
    getProxy().LightProvider::addListener(this);
}
void ASIOConnectAndHandshake::handleResolve(const ASIOConnectAndHandshakePtr& thus,
					    const std::tr1::shared_ptr<MultiplexedSocket>&connection,
                                            const Address&address,
                                            bool no_delay,
                                            const boost::system::error_code &error,
                                            tcp::resolver::iterator it) {
    if (!connection) {
        return;
    }
    if (error) {
        connection->connectionFailedCallback(error);
    }else {
        unsigned int numSockets=connection->numSockets();
        for (unsigned int whichSocket=0;whichSocket<numSockets;++whichSocket) {
            connectToIPAddress(thus,
			       connection,
                               address,
                               no_delay,
                               whichSocket,
                               it,
                               boost::asio::error::host_not_found);
        }
    }

}
예제 #3
0
  TransactionResult::Enum RunCommitTransaction()
  {
    TransactionResult::Enum tret;
    for (TouchedFilesList::iterator p = TouchedFiles.begin(),
	   end = TouchedFiles.end(); p != end; ++p) {
      tret = MarkAsProcessed(*p);
      if (tret != TransactionResult::COMMIT) {
	return tret;
      }
    }

    Statement stmt;
    tret = stmt.TxnPrepare
      (*DB, "INSERT INTO files (path, mtime, size) VALUES (?, ?, ?)");
    if (tret != TransactionResult::COMMIT) {
      return tret;
    }
    for (FTableMap::const_iterator p = FTable.begin(),
	   end = FTable.end(); p != end; ++p) {
      const FileIdentification &FI(p->second->Ident);
      if (p->first != FI.Path) {
	// This is a duplicate, secondary entry.  Avoid
	// shadowing the real entry.
	continue;
      }
      sqlite3_reset(stmt.Ptr);
      sqlite3_bind_text(stmt.Ptr, 1, FI.Path.data(), FI.Path.size(),
			SQLITE_TRANSIENT);
      sqlite3_bind_int64(stmt.Ptr, 2, FI.Mtime);
      sqlite3_bind_int64(stmt.Ptr, 3, FI.Size);
      if (sqlite3_step(stmt.Ptr) != SQLITE_DONE) {
	return DB->SetTransactionError(sqlite3_sql(stmt.Ptr));
      }
      p->second->ID = sqlite3_last_insert_rowid(DB->Ptr);
    }

    tret = stmt.TxnPrepare
      (*DB,
       "INSERT INTO reports (file, line, column, tool, message) "
       "VALUES (?, ?, ?, ?, ?);");
    if (tret != TransactionResult::COMMIT) {
      return tret;
    }

    for (std::vector<Report>::const_iterator p = Reports.begin(),
	   end = Reports.end(); p != end; ++p) {
      sqlite3_reset(stmt.Ptr);
      sqlite3_bind_int64(stmt.Ptr, 1, p->FI->ID);
      sqlite3_bind_int64(stmt.Ptr, 2, p->Line);
      sqlite3_bind_int64(stmt.Ptr, 3, p->Column);
      sqlite3_bind_text(stmt.Ptr, 4, p->Tool.data(), p->Tool.size(),
			SQLITE_TRANSIENT);
      sqlite3_bind_text(stmt.Ptr, 5, p->Message.data(), p->Message.size(),
			SQLITE_TRANSIENT);
      if (sqlite3_step(stmt.Ptr) != SQLITE_DONE) {
	return DB->SetTransactionError(sqlite3_sql(stmt.Ptr));
      }
    }
    return TransactionResult::COMMIT;
  }
예제 #4
0
    inline void generateFilteredData(std::vector<GLfloat>& scalardata,
				     const std::tr1::shared_ptr<Attribute>& ptr,
				     size_t mode)
    {
      //Update the data according to what was selected
      scalardata.resize(ptr->num_elements());
      const size_t components = ptr->components();
      const std::vector<GLfloat>& attrdata = *ptr;
      
      if (mode == 1)
	//Magnitude calculation
	{
	  for (size_t i(0); i < scalardata.size(); ++i)
	    {
	      scalardata[i] = 0;
	      for (size_t j(0); j < components; ++j)
		{
		  GLfloat val = attrdata[i * components + j];
		  scalardata[i] += val * val;
		}
	      scalardata[i] = std::sqrt(scalardata[i]);
	    }
	}
      else
	{
	  //Component wise selection
	  size_t component = mode - 2;
#ifdef COIL_DEBUG
	  if (component >= components)
	    M_throw() << "Trying to filter an invalid component";
#endif
	  for (size_t i(0); i < scalardata.size(); ++i)
	    scalardata[i] = attrdata[i * components + component];
	}
    }
예제 #5
0
  void SteadyVisualization::output_residual_sensitivities
    (std::tr1::shared_ptr<libMesh::EquationSystems> equation_system,
     MultiphysicsSystem* system,
     const libMesh::ParameterVector & params,
     const unsigned int,
     const libMesh::Real )
  {
    for (unsigned int p=0; p != params.size(); ++p)
      {
        std::stringstream pstr;
        pstr << p;

        std::string filename =
          this->_vis_output_file_prefix+"_dRdp"+pstr.str();

        // Swap solution with precomputed sensitivity rhs
        system->solution->swap(system->get_sensitivity_rhs(p));
        equation_system->update();

        this->dump_visualization( equation_system, filename, 0.0 );

        // Now swap back and reupdate
        system->solution->swap(system->get_sensitivity_rhs(p));
        equation_system->update();
      }
  }
예제 #6
0
  void SteadyVisualization::output_adjoint( std::tr1::shared_ptr<libMesh::EquationSystems> equation_system,
                                            MultiphysicsSystem* system,
                                            const unsigned int /*time_step*/,
                                            const libMesh::Real /*time*/ )
  {
    const libMesh::DifferentiableQoI* raw_qoi = system->get_qoi();
    const CompositeQoI* qoi = dynamic_cast<const CompositeQoI*>( raw_qoi );

    unsigned int n_qois = qoi->n_qois();

    for( unsigned int q = 0; q < n_qois; q++ )
      {
        libMesh::NumericVector<libMesh::Number>& dual_solution = system->get_adjoint_solution(q);

        const std::string& qoi_name = qoi->get_qoi(q).name();
        std::string filename = this->_vis_output_file_prefix+"_adjoint_"+qoi_name;

        system->solution->swap( dual_solution );
        equation_system->update();

        this->dump_visualization( equation_system, filename, 0.0 );

        // Now swap back and reupdate
        system->solution->swap( dual_solution );
        equation_system->update();
      }
  }
예제 #7
0
PoissonSolver::PoissonSolver(std::tr1::shared_ptr<FFT1D> a_fft1dPtr)
{
  
  m_fft1dptr = a_fft1dPtr;
  m_N = a_fft1dPtr->getN();
  m_M = a_fft1dPtr->getM();
}
예제 #8
0
void MeerkatChunkHandler::get(std::tr1::shared_ptr<RemoteFileMetadata> file,
        std::tr1::shared_ptr<Chunk> chunk, ChunkCallback callback) {

    //Check for null arguments
    std::tr1::shared_ptr<DenseData> bad;
    if (!file) {
        SILOG(transfer, error, "HttpChunkHandler get called with null file parameter");
        callback(bad);
        return;
    }
    if (!chunk) {
        SILOG(transfer, error, "HttpChunkHandler get called with null chunk parameter");
        callback(bad);
        return;
    }

    //Make sure chunk given is part of file
    bool foundIt = false;
    const ChunkList & chunks = file->getChunkList();
    for (ChunkList::const_iterator it = chunks.begin(); it != chunks.end(); it++) {
        if(*chunk == *it) {
            foundIt = true;
        }
    }
    if(!foundIt) {
        SILOG(transfer, error, "HttpChunkHandler get called with chunk not present in file metadata");
        callback(bad);
        return;
    }

    //Check to see if it's in the cache first
    SharedChunkCache::getSingleton().getCache()->getData(file->getFingerprint(), chunk->getRange(), std::tr1::bind(
            &MeerkatChunkHandler::cache_check_callback, this, _1, file->getURI(), chunk, callback));
}
예제 #9
0
	void ParameterGroup::insert(const std::string& name,
				    const std::tr1::shared_ptr<ParameterMapItem>& data)
        {
	    std::pair<std::string, std::string> name_path = split(name);
	    map_type::const_iterator it = map_.find(name_path.first);
	    assert(name_path.second == "");
	    if (it == map_.end()) {
		map_[name] = data;
	    } else {
		if ( (map_[name]->getTag() == data->getTag())  &&
                     (data->getTag() == ID_xmltag__param_grp) ) {
		    ParameterGroup& alpha = dynamic_cast<ParameterGroup&>(*(*it).second);
		    ParameterGroup& beta  = dynamic_cast<ParameterGroup&>(*data);
		    for (map_type::const_iterator
                             item = beta.map_.begin(); item != beta.map_.end(); ++item) {
			alpha.insert((*item).first, (*item).second);
		    }
		} else {
		    std::cout << "WARNING : The '"
			      << map_[name]->getTag()
			      << "' element '"
			      << name
			      << "' already exist in group '"
			      << this->path()
			      << "'. The element will be replaced by a '"
			      << data->getTag()
			      << "' element.\n";
		    map_[name] = data;
		}
	    }
	}
예제 #10
0
 impl(const std::string &url,
      std::tr1::shared_ptr<const std::vector<unsigned char> > compressed)
   : url_(url), compressed_(compressed),
     mrsource_(compressed_->data(), compressed_->size()),
     gzsource_(&mrsource_)
 {
 }
예제 #11
0
void FileNameHandler::onReadFinished(std::tr1::shared_ptr<DenseData> fileContents,
        std::tr1::shared_ptr<MetadataRequest> request, NameCallback callback) {

    mStats.resolved++;

    std::tr1::shared_ptr<RemoteFileMetadata> bad;
    if (!fileContents) {
        SILOG(transfer, error, "FileNameHandler couldn't find file '" << request->getURI() << "'");
        callback(bad);
        return;
    }

    FileHeaders emptyHeaders;
    Fingerprint fp = SparseData(fileContents).computeFingerprint();

    //Just treat everything as a single chunk for now
    Range::length_type file_size = fileContents->length();
    Range whole(0, file_size, LENGTH, true);
    Chunk chunk(fp, whole);
    ChunkList chunkList;
    chunkList.push_back(chunk);

    SharedChunkCache::getSingleton().getCache()->addToCache(fp, fileContents);
    std::tr1::shared_ptr<RemoteFileMetadata> met(new RemoteFileMetadata(fp, request->getURI(),
                file_size, chunkList, emptyHeaders));
    callback(met);
}
예제 #12
0
파일: jeu.cpp 프로젝트: Hindi/Jeu
bool hasQuitCondition(std::tr1::shared_ptr<Player> player, std::tr1::shared_ptr<Player> player2, bool m_quit)
{
    if(m_quit)
        return true;
    if(Level_manager::getInstance()->isFinished() && (!Population::getInstance()->haveEnnemyInProgress()))
        return true;
    if(player->isDead() && player2->isDead())
        return true;
}
예제 #13
0
void rss_parser::add_item_to_feed(std::tr1::shared_ptr<rss_feed> feed, std::tr1::shared_ptr<rss_item> item) {
	// only add item to feed if it isn't on the ignore list or if there is no ignore list
	if (!ign || !ign->matches(item.get())) {
		feed->add_item(item);
		LOG(LOG_INFO, "rss_parser::parse: added article title = `%s' link = `%s' ign = %p", item->title().c_str(), item->link().c_str(), ign);
	} else {
		LOG(LOG_INFO, "rss_parser::parse: ignored article title = `%s' link = `%s'", item->title().c_str(), item->link().c_str());
	}
}
예제 #14
0
void rss_parser::set_item_title(std::tr1::shared_ptr<rss_feed> feed, std::tr1::shared_ptr<rss_item> x, rsspp::item& item) {
	if (is_html_type(item.title_type)) {
		x->set_title(render_xhtml_title(item.title, feed->link()));
	} else {
		std::string title = item.title;
		replace_newline_characters(title);
		x->set_title(title);
	}
}
예제 #15
0
/**
 Adds an option to the style file. Returns true, if command was inserted successfully or false,
 if not (e. g. command already exists)
 */
bool CStyleFile::AddOption(std::tr1::shared_ptr<CDeclareOption>& cmd)
{
	if (!CStyleFileContainer::ContainsString(&m_Options, cmd->GetName()))
	{
		m_Options.Add(cmd->GetName());
		return true;
	}

	return false;
}
예제 #16
0
void rss_parser::fill_feed_items(std::tr1::shared_ptr<rss_feed> feed) {
	/*
	 * we iterate over all items of a feed, create an rss_item object for
	 * each item, and fill it with the appropriate values from the data structure.
	 */
	for (std::vector<rsspp::item>::iterator item=f.items.begin();item!=f.items.end();item++) {
		std::tr1::shared_ptr<rss_item> x(new rss_item(ch));

		set_item_title(feed, x, *item);

		if (item->link != "") {
			x->set_link(utils::absolute_url(feed->link(), item->link));
		}

		set_item_author(x, *item);

		x->set_feedurl(feed->rssurl());

		if (f.rss_version == rsspp::ATOM_1_0 && item->labels.size() > 0) {
			std::vector<std::string>::const_iterator start, finish;
			start = item->labels.begin();
			finish = item->labels.end();
			if (std::find(start, finish, "fresh") != finish) {
				x->set_unread_nowrite(true);
				x->set_override_unread(true);
			} 
			if (std::find(start, finish, "kept-unread") != finish) {
				x->set_unread_nowrite(true);
				x->set_override_unread(true);
			}
			if (std::find(start, finish, "read") != finish) {
				x->set_unread_nowrite(false);
				x->set_override_unread(true);
			}
		}

		set_item_content(x, *item);

		if (item->pubDate != "") 
			x->set_pubDate(parse_date(item->pubDate));
		else
			x->set_pubDate(::time(NULL));
			
		x->set_guid(get_guid(*item));

		x->set_base(item->base);

		set_item_enclosure(x, *item);

		LOG(LOG_DEBUG, "rss_parser::parse: item title = `%s' link = `%s' pubDate = `%s' (%d) description = `%s'", x->title().c_str(), 
			x->link().c_str(), x->pubDate().c_str(), x->pubDate_timestamp(), x->description().c_str());

		add_item_to_feed(feed, x);
	}
}
예제 #17
0
파일: TexChunk.cpp 프로젝트: ab11w/gosu
Gosu::TexChunk::TexChunk(Graphics& graphics, DrawOpQueueStack& queues,
    std::tr1::shared_ptr<Texture> texture, int x, int y, int w, int h, int padding)
: graphics(graphics), queues(queues), texture(texture), x(x), y(y), w(w), h(h), padding(padding)
{
    info.texName = texture->texName();
    float textureSize = texture->size();
    info.left = x / textureSize;
    info.top = y / textureSize;
    info.right = (x + w) / textureSize;
    info.bottom = (y + h) / textureSize;
}
예제 #18
0
파일: Actor.cpp 프로젝트: Avnerus/ichigo
 // Adds a retained child as an actor
 bool Actor::addChild(std::tr1::shared_ptr<Agent> agent, std::string name /*= ""*/)
 {
     bool retVal = Agent::addChild(agent, name);
     
     if (retVal && _actorView && agent->getView())
     {
         _actorView->addChild((ActorView *)agent->getView());
     }
     
     return retVal;
 }
예제 #19
0
void rss_parser::handle_content_encoded(std::tr1::shared_ptr<rss_item> x, rsspp::item& item) {
	if (x->description() != "")
		return;

	/* here we handle content:encoded tags that are an extension but very widespread */
	if (item.content_encoded != "") {
		x->set_description(item.content_encoded);
	} else {
		LOG(LOG_DEBUG, "rss_parser::parse: found no content:encoded");
	}
}
예제 #20
0
파일: Scene.cpp 프로젝트: Avnerus/ichigo
 // Adds a retained child as a layer
 bool Scene::addChild(std::tr1::shared_ptr<Agent> agent, std::string name /*= ""*/)
 {
     bool retVal = Agent::addChild(agent, name);
     
     if (retVal && _sceneView && agent->getView())
     {
         _sceneView->addLayer((LayerView *)agent->getView());
     }
     
     return retVal;
 }
예제 #21
0
void MeerkatChunkHandler::get(std::tr1::shared_ptr<Chunk> chunk, ChunkCallback callback) {
    std::tr1::shared_ptr<DenseData> bad;
    if (!chunk) {
        SILOG(transfer, error, "HttpChunkHandler get called with null chunk parameter");
        callback(bad);
        return;
    }
    //Check to see if it's in the cache first
    SharedChunkCache::getSingleton().getCache()->getData(chunk->getHash(), chunk->getRange(), std::tr1::bind(
            &MeerkatChunkHandler::cache_check_callback, this, _1, URI("meerkat:///"), chunk, callback));
}
예제 #22
0
void rss_parser::handle_itunes_summary(std::tr1::shared_ptr<rss_item> x, rsspp::item& item) {
	if (x->description() != "")
		return;

	std::string summary = item.itunes_summary;
	if (summary != "") {
		std::string desc = "<ituneshack>";
		desc.append(summary);
		desc.append("</ituneshack>");
		x->set_description(desc);
	}
}
예제 #23
0
 BitCache::BitCache(const std::tr1::shared_ptr<BitData>& bitdata,
                    BitDownloadingInfo *downloading_info)
     : piece_length_(bitdata->GetPieceLength()),
       piece_map_(bitdata->GetPieceMap()),
       info_hash_(bitdata->GetInfoHash()),
       metainfo_file_(bitdata->GetMetainfoFile()),
       downloading_info_(downloading_info),
       file_(bitdata)
 {
     const std::size_t total_cache_memory = 50 * 1024 * 1024;
     max_cache_pieces_ = total_cache_memory / piece_length_;
 }
예제 #24
0
void rss_parser::set_item_content(std::tr1::shared_ptr<rss_item> x, rsspp::item& item) {

	handle_content_encoded(x, item);

	handle_itunes_summary(x, item);

	if (x->description() == "") {
		x->set_description(item.description);
	} else {
		if (cfgcont->get_configvalue_as_bool("always-display-description") && item.description != "")
			x->set_description(x->description() + "<hr>" + item.description);
	}
	LOG(LOG_DEBUG, "rss_parser::set_item_content: content = %s", x->description().c_str());
}
예제 #25
0
파일: main.cpp 프로젝트: aalex/ubuntu-tempi
bool App::startOSC()
{
    // starts OSC
    if (osc_recv_port_ == 0)
    {
        std::cout << "OSC receiving disabled." << std::endl;
        return false;
    }
    else
    {
        osc_receiver_.reset(new tempi::osc::OscReceiver(osc_recv_port_));
        std::cout << "Receive OSC from " << (*osc_receiver_.get()) << std::endl;
    }
    return true;
}
예제 #26
0
void rss_parser::set_item_author(std::tr1::shared_ptr<rss_item> x, rsspp::item& item) {
	/* 
	 * some feeds only have a feed-wide managingEditor, which we use as an item's
	 * author if there is no item-specific one available.
	 */
	if (item.author == "") {
		if (f.managingeditor != "")
			x->set_author(f.managingeditor);
		else {
			x->set_author(f.dc_creator);
		}
	} else {
		x->set_author(item.author);
	}
}
예제 #27
0
void FileChunkHandler::onReadFinished(std::tr1::shared_ptr<DenseData> fileContents, std::tr1::shared_ptr<RemoteFileMetadata> file,
        std::tr1::shared_ptr<Chunk> chunk, ChunkCallback callback) {

    mStats.downloaded++;

    std::tr1::shared_ptr<DenseData> bad;
    if (!fileContents) {
        SILOG(transfer, error, "FileChunkHandler couldn't find file '" << file->getURI() << "'");
        callback(bad);
        return;
    }

    SharedChunkCache::getSingleton().getCache()->addToCache(file->getFingerprint(), fileContents);
    callback(fileContents);
}
예제 #28
0
void MeerkatNameHandler::resolve(std::tr1::shared_ptr<MetadataRequest> request, NameCallback callback) {
    URL url(request->getURI());
    assert(!url.empty());

    std::string dns_uri_prefix = CDN_DNS_URI_PREFIX;
    std::string host_name = CDN_HOST_NAME;
    Network::Address cdn_addr = mCdnAddr;
    if (url.host() != "") {
        host_name = url.context().hostname();
        std::string service = url.context().service();
        if (service == "") {
            service = CDN_SERVICE;
        }
        Network::Address given_addr(host_name, service);
        cdn_addr = given_addr;
    }

    HttpManager::Headers headers;
    headers["Host"] = host_name;

    HttpManager::getSingleton().head(
        cdn_addr, dns_uri_prefix + url.fullpath(),
        std::tr1::bind(&MeerkatNameHandler::request_finished, this, _1, _2, _3, request, callback),
        headers
    );
}
예제 #29
0
bool Factory<PTree>::create(
	std::tr1::shared_ptr<PTree>& sptr,
	std::ostream& error,
	const std::string& basepath,
	const std::string& path,
	const std::string& name,
	const empty&)
{
	const std::string abspath = basepath + "/" + path + "/" + name;
	std::ifstream file(abspath.c_str());
	if (file)
	{
		sptr.reset(new PTree());
		if (m_content)
		{
			// include support
			ConfigInclude include(*m_content, basepath, path);
			m_read(file, *sptr, &include);
		}
		else
		{
			m_read(file, *sptr, 0);
		}
		return true;
	}
	return false;
}
예제 #30
0
Projection::Projection(std::tr1::shared_ptr<FFT1D> a_fft1dPtr)
{
  // create the solver
  m_solver = PoissonSolver(a_fft1dPtr);
  // store N
  m_N = a_fft1dPtr->getN();
}