blob: 6d44449850d0741f0811297bda7957a54249353a [file] [log] [blame]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/developer/debug/zxdb/client/target.h"
#include "src/developer/debug/zxdb/client/setting_schema_definition.h"
#include "src/developer/debug/zxdb/client/system.h"
namespace zxdb {
// Schema Definition -----------------------------------------------------------
static const char* kShowStdoutDescription =
R"( Whether this process should pipe its stdout/stderr to zxdb.
If not set for a particular process, it will default to the system-wide
setting.)";
namespace {
fxl::RefPtr<SettingSchema> CreateSchema() {
auto schema = fxl::MakeRefCounted<SettingSchema>();
schema->AddBool(ClientSettings::System::kShowStdout,
kShowStdoutDescription, true);
return schema;
}
} // namespace
// Target Implementation -------------------------------------------------------
Target::Target(Session* session)
: ClientObject(session),
// Implementations can set up fallbacks if needed.
settings_(GetSchema(), nullptr),
weak_factory_(this) {}
Target::~Target() = default;
void Target::AddObserver(TargetObserver* observer) {
observers_.AddObserver(observer);
}
void Target::RemoveObserver(TargetObserver* observer) {
observers_.RemoveObserver(observer);
}
fxl::WeakPtr<Target> Target::GetWeakPtr() { return weak_factory_.GetWeakPtr(); }
fxl::RefPtr<SettingSchema> Target::GetSchema() {
// Will only run initialization once.
InitializeSchemas();
static fxl::RefPtr<SettingSchema> schema = CreateSchema();
return schema;
}
} // namespace zxdb