From c5185d2fa5f99de8b75b4b780117d39aab0ffbde Mon Sep 17 00:00:00 2001 From: Cole Kendrick Date: Thu, 18 Apr 2024 08:21:00 -0700 Subject: [PATCH] Make Database::open and Database::create pure virtual --- lib/utils/CSVDatabase.cpp | 2 -- lib/utils/Database.cpp | 26 -------------------------- lib/utils/Database.h | 6 ++---- lib/utils/HDFDatabase.cpp | 4 ---- lib/utils/HDFDatabaseMPIO.cpp | 4 ---- 5 files changed, 2 insertions(+), 40 deletions(-) diff --git a/lib/utils/CSVDatabase.cpp b/lib/utils/CSVDatabase.cpp index 263447594..a5c7063c7 100644 --- a/lib/utils/CSVDatabase.cpp +++ b/lib/utils/CSVDatabase.cpp @@ -31,7 +31,6 @@ CSVDatabase::create( const std::string& file_name, const MPI_Comm comm) { - Database::create(file_name, comm); return true; } @@ -41,7 +40,6 @@ CSVDatabase::open( const std::string& type, const MPI_Comm comm) { - Database::open(file_name, type, comm); return true; } diff --git a/lib/utils/Database.cpp b/lib/utils/Database.cpp index df2cb01b6..76148ec0d 100644 --- a/lib/utils/Database.cpp +++ b/lib/utils/Database.cpp @@ -16,13 +16,6 @@ namespace CAROM { -bool fileExists(const std::string& name) -{ - std::ifstream f(name.c_str()); - return f.good(); - // ifstream f will be closed upon the end of the function. -} - Database::Database() { } @@ -31,23 +24,4 @@ Database::~Database() { } -bool -Database::create( - const std::string& file_name, - const MPI_Comm comm) -{ - std::cout << "Creating file: " << file_name << std::endl; - return true; -} - -bool -Database::open( - const std::string& file_name, - const std::string& type, - const MPI_Comm comm) -{ - std::cout << "Opening file: " << file_name << std::endl; - return true; -} - } diff --git a/lib/utils/Database.h b/lib/utils/Database.h index 1008f391d..0a05068a2 100644 --- a/lib/utils/Database.h +++ b/lib/utils/Database.h @@ -20,8 +20,6 @@ namespace CAROM { -bool fileExists(const std::string& name); - /** * Class Database is an abstract base class that provides basic ability to * write to and read from a file. It's capabilities are limited to what the @@ -55,7 +53,7 @@ class Database bool create( const std::string& file_name, - const MPI_Comm comm=MPI_COMM_NULL); + const MPI_Comm comm=MPI_COMM_NULL) = 0; /** * @brief Opens an existing database file with the supplied name. @@ -73,7 +71,7 @@ class Database open( const std::string& file_name, const std::string& type, - const MPI_Comm comm=MPI_COMM_NULL); + const MPI_Comm comm=MPI_COMM_NULL) = 0; /** * @brief Closes the currently open database file. diff --git a/lib/utils/HDFDatabase.cpp b/lib/utils/HDFDatabase.cpp index 49e9136a8..bd11fdaff 100644 --- a/lib/utils/HDFDatabase.cpp +++ b/lib/utils/HDFDatabase.cpp @@ -57,8 +57,6 @@ HDFDatabase::create( ext_filename += tmp; } - Database::create(ext_filename, comm); - hid_t file_id = H5Fcreate(ext_filename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, @@ -89,8 +87,6 @@ HDFDatabase::open( ext_filename += tmp; } - Database::open(ext_filename, type, comm); - CAROM_VERIFY(type == "r" || type == "wr"); hid_t file_id; if (type == "r") diff --git a/lib/utils/HDFDatabaseMPIO.cpp b/lib/utils/HDFDatabaseMPIO.cpp index 5e2d9bc40..a93e37f47 100644 --- a/lib/utils/HDFDatabaseMPIO.cpp +++ b/lib/utils/HDFDatabaseMPIO.cpp @@ -45,8 +45,6 @@ HDFDatabaseMPIO::create( /* Create a single file with a name compatible to HDFDatabase. */ std::string file_name_ext(file_name + ".000000"); - if (d_rank == 0) - Database::create(file_name_ext); CAROM_VERIFY(!file_name.empty()); hid_t plist_id; @@ -97,8 +95,6 @@ HDFDatabaseMPIO::open( d_rank = 0; std::string file_name_ext(file_name + ".000000"); - if (d_rank == 0) - Database::open(file_name_ext, type); CAROM_VERIFY(!file_name.empty()); CAROM_VERIFY(type == "r" || type == "wr");