Skip to content

Commit

Permalink
Make Database::open and Database::create pure virtual
Browse files Browse the repository at this point in the history
  • Loading branch information
ckendrick committed Apr 18, 2024
1 parent e692592 commit c5185d2
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 40 deletions.
2 changes: 0 additions & 2 deletions lib/utils/CSVDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ CSVDatabase::create(
const std::string& file_name,
const MPI_Comm comm)
{
Database::create(file_name, comm);
return true;
}

Expand All @@ -41,7 +40,6 @@ CSVDatabase::open(
const std::string& type,
const MPI_Comm comm)
{
Database::open(file_name, type, comm);
return true;
}

Expand Down
26 changes: 0 additions & 26 deletions lib/utils/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
}
Expand All @@ -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;
}

}
6 changes: 2 additions & 4 deletions lib/utils/Database.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
4 changes: 0 additions & 4 deletions lib/utils/HDFDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")
Expand Down
4 changes: 0 additions & 4 deletions lib/utils/HDFDatabaseMPIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");

Expand Down

0 comments on commit c5185d2

Please sign in to comment.