Implement Params singleton in modern C++ way

This commit is contained in:
Luis Díaz Más 2022-02-20 09:22:55 +01:00
parent a357596a2e
commit 4163236e72
2 changed files with 2 additions and 17 deletions

View File

@ -181,7 +181,6 @@ int main(int argc, char* const argv[])
}
taskFactory.cleanup();
Params::cleanup();
Exiv2::XmpParser::terminate();
}
} catch (const std::exception& exc) {
@ -195,7 +194,6 @@ int main(int argc, char* const argv[])
// *****************************************************************************
// class Params
Params* Params::instance_ = nullptr;
const Params::YodAdjust Params::emptyYodAdjust_[] = {
{ false, "-Y", 0 },
@ -232,16 +230,8 @@ Params::Params() : optstring_(":hVvqfbuktTFa:Y:O:D:r:p:P:d:e:i:c:m:M:l:S:g:K:n:Q
Params& Params::instance()
{
if (nullptr == instance_) {
instance_ = new Params;
}
return *instance_;
}
void Params::cleanup()
{
delete instance_;
instance_ = nullptr;
static Params instance_;
return instance_;
}
void Params::version(bool verbose, std::ostream& os)

View File

@ -148,9 +148,6 @@ public:
//! Prevent copy-construction: not implemented.
Params(const Params& rhs) = delete;
//! Destructor
static void cleanup();
//! Enumerates print modes
enum PrintMode {
pmSummary,
@ -244,8 +241,6 @@ public:
Exiv2::DataBuf stdinBuf; //!< DataBuf with the binary bytes from stdin
private:
//! Pointer to the global Params object.
static Params* instance_;
//! Initializer for year, month and day adjustment info.
static const YodAdjust emptyYodAdjust_[];