Skip to content

Commit

Permalink
Expose the default UID via the PluginAdaptor
Browse files Browse the repository at this point in the history
  • Loading branch information
peternewman committed Apr 14, 2024
1 parent 14d84e5 commit ebe7f20
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 10 deletions.
12 changes: 11 additions & 1 deletion include/olad/PluginAdaptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <ola/ExportMap.h>
#include <ola/base/Macro.h>
#include <ola/io/SelectServerInterface.h>
#include <ola/rdm/UID.h>
#include <olad/OlaServer.h>

#include <string>
Expand All @@ -48,13 +49,15 @@ class PluginAdaptor: public ola::io::SelectServerInterface {
* @param preferences_factory pointer to the PreferencesFactory object
* @param port_broker pointer to the PortBroker object
* @param instance_name the instance name of this OlaServer
* @param uid the ola::rdm::UID of this OlaServer
*/
PluginAdaptor(class DeviceManager *device_manager,
ola::io::SelectServerInterface *select_server,
ExportMap *export_map,
class PreferencesFactory *preferences_factory,
class PortBrokerInterface *port_broker,
const std::string *instance_name);
const std::string *instance_name,
const ola::rdm::UID *default_uid);

// The following methods are part of the SelectServerInterface
bool AddReadDescriptor(ola::io::ReadFileDescriptor *descriptor);
Expand Down Expand Up @@ -98,6 +101,12 @@ class PluginAdaptor: public ola::io::SelectServerInterface {
*/
const std::string InstanceName() const;

/**
* @brief Return the default UID for the OLA server
* @return an ola::rdm::UID which is the UID for the server
*/
const ola::rdm::UID DefaultUID() const;

ExportMap *GetExportMap() const {
return m_export_map;
}
Expand Down Expand Up @@ -134,6 +143,7 @@ class PluginAdaptor: public ola::io::SelectServerInterface {
class PreferencesFactory *m_preferences_factory;
class PortBrokerInterface *m_port_broker;
const std::string *m_instance_name;
const ola::rdm::UID *m_uid;

DISALLOW_COPY_AND_ASSIGN(PluginAdaptor);
};
Expand Down
2 changes: 1 addition & 1 deletion olad/OlaServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ bool OlaServer::Init() {
auto_ptr<PluginAdaptor> plugin_adaptor(
new PluginAdaptor(device_manager.get(), m_ss, m_export_map,
m_preferences_factory, port_broker.get(),
&m_instance_name));
&m_instance_name, &m_default_uid));

auto_ptr<PluginManager> plugin_manager(
new PluginManager(m_plugin_loaders, plugin_adaptor.get()));
Expand Down
4 changes: 2 additions & 2 deletions olad/PluginManagerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class MockLoader: public ola::PluginLoader {
*/
void PluginManagerTest::testPluginManager() {
ola::MemoryPreferencesFactory factory;
ola::PluginAdaptor adaptor(NULL, NULL, NULL, &factory, NULL, NULL);
ola::PluginAdaptor adaptor(NULL, NULL, NULL, &factory, NULL, NULL, NULL);

TestMockPlugin plugin1(&adaptor, ola::OLA_PLUGIN_ARTNET);
TestMockPlugin plugin2(&adaptor, ola::OLA_PLUGIN_ESPNET, false);
Expand Down Expand Up @@ -133,7 +133,7 @@ void PluginManagerTest::testPluginManager() {
*/
void PluginManagerTest::testConflictingPlugins() {
ola::MemoryPreferencesFactory factory;
ola::PluginAdaptor adaptor(NULL, NULL, NULL, &factory, NULL, NULL);
ola::PluginAdaptor adaptor(NULL, NULL, NULL, &factory, NULL, NULL, NULL);

set<ola::ola_plugin_id> conflict_set1, conflict_set2, conflict_set3;
conflict_set1.insert(ola::OLA_PLUGIN_ARTNET);
Expand Down
14 changes: 12 additions & 2 deletions olad/plugin_api/PluginAdaptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ PluginAdaptor::PluginAdaptor(DeviceManager *device_manager,
ExportMap *export_map,
PreferencesFactory *preferences_factory,
PortBrokerInterface *port_broker,
const std::string *instance_name):
const std::string *instance_name,
const ola::rdm::UID *default_uid):
m_device_manager(device_manager),
m_ss(select_server),
m_export_map(export_map),
m_preferences_factory(preferences_factory),
m_port_broker(port_broker),
m_instance_name(instance_name) {
m_instance_name(instance_name),
m_default_uid(default_uid) {
}

bool PluginAdaptor::AddReadDescriptor(
Expand Down Expand Up @@ -136,4 +138,12 @@ const std::string PluginAdaptor::InstanceName() const {
return "";
}
}

const ola::rdm::UID PluginAdaptor::DefaultUID() const {
if (m_default_uid) {
return *m_default_uid;
} else {
return ola::rdm::UID(0, 0);
}
}
} // namespace ola
2 changes: 1 addition & 1 deletion olad/plugin_api/PortTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void PortTest::testInputPortPriorities() {
MockDevice device(NULL, "foo");
TimeStamp time_stamp;
MockSelectServer ss(&time_stamp);
ola::PluginAdaptor plugin_adaptor(NULL, &ss, NULL, NULL, NULL, NULL);
ola::PluginAdaptor plugin_adaptor(NULL, &ss, NULL, NULL, NULL, NULL, NULL);
// This port operates in static priority mode
TestMockInputPort input_port(&device, 1, &plugin_adaptor);
port_manager.PatchPort(&input_port, universe_id);
Expand Down
6 changes: 3 additions & 3 deletions olad/plugin_api/UniverseTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ void UniverseTest::testReceiveDmx() {
ola::PortManager port_manager(m_store, &broker);
TimeStamp time_stamp;
MockSelectServer ss(&time_stamp);
ola::PluginAdaptor plugin_adaptor(NULL, &ss, NULL, NULL, NULL, NULL);
ola::PluginAdaptor plugin_adaptor(NULL, &ss, NULL, NULL, NULL, NULL, NULL);

MockDevice device(NULL, "foo");
TestMockInputPort port(&device, 1, &plugin_adaptor); // input port
Expand Down Expand Up @@ -366,7 +366,7 @@ void UniverseTest::testLtpMerging() {

TimeStamp time_stamp;
MockSelectServer ss(&time_stamp);
ola::PluginAdaptor plugin_adaptor(NULL, &ss, NULL, NULL, NULL, NULL);
ola::PluginAdaptor plugin_adaptor(NULL, &ss, NULL, NULL, NULL, NULL, NULL);
MockDevice device(NULL, "foo");
MockDevice device2(NULL, "bar");
TestMockInputPort port(&device, 1, &plugin_adaptor); // input port
Expand Down Expand Up @@ -446,7 +446,7 @@ void UniverseTest::testHtpMerging() {

TimeStamp time_stamp;
MockSelectServer ss(&time_stamp);
ola::PluginAdaptor plugin_adaptor(NULL, &ss, NULL, NULL, NULL, NULL);
ola::PluginAdaptor plugin_adaptor(NULL, &ss, NULL, NULL, NULL, NULL, NULL);
MockDevice device(NULL, "foo");
MockDevice device2(NULL, "bar");
TestMockInputPort port(&device, 1, &plugin_adaptor); // input port
Expand Down

0 comments on commit ebe7f20

Please sign in to comment.