Commit c6b08019 authored by Francis Dupont's avatar Francis Dupont
Browse files

[5533a] Move factory to shared pointer, added cache tests

parent 2ea993e6
......@@ -134,11 +134,11 @@ struct MySqlHostDataSourceInit {
}
// Factory class method
static BaseHostDataSource*
static HostDataSourcePtr
factory(const DatabaseConnection::ParameterMap& parameters) {
LOG_INFO(dhcpsrv_logger, DHCPSRV_MYSQL_HOST_DB)
.arg(DatabaseConnection::redactedAccessString(parameters));
return (new MySqlHostDataSource(parameters));
return (HostDataSourcePtr(new MySqlHostDataSource(parameters)));
}
};
......@@ -159,11 +159,11 @@ struct PgSqlHostDataSourceInit {
}
// Factory class method
static BaseHostDataSource*
static HostDataSourcePtr
factory(const DatabaseConnection::ParameterMap& parameters) {
LOG_INFO(dhcpsrv_logger, DHCPSRV_PGSQL_HOST_DB)
.arg(DatabaseConnection::redactedAccessString(parameters));
return (new PgSqlHostDataSource(parameters));
return (HostDataSourcePtr(new PgSqlHostDataSource(parameters)));
}
};
......@@ -184,11 +184,11 @@ struct CqlHostDataSourceInit {
}
// Factory class method
static BaseHostDataSource*
static HostDataSourcePtr
factory(const DatabaseConnection::ParameterMap& parameters) {
LOG_INFO(dhcpsrv_logger, DHCPSRV_CQL_HOST_DB)
.arg(DatabaseConnection::redactedAccessString(parameters));
return (new CqlHostDataSource(parameters));
return (HostDataSourcePtr(new CqlHostDataSource(parameters)));
}
};
......
......@@ -77,7 +77,7 @@ public:
///
/// A factory takes a parameter map and returns a pointer to a host
/// data source. In case of failure it must throw and not return NULL.
typedef boost::function<BaseHostDataSource*(const DatabaseConnection::ParameterMap&)> Factory;
typedef boost::function<HostDataSourcePtr (const DatabaseConnection::ParameterMap&)> Factory;
/// @brief Register a host data source factory
///
......
......@@ -91,6 +91,7 @@ libdhcpsrv_unittests_SOURCES += dbaccess_parser_unittest.cc
libdhcpsrv_unittests_SOURCES += dhcp4o6_ipc_unittest.cc
libdhcpsrv_unittests_SOURCES += duid_config_parser_unittest.cc
libdhcpsrv_unittests_SOURCES += expiration_config_parser_unittest.cc
libdhcpsrv_unittests_SOURCES += host_cache_unittest.cc
libdhcpsrv_unittests_SOURCES += host_data_source_factory_unittest.cc
libdhcpsrv_unittests_SOURCES += host_mgr_unittest.cc
libdhcpsrv_unittests_SOURCES += host_unittest.cc
......
This diff is collapsed.
......@@ -36,9 +36,9 @@ public:
};
// @brief Factory of mem1
BaseHostDataSource*
HostDataSourcePtr
mem1Factory(const DatabaseConnection::ParameterMap&) {
return (new Mem1HostDataSource());
return (HostDataSourcePtr(new Mem1HostDataSource()));
}
// @brief Register mem1Factory
......@@ -55,9 +55,9 @@ public:
};
// @brief Factory of mem2
BaseHostDataSource*
HostDataSourcePtr
mem2Factory(const DatabaseConnection::ParameterMap&) {
return (new Mem2HostDataSource());
return (HostDataSourcePtr(new Mem2HostDataSource()));
}
// @brief Register mem2Factory
......@@ -66,8 +66,8 @@ bool registerFactory2() {
}
// @brief Factory function returning 0
BaseHostDataSource* factory0(const DatabaseConnection::ParameterMap&) {
return (0);
HostDataSourcePtr factory0(const DatabaseConnection::ParameterMap&) {
return (HostDataSourcePtr());
}
// @brief Test fixture class
......
......@@ -223,9 +223,9 @@ MemHostDataSource::size() const {
return (store_.size());
}
BaseHostDataSource*
HostDataSourcePtr
memFactory(const DatabaseConnection::ParameterMap& /*parameters*/) {
return (new MemHostDataSource());
return (HostDataSourcePtr(new MemHostDataSource()));
}
} // namespace isc::dhcp::test
......
......@@ -225,7 +225,7 @@ typedef boost::shared_ptr<MemHostDataSource> MemHostDataSourcePtr;
///
/// @param parameters
/// @return A pointer to a base host data source instance.
BaseHostDataSource*
HostDataSourcePtr
memFactory(const DatabaseConnection::ParameterMap& /*parameters*/);
} // namespace isc::dhcp::test
......
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