Add the main.cpp file
Separate the main method from virtualSensor.cpp and add it to the
main.cpp file.
Change-Id: Ife3dd9bb6dee552d944399bcc769fc6c4ba54a4b
Signed-off-by: George Liu <liuxiwei@ieisystem.com>
diff --git a/main.cpp b/main.cpp
new file mode 100644
index 0000000..177a0e0
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,24 @@
+#include "virtualSensor.hpp"
+
+#include <sdbusplus/server.hpp>
+
+int main()
+{
+ // Get a handle to system dbus
+ auto bus = sdbusplus::bus::new_default();
+
+ // Add the ObjectManager interface
+ sdbusplus::server::manager_t objManager(bus,
+ "/xyz/openbmc_project/sensors");
+
+ // Create an virtual sensors object
+ phosphor::virtual_sensor::VirtualSensors virtualSensors(bus);
+
+ // Request service bus name
+ bus.request_name("xyz.openbmc_project.VirtualSensor");
+
+ // Run the dbus loop.
+ bus.process_loop();
+
+ return 0;
+}
diff --git a/meson.build b/meson.build
index 20d186b..a5320f7 100644
--- a/meson.build
+++ b/meson.build
@@ -25,9 +25,10 @@
'virtual-sensor',
[
'calculate.cpp',
- 'virtualSensor.cpp',
'dbusSensor.cpp',
'dbusUtils.cpp',
+ 'main.cpp',
+ 'virtualSensor.cpp',
],
dependencies: [
dependency('nlohmann_json', include_type: 'system'),
diff --git a/virtualSensor.cpp b/virtualSensor.cpp
index 1356325..3aeddf3 100644
--- a/virtualSensor.cpp
+++ b/virtualSensor.cpp
@@ -927,27 +927,3 @@
}
} // namespace phosphor::virtual_sensor
-
-/**
- * @brief Main
- */
-int main()
-{
- // Get a handle to system dbus
- auto bus = sdbusplus::bus::new_default();
-
- // Add the ObjectManager interface
- sdbusplus::server::manager_t objManager(bus,
- "/xyz/openbmc_project/sensors");
-
- // Create an virtual sensors object
- phosphor::virtual_sensor::VirtualSensors virtualSensors(bus);
-
- // Request service bus name
- bus.request_name("xyz.openbmc_project.VirtualSensor");
-
- // Run the dbus loop.
- bus.process_loop();
-
- return 0;
-}