Store SourceInfo as direct member

This commit is contained in:
John Firebaugh
2014-11-25 18:09:38 -08:00
parent 41e90b4150
commit 167097936a
3 changed files with 8 additions and 15 deletions

View File

@@ -29,16 +29,11 @@ public:
};
class StyleSource : public std::enable_shared_from_this<StyleSource> {
class StyleSource : private util::noncopyable {
public:
util::ptr<SourceInfo> info;
SourceInfo info;
bool enabled = false;
util::ptr<Source> source;
StyleSource(const util::ptr<SourceInfo> &info_)
: info(info_)
{}
};
}

View File

@@ -606,7 +606,7 @@ void Map::updateSources() {
for (const util::ptr<StyleSource> &style_source : activeSources) {
if (style_source->enabled) {
if (!style_source->source) {
style_source->source = std::make_shared<Source>(*style_source->info);
style_source->source = std::make_shared<Source>(style_source->info);
style_source->source->load(*this, *fileSource);
}
} else {

View File

@@ -178,14 +178,12 @@ void StyleParser::parseSources(JSVal value) {
rapidjson::Value::ConstMemberIterator itr = value.MemberBegin();
for (; itr != value.MemberEnd(); ++itr) {
std::string name { itr->name.GetString(), itr->name.GetStringLength() };
util::ptr<SourceInfo> info = std::make_shared<SourceInfo>();
SourceInfo& info = sources.emplace(name, std::make_shared<StyleSource>()).first->second->info;
parseRenderProperty<SourceTypeClass>(itr->value, info->type, "type");
parseRenderProperty(itr->value, info->url, "url");
parseRenderProperty(itr->value, info->tile_size, "tileSize");
info->parseTileJSONProperties(itr->value);
sources.emplace(std::move(name), std::make_shared<StyleSource>(info));
parseRenderProperty<SourceTypeClass>(itr->value, info.type, "type");
parseRenderProperty(itr->value, info.url, "url");
parseRenderProperty(itr->value, info.tile_size, "tileSize");
info.parseTileJSONProperties(itr->value);
}
} else {
Log::Warning(Event::ParseStyle, "sources must be an object");