Skip to content

Commit be1c72e

Browse files
committed
Refactor device map methods to use OnixDeviceMap for consistency
1 parent 241b191 commit be1c72e

File tree

7 files changed

+16
-25
lines changed

7 files changed

+16
-25
lines changed

Source/OnixDevice.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ namespace OnixSourcePlugin
144144
std::vector<std::string> m_channelIdentifierSubTypes = { "subtypes" };
145145
};
146146

147+
using OnixDeviceMap = std::map<uint32_t, OnixDeviceType>;
148+
147149
/**
148150
149151
Streams data from an ONIX device
@@ -156,28 +158,18 @@ namespace OnixSourcePlugin
156158
/** Constructor */
157159
OnixDevice(std::string name_, std::string hubName, OnixDeviceType type_, const oni_dev_idx_t, std::shared_ptr<Onix1> oni_ctx, bool passthrough = false);
158160

159-
/** Destructor */
160-
~OnixDevice() { }
161-
162161
virtual void addFrame(oni_frame_t*) {};
163-
164162
virtual void processFrames() {};
165163

166164
const std::string getName() { return name; }
167-
168165
bool isEnabled() const { return enabled; }
169-
170166
void setEnabled(bool newState) { enabled = newState; }
171167
oni_dev_idx_t getDeviceIdx(bool getPassthroughIndex = false);
172168

173169
virtual int configureDevice() { return -1; };
174-
175170
virtual bool updateSettings() { return false; };
176-
177171
virtual void startAcquisition() {};
178-
179172
virtual void stopAcquisition() {};
180-
181173
/** Given the sourceBuffers from OnixSource, add all streams for the current device to the array */
182174
virtual void addSourceBuffers(OwnedArray<DataBuffer>& sourceBuffers) {};
183175

Source/OnixSource.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -589,9 +589,9 @@ OnixDeviceVector OnixSource::getDevices(OnixDeviceType type)
589589
return foundDevices;
590590
}
591591

592-
std::map<int, OnixDeviceType> OnixSource::createDeviceMap(OnixDeviceVector devices, bool filterDevices)
592+
OnixDeviceMap OnixSource::getConnectedDevices(OnixDeviceVector devices, bool filterDevices)
593593
{
594-
std::map<int, OnixDeviceType> deviceMap;
594+
OnixDeviceMap deviceMap;
595595

596596
for (const auto& device : devices)
597597
{
@@ -603,9 +603,9 @@ std::map<int, OnixDeviceType> OnixSource::createDeviceMap(OnixDeviceVector devic
603603
return deviceMap;
604604
}
605605

606-
std::map<int, OnixDeviceType> OnixSource::createDeviceMap(bool filterDevices)
606+
OnixDeviceMap OnixSource::getConnectedDevices(bool filterDevices)
607607
{
608-
return createDeviceMap(getEnabledDataSources(), filterDevices);
608+
return getConnectedDevices(getEnabledDataSources(), filterDevices);
609609
}
610610

611611
std::map<int, std::string> OnixSource::getHubNames()
@@ -952,7 +952,7 @@ std::string OnixSource::createContinuousChannelIdentifier(StreamInfo streamInfo,
952952
bool OnixSource::isDevicesReady()
953953
{
954954
auto tabMap = editor->createTabMapFromCanvas();
955-
auto sourceMap = createDeviceMap(true);
955+
auto sourceMap = getConnectedDevices(true);
956956

957957
return tabMap == sourceMap;
958958
}

Source/OnixSource.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ namespace OnixSourcePlugin
117117
std::shared_ptr<OnixDevice> getDevice(OnixDeviceType, int);
118118
OnixDeviceVector getDevices(OnixDeviceType);
119119

120-
static std::map<int, OnixDeviceType> createDeviceMap(OnixDeviceVector, bool filterDevices = false);
120+
static OnixDeviceMap getConnectedDevices(OnixDeviceVector, bool filterDevices = false);
121121

122-
std::map<int, OnixDeviceType> createDeviceMap(bool filterDevices = false);
122+
OnixDeviceMap getConnectedDevices(bool filterDevices = false);
123123

124124
std::map<int, std::string> getHubNames();
125125

Source/OnixSourceCanvas.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ void OnixSourceCanvas::removeAllTabs()
245245
topLevelTabComponent->clearTabs();
246246
}
247247

248-
std::map<int, OnixDeviceType> OnixSourceCanvas::createSelectedMap(std::vector<std::shared_ptr<SettingsInterface>> interfaces)
248+
OnixDeviceMap OnixSourceCanvas::getSelectedDevices(std::vector<std::shared_ptr<SettingsInterface>> interfaces)
249249
{
250-
std::map<int, OnixDeviceType> tabMap;
250+
OnixDeviceMap tabMap;
251251

252252
for (const auto& settings : interfaces)
253253
{

Source/OnixSourceCanvas.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ namespace OnixSourcePlugin
8989

9090
Array<CustomTabComponent*> getHubTabs();
9191

92-
std::map<int, OnixDeviceType> createSelectedMap(std::vector<std::shared_ptr<SettingsInterface>>);
92+
OnixDeviceMap getSelectedDevices(std::vector<std::shared_ptr<SettingsInterface>>);
9393

9494
std::vector<std::shared_ptr<SettingsInterface>> settingsInterfaces;
9595

@@ -102,7 +102,6 @@ namespace OnixSourcePlugin
102102
private:
103103

104104
OnixSourceEditor* editor;
105-
106105
OnixSource* source;
107106

108107
std::unique_ptr<CustomTabComponent> topLevelTabComponent;

Source/OnixSourceEditor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ bool OnixSourceEditor::configureAllDevices()
365365
connectButton->setToggleState(false, sendNotification);
366366
return false;
367367
}
368-
368+
369369
if (!source->configureBlockReadSize(source->getContext(), blockReadSizeValue->getText().getIntValue()))
370370
{
371371
connectButton->setToggleState(false, sendNotification);
@@ -633,9 +633,9 @@ void OnixSourceEditor::refreshComboBoxSelection()
633633
if (resetPortB) headstageComboBoxB->setSelectedItemIndex(0, dontSendNotification);
634634
}
635635

636-
std::map<int, OnixDeviceType> OnixSourceEditor::createTabMapFromCanvas()
636+
OnixDeviceMap OnixSourceEditor::createTabMapFromCanvas()
637637
{
638-
return canvas->createSelectedMap(canvas->settingsInterfaces);
638+
return canvas->getSelectedDevices(canvas->settingsInterfaces);
639639
}
640640

641641
void OnixSourceEditor::saveVisualizerEditorParameters(XmlElement* xml)

Source/OnixSourceEditor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ namespace OnixSourcePlugin
8383

8484
void refreshComboBoxSelection();
8585

86-
std::map<int, OnixDeviceType> createTabMapFromCanvas();
86+
OnixDeviceMap createTabMapFromCanvas();
8787

8888
void setConnectedStatus(bool);
8989

0 commit comments

Comments
 (0)