From 6d72b2a2388973cded4da6d1470fbba74e7c7a2c Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Fri, 28 Jun 2019 10:19:35 +0200 Subject: [PATCH] bnet: cleanup scope of functions and constructors - BnetDump(const std::string&) is private because it should only by used by the static Create function - deleted not used functions --- core/src/lib/bnet_network_dump.cc | 18 +++++------------- core/src/lib/bnet_network_dump.h | 12 +++++------- core/src/lib/bnet_network_dump_private.h | 1 - 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/core/src/lib/bnet_network_dump.cc b/core/src/lib/bnet_network_dump.cc index 0f12208899d..aa90d4245eb 100644 --- a/core/src/lib/bnet_network_dump.cc +++ b/core/src/lib/bnet_network_dump.cc @@ -30,18 +30,16 @@ std::unique_ptr BnetDump::Create(std::string own_qualified_name) std::unique_ptr p; return p; } else { - std::unique_ptr p(std::make_unique(own_qualified_name)); + // BnetDump constructor should be private + std::unique_ptr p(new BnetDump(own_qualified_name)); return p; } } -BnetDump::BnetDump(const std::string& own_qualified_name) : BnetDump() +BnetDump::BnetDump(const std::string& own_qualified_name) + : impl_(std::make_unique()) { impl_->own_qualified_name_ = own_qualified_name; -} - -BnetDump::BnetDump() : impl_(std::make_unique()) -{ impl_->OpenFile(); } @@ -51,12 +49,6 @@ BnetDump::~BnetDump() impl_->CloseFile(); } -bool BnetDump::IsInitialized() const { return impl_->output_file_.is_open(); } - -void BnetDump::DisableLogging() { impl_->logging_disabled_ = true; } - -void BnetDump::EnableLogging() { impl_->logging_disabled_ = false; } - void BnetDump::SetDestinationQualifiedName( std::string destination_qualified_name) { @@ -83,7 +75,7 @@ bool BnetDump::EvaluateCommandLineArgs(const char* cmdline_optarg) void BnetDump::DumpMessageAndStacktraceToFile(const char* ptr, int nbytes) const { - if (!IsInitialized() || impl_->logging_disabled_) { return; } + if (!impl_->output_file_.is_open()) { return; } impl_->SaveAndSendMessageIfNoDestinationDefined(ptr, nbytes); impl_->DumpToFile(ptr, nbytes); diff --git a/core/src/lib/bnet_network_dump.h b/core/src/lib/bnet_network_dump.h index 2e6b5649fb8..2d0ff987787 100644 --- a/core/src/lib/bnet_network_dump.h +++ b/core/src/lib/bnet_network_dump.h @@ -30,23 +30,21 @@ class BnetDump { public: static std::unique_ptr Create(std::string own_qualified_name); static bool EvaluateCommandLineArgs(const char* cmdline_optarg); - void SetDestinationQualifiedName(std::string destination_qualified_name); + void SetDestinationQualifiedName(std::string destination_qualified_name); void DumpMessageAndStacktraceToFile(const char* ptr, int nbytes) const; - bool IsInitialized() const; - void DisableLogging(); - void EnableLogging(); public: - BnetDump(const std::string& own_qualified_name); + ~BnetDump(); + BnetDump(const BnetDump& other) = delete; BnetDump(const BnetDump&& other) = delete; BnetDump& operator=(const BnetDump& rhs) = delete; BnetDump& operator=(const BnetDump&& rhs) = delete; - ~BnetDump(); + BnetDump() = delete; private: - BnetDump(); + BnetDump(const std::string& own_qualified_name); std::unique_ptr impl_; }; diff --git a/core/src/lib/bnet_network_dump_private.h b/core/src/lib/bnet_network_dump_private.h index 57945431c52..70291b46d48 100644 --- a/core/src/lib/bnet_network_dump_private.h +++ b/core/src/lib/bnet_network_dump_private.h @@ -52,7 +52,6 @@ class BnetDumpPrivate { std::string destination_qualified_name_; std::ofstream output_file_; - bool logging_disabled_ = false; private: void CreateAndWriteStacktraceToBuffer();