Commit 946126b3 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[2835] Use string for segment type

Instead of hard-coded enum type. The data source should be agnostic to
the type.
parent 8c6afd88
......@@ -483,7 +483,7 @@ ConfigurableClientList::getStatus() const {
// SEGMENT_WAITING.
result.push_back(DataSourceStatus(info.name_, info.cache_ ?
SEGMENT_INUSE : SEGMENT_UNUSED,
SEGMENT_LOCAL));
"local"));
}
return (result);
}
......
......@@ -64,15 +64,6 @@ enum MemorySegmentState {
SEGMENT_INUSE
};
/// \brief The type of the memory segment in cache
enum MemorySegmentType {
/// \brief A locally loaded, unshared cache. Normal memory.
SEGMENT_LOCAL,
/// \brief A file image mapped into memory
SEGMENT_FILE
};
/// \brief Status of one data source.
///
/// This indicates the status a data soure is in. It is used with segment
......@@ -88,10 +79,10 @@ public:
/// Sets initial values. It doesn't matter what is provided for the type
/// if state is SEGMENT_UNUSED, the value is effectively ignored.
DataSourceStatus(const std::string& name, MemorySegmentState state,
MemorySegmentType type) :
const std::string& type) :
name_(name),
state_(state),
type_(type)
type_(type),
state_(state)
{}
/// \brief Get the segment state
......@@ -102,7 +93,7 @@ public:
/// \brief Get the segment type
///
/// \throw isc::InvalidOperation if called and state is SEGMENT_UNUSED.
MemorySegmentType getSegmentType() const {
const std::string& getSegmentType() const {
if (getSegmentState() == SEGMENT_UNUSED) {
isc_throw(isc::InvalidOperation,
"No segment used, no type therefore.");
......@@ -116,8 +107,8 @@ public:
}
private:
std::string name_;
std::string type_;
MemorySegmentState state_;
MemorySegmentType type_;
};
/// \brief The list of data source clients.
......
......@@ -579,7 +579,7 @@ TEST_F(ListTest, status) {
EXPECT_THROW(statuses[0].getSegmentType(), isc::InvalidOperation);
EXPECT_EQ("Test name", statuses[1].getName());
EXPECT_EQ(SEGMENT_INUSE, statuses[1].getSegmentState());
EXPECT_EQ(SEGMENT_LOCAL, statuses[1].getSegmentType());
EXPECT_EQ("local", statuses[1].getSegmentType());
}
TEST_F(ListTest, wrongConfig) {
......@@ -1163,14 +1163,14 @@ TYPED_TEST(ReloadTest, reloadMasterFile) {
RRType::TXT())->code);
}
// Check the status holds data and the data can be extracted
// Check the status holds data and can change the segment state
TEST(DataSourceStatus, status) {
const DataSourceStatus status("Test", SEGMENT_INUSE, SEGMENT_LOCAL);
const DataSourceStatus status("Test", SEGMENT_INUSE, "local");
EXPECT_EQ("Test", status.getName());
EXPECT_EQ(SEGMENT_INUSE, status.getSegmentState());
EXPECT_EQ(SEGMENT_LOCAL, status.getSegmentType());
EXPECT_EQ("local", status.getSegmentType());
const DataSourceStatus statusUnused("Unused", SEGMENT_UNUSED,
SEGMENT_FILE);
"");
EXPECT_EQ("Unused", statusUnused.getName());
EXPECT_EQ(SEGMENT_UNUSED, statusUnused.getSegmentState());
EXPECT_THROW(statusUnused.getSegmentType(), isc::InvalidOperation);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment