Permalink
Browse files

Add the ability to fetch the preferred default interface to use in pl…

…ugins
  • Loading branch information...
peternewman committed Aug 17, 2018
1 parent 75da6b0 commit 9cce73edbe6467a4579245100f6539b7db69c73e
@@ -48,13 +48,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 default_ip_or_name the default IP or interface name to use
*/
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 std::string *default_ip_or_name);

// The following methods are part of the SelectServerInterface
bool AddReadDescriptor(ola::io::ReadFileDescriptor *descriptor);
@@ -96,7 +98,13 @@ class PluginAdaptor: public ola::io::SelectServerInterface {
* @brief Return the instance name for the OLA server
* @return a string which is the instance name
*/
const std::string InstanceName();
const std::string InstanceName() const;

/**
* @brief Return the default IP address or Interface name to use
* @return a string which is the default IP address or Interface name to use
*/
const std::string DefaultIPOrInterfaceName() const;

ExportMap *GetExportMap() const {
return m_export_map;
@@ -134,6 +142,7 @@ class PluginAdaptor: public ola::io::SelectServerInterface {
class PreferencesFactory *m_preferences_factory;
class PortBrokerInterface *m_port_broker;
const std::string *m_instance_name;
const std::string *m_default_ip_or_interface_name;

DISALLOW_COPY_AND_ASSIGN(PluginAdaptor);
};
@@ -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_options.network_interface));

auto_ptr<PluginManager> plugin_manager(
new PluginManager(m_plugin_loaders, plugin_adaptor.get()));
@@ -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);
@@ -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);
@@ -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 std::string *default_ip_or_name):
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_ip_or_interface_name(default_ip_or_name) {
}

bool PluginAdaptor::AddReadDescriptor(
@@ -129,11 +131,19 @@ const TimeStamp *PluginAdaptor::WakeUpTime() const {
return m_ss->WakeUpTime();
}

const std::string PluginAdaptor::InstanceName() {
const std::string PluginAdaptor::InstanceName() const {
if (m_instance_name) {
return *m_instance_name;
} else {
return "";
}
}

const std::string PluginAdaptor::DefaultIPOrInterfaceName() const {
if (m_default_ip_or_interface_name) {
return *m_default_ip_or_interface_name;
} else {
return "";
}
}
} // namespace ola
@@ -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);
@@ -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
@@ -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
@@ -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

0 comments on commit 9cce73e

Please sign in to comment.