本文整理汇总了C++中std::tr1::shared_ptr类的典型用法代码示例。如果您正苦于以下问题:C++ shared_ptr类的具体用法?C++ shared_ptr怎么用?C++ shared_ptr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了shared_ptr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Entity
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);
}
示例2: handleResolve
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: generateFilteredData
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];
}
}
示例4:
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();
}
}
示例5: output_adjoint
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();
}
}
示例6:
PoissonSolver::PoissonSolver(std::tr1::shared_ptr<FFT1D> a_fft1dPtr)
{
m_fft1dptr = a_fft1dPtr;
m_N = a_fft1dPtr->getN();
m_M = a_fft1dPtr->getM();
}
示例7: get
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));
}
示例8: insert
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;
}
}
}
示例9: impl
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_)
{
}
示例10: SILOG
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);
}
示例11: hasQuitCondition
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;
}
示例12: add_item_to_feed
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());
}
}
示例13: set_item_title
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);
}
}
示例14: not
/**
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;
}
示例15: x
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);
}
}