Skip to content

Commit ea763de

Browse files
committed
add Sigslot as a generic publish/subscribe framework
The intention is to use this instead of adding more and more methods to the coVRPlugin base class. Usage examples: https://github.com/palacaze/sigslot deviceDiscovery is the first user of this.
1 parent ed789be commit ea763de

6 files changed

Lines changed: 24 additions & 0 deletions

File tree

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@
3232
[submodule "src/3rdparty/crow"]
3333
path = src/3rdparty/crow
3434
url = https://github.com/CrowCpp/Crow.git
35+
[submodule "src/3rdparty/sigslot"]
36+
path = src/3rdparty/sigslot
37+
url = https://github.com/palacaze/sigslot.git

src/3rdparty/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,12 @@ endif()
8989

9090
set(CROW_USE_BOOST ON CACHE BOOL "Use Boost.Asio for Crow" FORCE)
9191
add_subdirectory(crow)
92+
93+
#include(sigslot/cmake/SigSlotUtils.cmake)
94+
add_library(PalSigslot INTERFACE sigslot/include/sigslot/signal.hpp)
95+
target_include_directories(PalSigslot INTERFACE
96+
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/sigslot/include>
97+
$<INSTALL_INTERFACE:include>
98+
)
99+
install(TARGETS PalSigslot EXPORT covise-targets)
100+
add_library(Pal::Sigslot ALIAS PalSigslot)

src/3rdparty/sigslot

Submodule sigslot added at b588b79

src/OpenCOVER/cover/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ TARGET_LINK_LIBRARIES(${COVERKERNEL_TARGET} coOpenVRUI coOSGVRUI coMessages coOp
312312
${COVISE_VRBCLIENT_LIBRARY} ${COVISE_GRMSG_LIBRARY} ${COVISE_UTIL_LIBRARY} ${COVISE_GPU_LIBRARIES} ${COVISE_NET_LIBRARY}
313313
${XERCESC_LIBRARIES} ${OPENSCENEGRAPH_LIBRARIES} ${TIFF_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${EXTRA_LIBS})
314314

315+
TARGET_LINK_LIBRARIES(${COVERKERNEL_TARGET} Pal::Sigslot)
316+
315317
IF(CURL_FOUND)
316318
USING(CURL)
317319
add_dependencies(${COVERKERNEL_TARGET} coCurlHTTPClient)

src/OpenCOVER/cover/input/deviceDiscovery.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ namespace opencover
103103
}
104104
}
105105
toAdd.clear();
106+
auto firstNew = devices.end() - numToAdd;
107+
for (int i = 0; i < numToAdd; i++)
108+
{
109+
deviceAdded(*firstNew);
110+
++firstNew;
111+
}
106112
}
107113
void deviceDiscovery::run()
108114
{

src/OpenCOVER/cover/input/deviceDiscovery.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include <OpenThreads/Mutex>
2323
#include <util/UDPComm.h>
2424

25+
#include <sigslot/signal.hpp>
26+
2527

2628
namespace opencover
2729
{
@@ -56,6 +58,7 @@ namespace opencover
5658

5759
// only to be used from main thread
5860
const std::vector<const deviceInfo *> &getDevices() const;
61+
sigslot::signal<const deviceInfo *> deviceAdded;
5962

6063
private:
6164
std::vector<const deviceInfo *> devices;

0 commit comments

Comments
 (0)