Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Debugger: Add initial version of TargetHostInterfaceRoster.
TargetHostInterfaceRoster: - Provides a singleton interface to enumerate both the available interface types, and all currently running instances. This will provide clients like the TeamsWindow with a way to present the user with all available types, as well as the necessary information to configure/instantiate them. TargetHostInterfaceInfo: - Provides an information object for each available type of interface, including an optional description of the settings needed to configure it. Callers can then use this to provide a configuration UI as needed, and once complete, request a corresponding interface instance for the desired configuration. {Local}TargetHostInterface: - Add Settings parameter to Init(). Adjust LocalTargetHostInterface accordingly. LocalTargetHostInterfaceInfo: - Implementation of TargetHostInterfaceInfo for the local system case.
- Loading branch information
Showing
11 changed files
with
325 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/apps/debugger/target_host_interface/TargetHostInterfaceInfo.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright 2016, Rene Gollent, rene@gollent.com. | ||
* Distributed under the terms of the MIT License. | ||
*/ | ||
#include "TargetHostInterfaceInfo.h" | ||
|
||
|
||
TargetHostInterfaceInfo::TargetHostInterfaceInfo(const BString& name) | ||
: | ||
BReferenceable(), | ||
fName(name) | ||
{ | ||
} | ||
|
||
|
||
TargetHostInterfaceInfo::~TargetHostInterfaceInfo() | ||
{ | ||
} |
40 changes: 40 additions & 0 deletions
40
src/apps/debugger/target_host_interface/TargetHostInterfaceInfo.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2016, Rene Gollent, rene@gollent.com. | ||
* Distributed under the terms of the MIT License. | ||
*/ | ||
#ifndef TARGET_HOST_INTERFACE_INFO_H | ||
#define TARGET_HOST_INTERFACE_INFO_H | ||
|
||
#include <String.h> | ||
|
||
#include <Referenceable.h> | ||
#include <util/DoublyLinkedList.h> | ||
|
||
|
||
class Settings; | ||
class SettingsDescription; | ||
class TargetHostInterface; | ||
|
||
|
||
class TargetHostInterfaceInfo : public BReferenceable { | ||
public: | ||
TargetHostInterfaceInfo(const BString& name); | ||
virtual ~TargetHostInterfaceInfo(); | ||
|
||
const BString& Name() const { return fName; } | ||
|
||
virtual status_t Init() = 0; | ||
|
||
virtual bool IsLocal() const = 0; | ||
virtual bool IsConfigured(Settings* settings) const = 0; | ||
virtual SettingsDescription* GetSettingsDescription() const = 0; | ||
|
||
virtual status_t CreateInterface(Settings* settings, | ||
TargetHostInterface*& _interface) const | ||
= 0; | ||
|
||
private: | ||
BString fName; | ||
}; | ||
|
||
#endif // TARGET_HOST_INTERFACE_INFO_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Copyright 2016, Rene Gollent, rene@gollent.com. | ||
* Distributed under the terms of the MIT License. | ||
*/ | ||
#include "TargetHostInterfaceRoster.h" | ||
|
||
#include <new> | ||
|
||
#include <AutoDeleter.h> | ||
|
||
#include "LocalTargetHostInterfaceInfo.h" | ||
#include "TargetHostInterface.h" | ||
#include "TargetHostInterfaceInfo.h" | ||
|
||
|
||
/*static*/ TargetHostInterfaceRoster* | ||
TargetHostInterfaceRoster::sDefaultInstance = NULL; | ||
|
||
|
||
TargetHostInterfaceRoster::TargetHostInterfaceRoster() | ||
: | ||
fLock(), | ||
fInterfaceInfos(20, false), | ||
fActiveInterfaces(20, false) | ||
{ | ||
} | ||
|
||
|
||
TargetHostInterfaceRoster::~TargetHostInterfaceRoster() | ||
{ | ||
} | ||
|
||
|
||
/*static*/ TargetHostInterfaceRoster* | ||
TargetHostInterfaceRoster::Default() | ||
{ | ||
return sDefaultInstance; | ||
} | ||
|
||
|
||
/*static*/ status_t | ||
TargetHostInterfaceRoster::CreateDefault() | ||
{ | ||
if (sDefaultInstance != NULL) | ||
return B_OK; | ||
|
||
TargetHostInterfaceRoster* roster | ||
= new(std::nothrow) TargetHostInterfaceRoster; | ||
if (roster == NULL) | ||
return B_NO_MEMORY; | ||
ObjectDeleter<TargetHostInterfaceRoster> rosterDeleter(roster); | ||
|
||
status_t error = roster->Init(); | ||
if (error != B_OK) | ||
return error; | ||
|
||
error = roster->RegisterInterfaceInfos(); | ||
if (error != B_OK) | ||
return error; | ||
|
||
sDefaultInstance = rosterDeleter.Detach(); | ||
return B_OK; | ||
} | ||
|
||
|
||
/*static*/ void | ||
TargetHostInterfaceRoster::DeleteDefault() | ||
{ | ||
TargetHostInterfaceRoster* roster = sDefaultInstance; | ||
sDefaultInstance = NULL; | ||
delete roster; | ||
} | ||
|
||
|
||
status_t | ||
TargetHostInterfaceRoster::Init() | ||
{ | ||
return fLock.InitCheck(); | ||
} | ||
|
||
|
||
status_t | ||
TargetHostInterfaceRoster::RegisterInterfaceInfos() | ||
{ | ||
TargetHostInterfaceInfo* info = NULL; | ||
BReference<TargetHostInterfaceInfo> interfaceReference; | ||
|
||
#undef REGISTER_INTERFACE_INFO | ||
#define REGISTER_INTERFACE_INFO(type) \ | ||
info = new(std::nothrow) type##TargetHostInterfaceInfo; \ | ||
if (info == NULL) \ | ||
return B_NO_MEMORY; \ | ||
interfaceReference.SetTo(info, true); \ | ||
if (!fInterfaceInfos.AddItem(info)) \ | ||
return B_NO_MEMORY; \ | ||
interfaceReference.Detach(); | ||
|
||
REGISTER_INTERFACE_INFO(Local) | ||
|
||
return B_OK; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright 2016, Rene Gollent, rene@gollent.com. | ||
* Distributed under the terms of the MIT License. | ||
*/ | ||
#ifndef TARGET_HOST_INTERFACE_ROSTER_H | ||
#define TARGET_HOST_INTERFACE_ROSTER_H | ||
|
||
#include <OS.h> | ||
|
||
#include <Locker.h> | ||
#include <ObjectList.h> | ||
|
||
|
||
class Settings; | ||
class TargetHostInterface; | ||
class TargetHostInterfaceInfo; | ||
|
||
|
||
class TargetHostInterfaceRoster { | ||
public: | ||
TargetHostInterfaceRoster(); | ||
virtual ~TargetHostInterfaceRoster(); | ||
|
||
static TargetHostInterfaceRoster* Default(); | ||
static status_t CreateDefault(); | ||
static void DeleteDefault(); | ||
|
||
status_t Init(); | ||
status_t RegisterInterfaceInfos(); | ||
|
||
int32 CountInterfaceInfos(); | ||
TargetHostInterfaceInfo* | ||
InterfaceInfoAt(int32 index) const; | ||
|
||
status_t CreateInterface(TargetHostInterfaceInfo* info, | ||
Settings* settings, | ||
TargetHostInterface*& _interface) const; | ||
|
||
int32 CountActiveInterfaces(); | ||
TargetHostInterface* ActiveInterfaceAt(int32 index) const; | ||
|
||
private: | ||
typedef BObjectList<TargetHostInterfaceInfo> InfoList; | ||
typedef BObjectList<TargetHostInterface> InterfaceList; | ||
|
||
private: | ||
BLocker fLock; | ||
static TargetHostInterfaceRoster* sDefaultInstance; | ||
|
||
InfoList fInterfaceInfos; | ||
InterfaceList fActiveInterfaces; | ||
}; | ||
|
||
|
||
#endif // TARGET_HOST_INTERFACE_ROSTER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/apps/debugger/target_host_interface/local/LocalTargetHostInterfaceInfo.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright 2016, Rene Gollent, rene@gollent.com. | ||
* Distributed under the terms of the MIT License. | ||
*/ | ||
#include "LocalTargetHostInterfaceInfo.h" | ||
|
||
#include "LocalTargetHostInterface.h" | ||
|
||
|
||
LocalTargetHostInterfaceInfo::LocalTargetHostInterfaceInfo() | ||
: | ||
TargetHostInterfaceInfo("Local") | ||
{ | ||
} | ||
|
||
|
||
LocalTargetHostInterfaceInfo::~LocalTargetHostInterfaceInfo() | ||
{ | ||
} | ||
|
||
|
||
status_t | ||
LocalTargetHostInterfaceInfo::Init() | ||
{ | ||
return B_OK; | ||
} | ||
|
||
|
||
bool | ||
LocalTargetHostInterfaceInfo::IsLocal() const | ||
{ | ||
return true; | ||
} | ||
|
||
|
||
bool | ||
LocalTargetHostInterfaceInfo::IsConfigured(Settings* settings) const | ||
{ | ||
return true; | ||
} | ||
|
||
|
||
SettingsDescription* | ||
LocalTargetHostInterfaceInfo::GetSettingsDescription() const | ||
{ | ||
// the local interface requires no configuration, therefore | ||
// it returns no settings description, and has no real work | ||
// to do as far as settings validation is concerned. | ||
return NULL; | ||
} | ||
|
||
|
||
status_t | ||
LocalTargetHostInterfaceInfo::CreateInterface(Settings* settings, | ||
TargetHostInterface*& _interface) const | ||
{ | ||
LocalTargetHostInterface* interface | ||
= new(std::nothrow) LocalTargetHostInterface; | ||
if (interface == NULL) | ||
return B_NO_MEMORY; | ||
|
||
BReference<LocalTargetHostInterface> interfaceReference(interface, true); | ||
status_t error = interface->Init(settings); | ||
if (error != B_OK) | ||
return error; | ||
|
||
_interface = interface; | ||
interfaceReference.Detach(); | ||
|
||
return B_OK; | ||
} | ||
|
29 changes: 29 additions & 0 deletions
29
src/apps/debugger/target_host_interface/local/LocalTargetHostInterfaceInfo.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2016, Rene Gollent, rene@gollent.com. | ||
* Distributed under the terms of the MIT License. | ||
*/ | ||
#ifndef LOCAL_TARGET_HOST_INTERFACE_INFO_H | ||
#define LOCAL_TARGET_HOST_INTERFACE_INFO_H | ||
|
||
#include "TargetHostInterfaceInfo.h" | ||
|
||
|
||
class LocalTargetHostInterfaceInfo : public TargetHostInterfaceInfo { | ||
public: | ||
LocalTargetHostInterfaceInfo(); | ||
virtual ~LocalTargetHostInterfaceInfo(); | ||
|
||
virtual status_t Init(); | ||
|
||
virtual bool IsLocal() const; | ||
virtual bool IsConfigured(Settings* settings) const; | ||
virtual SettingsDescription* GetSettingsDescription() const; | ||
|
||
virtual status_t CreateInterface(Settings* settings, | ||
TargetHostInterface*& _interface) const; | ||
|
||
private: | ||
BString fName; | ||
}; | ||
|
||
#endif // TARGET_HOST_INTERFACE_INFO_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters