Debugger: Add missing roster method implementations.

TargetHostInterfaceRoster:
- Implement counting/retrieving interfaces, as well as requesting the
  creation of a new instance.
This commit is contained in:
Rene Gollent
2016-04-13 20:10:17 -04:00
parent fbf9ac1ce4
commit 7dde731f40
2 changed files with 60 additions and 3 deletions
@@ -7,6 +7,7 @@
#include <new>
#include <AutoDeleter.h>
#include <AutoLocker.h>
#include "LocalTargetHostInterfaceInfo.h"
#include "TargetHostInterface.h"
@@ -99,3 +100,56 @@ TargetHostInterfaceRoster::RegisterInterfaceInfos()
return B_OK;
}
int32
TargetHostInterfaceRoster::CountInterfaceInfos() const
{
return fInterfaceInfos.CountItems();
}
TargetHostInterfaceInfo*
TargetHostInterfaceRoster::InterfaceInfoAt(int32 index) const
{
return fInterfaceInfos.ItemAt(index);
}
status_t
TargetHostInterfaceRoster::CreateInterface(TargetHostInterfaceInfo* info,
Settings* settings, TargetHostInterface*& _interface)
{
// TODO: this should eventually verify that an active interface with
// matching settings/type doesn't already exist, and if so, return that
// directly rather than instantiating a new one, since i.e. the interface
// for the local host only requires one instance.
AutoLocker<TargetHostInterfaceRoster> locker(this);
TargetHostInterface* interface;
status_t error = info->CreateInterface(settings, interface);
if (error != B_OK)
return error;
BReference<TargetHostInterface> interfaceReference(interface, true);
if (!fActiveInterfaces.AddItem(interface))
return B_NO_MEMORY;
_interface = interface;
interfaceReference.Detach();
return B_OK;
}
int32
TargetHostInterfaceRoster::CountActiveInterfaces() const
{
return fActiveInterfaces.CountItems();
}
TargetHostInterface*
TargetHostInterfaceRoster::ActiveInterfaceAt(int32 index) const
{
return fActiveInterfaces.ItemAt(index);
}
@@ -25,18 +25,21 @@ public:
static status_t CreateDefault();
static void DeleteDefault();
bool Lock() { return fLock.Lock(); }
void Unlock() { fLock.Unlock(); }
status_t Init();
status_t RegisterInterfaceInfos();
int32 CountInterfaceInfos();
int32 CountInterfaceInfos() const;
TargetHostInterfaceInfo*
InterfaceInfoAt(int32 index) const;
status_t CreateInterface(TargetHostInterfaceInfo* info,
Settings* settings,
TargetHostInterface*& _interface) const;
TargetHostInterface*& _interface);
int32 CountActiveInterfaces();
int32 CountActiveInterfaces() const;
TargetHostInterface* ActiveInterfaceAt(int32 index) const;
private: