Remove initialized_ member
the std::optional on interface represents the same information about
whether or not this interface have been initialized.
Change-Id: I365ac35a76f3fd710bddac3d55b514f3fde2f255
Signed-off-by: Ed Tanous <edtanous@google.com>
diff --git a/include/sdbusplus/asio/object_server.hpp b/include/sdbusplus/asio/object_server.hpp
index 9aed002..283b52e 100644
--- a/include/sdbusplus/asio/object_server.hpp
+++ b/include/sdbusplus/asio/object_server.hpp
@@ -352,7 +352,7 @@
CallbackTypeGet&& getFunction)
{
// can only register once
- if (initialized_)
+ if (is_initialized())
{
return false;
}
@@ -401,7 +401,7 @@
CallbackTypeGet&& getFunction)
{
// can only register once
- if (initialized_)
+ if (is_initialized())
{
return false;
}
@@ -494,7 +494,7 @@
template <typename PropertyType, bool changesOnly = false>
bool set_property(const std::string& name, const PropertyType& value)
{
- if (!initialized_)
+ if (!is_initialized())
{
return false;
}
@@ -522,7 +522,7 @@
template <typename... SignalSignature>
bool register_signal(const std::string& name)
{
- if (initialized_)
+ if (is_initialized())
{
return false;
}
@@ -549,7 +549,7 @@
using InputTupleType = utility::decay_tuple_t<CallbackSignature>;
using ResultType = boost::callable_traits::return_type_t<CallbackType>;
- if (initialized_)
+ if (is_initialized())
{
return false;
}
@@ -693,7 +693,7 @@
*/
auto new_signal(const char* member)
{
- if (!initialized_)
+ if (is_initialized())
{
return message_t(nullptr);
}
@@ -703,11 +703,10 @@
bool initialize(const bool skipPropertyChangedSignal = false)
{
// can only register once
- if (initialized_)
+ if (is_initialized())
{
return false;
}
- initialized_ = true;
vtable_.emplace_back(vtable::end());
interface_.emplace(static_cast<sdbusplus::bus_t&>(*conn_),
@@ -728,12 +727,12 @@
bool is_initialized()
{
- return initialized_;
+ return interface_.has_value();
}
bool signal_property(const std::string& name)
{
- if (!initialized_)
+ if (!is_initialized())
{
return false;
}
@@ -763,8 +762,6 @@
std::unordered_map<std::string, std::unique_ptr<callback>> callbacksMethod_;
std::vector<sd_bus_vtable> vtable_;
std::optional<sdbusplus::server::interface_t> interface_;
-
- bool initialized_ = false;
};
class object_server